Sep 17, 2026·7 min read·16 visits
A missing validation of the RFC 9728 'resource' field in the rmcp crate allows rogue MCP servers to perform OAuth resource spoofing and capture legitimate access tokens.
An OAuth resource spoofing vulnerability in the rmcp crate prior to 2.0.0 allows a malicious Model Context Protocol (MCP) server to spoof protected resource metadata. By presenting metadata pointing to a legitimate resource and authorization server, the attacker can trick the client into completing the authentication flow and subsequently sending the authorized token back to the malicious server.
The rmcp crate is the official Rust Software Development Kit (SDK) implementing the Model Context Protocol (MCP). The framework operates as a standardized integration layer enabling Large Language Models (LLMs) to communicate with external data sources, applications, and custom tools. In highly secure environments, these transport connections are governed by robust authentication protocols, typically utilizing OAuth 2.0 frameworks. Specifically, the library implements OAuth Protected Resource Metadata discovery as defined under RFC 9728, which outlines the procedure for clients to automatically discover and trust authorization servers that correspond to given resource endpoints.
A high-severity vulnerability designated as CVE-2026-63127 exists in the client's transport authentication implementation, specifically within crates/rmcp/src/transport/auth.rs. Prior to version 2.0.0, the rmcp library did not validate that the resource identifiers returned during the automated discovery flow matched the target server with which the client established the original connection. This design flaw introduces an unauthenticated remote resource spoofing attack vector that compromises the security guarantees of the OAuth handshake.
This weakness is categorized under CWE-345 (Insufficient Verification of Data Authenticity), representing a failure to validate the binding between the metadata issuer and the actual resource identity. If an attacker hosts or compromises an MCP server, they can trick a connecting client into initiating an authentication flow with a legitimate, trusted third-party authorization server. Upon completion of this flow, the client mistakenly transmits the acquired high-privilege access token directly to the attacker's server, enabling downstream impersonation.
The technical breakdown of the vulnerability centers on the deserialization and subsequent validation logic in the discover_oauth_server_via_resource_metadata routine. According to RFC 9728 Sections 3.3 and 7.3, when a client performs metadata discovery, the resource server must return a JSON payload detailing its capabilities. Critically, the client is required to assert that the resource field inside the metadata response exactly matches the requested resource URL. This mechanism is critical to prevent resource server impersonation.
In affected versions of the rmcp crate, the JSON deserialization model ResourceServerMetadata did not contain the resource field. The library discarded this key entirely during deserialization because the struct was mapped using serde macro traits without a corresponding field placeholder. Consequently, the application logic was blind to the resource claim returned by the server, rendering it incapable of performing any validation checks.
Because the library completely ignored this property, the client did not perform the essential matching of domains, ports, or paths. If a user connected their client to an untrusted or malicious server, the server could instruct the client to authenticate against an arbitrary, highly-trusted authorization server. The validation layer failed to check the legitimacy of this binding, allowing the client to execute the entire OAuth PKCE workflow against the real authorization server under the false context of the untrusted connection.
To understand the precise code-level flaw, we must analyze the structure of the deserialization schema in crates/rmcp/src/transport/auth.rs prior to the patch.
// Vulnerable Struct Definition
#[derive(Debug, Clone, Deserialize)]
struct ResourceServerMetadata {
// Note the complete absence of the "resource" field
authorization_server: Option<String>,
authorization_servers: Option<Vec<String>>,
scopes_supported: Option<Vec<String>>,
}The absence of the resource field meant any server-side value assigned to it was dropped during the deserialization cycle. To fix this, the patch introduces the resource field and implements a strict check in AuthorizationManager::discover_metadata.
// Patched Struct Definition
#[derive(Debug, Clone, Deserialize)]
struct ResourceServerMetadata {
resource: Option<String>,
authorization_server: Option<String>,
authorization_servers: Option<Vec<String>>,
scopes_supported: Option<Vec<String>>,
}The validation helper function validate_resource_metadata_resource checks whether the target is valid:
impl AuthorizationManager {
fn validate_resource_metadata_resource(
&self,
metadata: &ResourceServerMetadata,
) -> Result<(), AuthError> {
let Some(resource) = metadata.resource.as_deref() else {
return Err(AuthError::MetadataError(
"Protected resource metadata missing required resource field".to_string(),
));
};
if !Self::resource_identifiers_match(self.base_url.as_str(), resource) {
return Err(AuthError::MetadataError(format!(
"Protected resource metadata resource mismatch: expected '{}', got '{}'",
self.base_url, resource
)));
}
Ok(())
}
}Furthermore, the matching logic utilizes resource_identifiers_match and is_root_resource_identifier to verify root path uniformity. It allows discrepancies limited strictly to root-level trailing slashes, thereby protecting against basic formatting differences while rejecting path traversal or cross-domain deviations.
Exploiting CVE-2026-63127 relies on standard HTTP manipulation techniques without requiring any advanced host penetration. First, the attacker registers or compromises a public or accessible endpoint, acting as a malicious Model Context Protocol server located at https://attacker-mcp.io. The attacker then waits for a victim client—such as an LLM agent framework configured with the rmcp crate and OAuth features enabled—to initiate a connection.
When the victim connects to the attacker-controlled server, the server responds with an HTTP 401 Unauthorized status code accompanied by a customized challenge header:
WWW-Authenticate: Bearer resource_metadata="https://attacker-mcp.io/.well-known/oauth-protected-resource". This header directs the vulnerable client to perform metadata discovery at the specified path.
When the client retrieves the metadata, the attacker's server serves a crafted JSON response:
{
"resource": "https://trusted-mcp.com",
"authorization_servers": ["https://auth.trusted-mcp.com"]
}The client deserializes this metadata, parses the legitimate authorization server list, and starts the login handshake. The victim's browser is launched to complete the authentication against https://auth.trusted-mcp.com.
After the victim successfully signs in and authorizes the application, the client completes the authorization code exchange to fetch an access token. Because the underlying connection state is still bound to https://attacker-mcp.io, the client transmits the legitimate bearer token to the attacker's endpoint. The attacker intercepts this token and can immediately perform authenticated operations on the target https://trusted-mcp.com server within the permissions granted by the stolen scopes.
The impact of this resource spoofing flaw is substantial, representing a complete bypass of the security boundary separating distinct OAuth resource domains. Since the vulnerability allows the direct capture of active OAuth bearer tokens, the attacker gains full read, write, or administrative access to the victim's target resource server, restricted only by the scopes assigned to the intercepted token.
In the context of CVSS 3.1, this vulnerability results in a Scope Change (S:C). This is because the compromise of the client's connection to the malicious server directly translates into unauthorized access to a distinct security authority (the trusted resource server). The confidentiality impact is High (C:H), and the integrity impact is Low (I:L) depending on the permissions of the scope requested by the target OAuth server.
No availability impact (A:N) is directly linked to this token theft. The base score is assessed at 8.2 (High). Since the attack requires the victim to click through a standard authentication prompt, user interaction is marked as Required (UI:R), but the complexity of execution remains Low (AC:L), and no initial privileges are required (PR:N) to initiate the spoofing sequence.
To mitigate the risk of CVE-2026-63127, administrators and developers must upgrade the rmcp dependency to version 2.0.0 or higher. This update alters the deserialization engine to strictly enforce RFC 9728 validation standards, dropping connections where there is a mismatch between the metadata resource field and the connection base URL. Developers should adjust their Cargo.toml file to require version 2.0.0 or later and ensure that lockfiles are fully regenerated.
For environments where immediate library upgrading is impossible, temporary mitigation strategies must be applied. Network administrators can implement Web Application Firewall (WAF) rules or egress filters to block outgoing HTTP requests from client instances to unauthorized or unverified OAuth authorization and metadata endpoints. Additionally, client integrations should disable dynamic metadata discovery and enforce hardcoded, pre-approved lists of authorization servers for each active connection.
In addition to updating dependencies, software developers should treat this vulnerability as a lesson in input validation. Any security framework that delegates authentication parameters to a third party must verify the provenance and identity claims of that third party. Regression test suites should incorporate test assertions that deliberately introduce invalid or mismatched resource metadata to verify that the handshake fails gracefully under incorrect parameters.
CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:H/I:L/A:N| Product | Affected Versions | Fixed Version |
|---|---|---|
rmcp modelcontextprotocol | < 2.0.0 | 2.0.0 |
| Attribute | Detail |
|---|---|
| CWE ID | CWE-345 |
| Attack Vector | Network (AV:N) |
| CVSS v3.1 Score | 8.2 (High) |
| EPSS Score | N/A |
| Impact | Confidentiality High (C:H), Integrity Low (I:L), Scope Changed (S:C) |
| Exploit Status | Proof-of-Concept (PoC) available in official test suite |
| CISA KEV Status | Not Listed |
The software does not sufficiently verify the authenticity of data, which can lead to accepting forged or manipulated information.
CVE-2026-118777 is a prototype pollution vulnerability (CWE-1321) in the Forge JavaScript cryptography and networking library (distributed on npm as node-forge) prior to version 1.4.1. The flaw resides in the forge.http client subsystem, where incoming HTTP cookie names and paths parsed from Set-Cookie response headers are stored directly into standard JavaScript objects without key validation or property isolation. By returning crafted Set-Cookie headers containing keys such as __proto__ or constructor, a malicious HTTP server can inject arbitrary properties into Object.prototype, attach attributes to the global Object constructor, or delete built-in prototype methods to cause an application-wide denial of service.
CVE-2026-118775 (GHSA-4642-5mcj-2rqw) is an integer overflow and validation flaw in the ASN.1 serialization module of Forge (node-forge) prior to version 1.4.1. The asn1.oidToDer() function fails to validate the range of the first two arcs of an Object Identifier (OID) and truncates the packed initial subidentifier to a single 8-bit integer. Applications that perform policy checks on untrusted OID strings before encoding them into Distinguished Encoding Rules (DER) format can be tricked into emitting DER bytes that correspond to a completely different, restricted OID.
CVE-2026-119194 is an algorithmic complexity vulnerability (CWE-407) in the pyasn1 library for Python, affecting versions 0.3.3 through 0.6.4. The flaw resides in the schemaless decoding routine ConstructedPayloadDecoderBase._decodeComponentsSchemaless used across BER, CER, and DER codecs. By sending an ASN.1 container populated with child components whose tag identifiers are separated by multiples of CPython's integer hash modulus (sys.hash_info.modulus), an unauthenticated attacker can force worst-case hash collisions in an unbounded Python set, degrading decoding performance from O(N) to O(N^2) and causing a Denial of Service (DoS).
CVE-2026-119195 is an algorithmic complexity vulnerability (CWE-407) in the pyasn1 library for Python, affecting all versions prior to 0.6.5. When decoding constructed strings or indefinite-length ANY types across BER, CER, and certain DER code paths, the payload decoders repeatedly concatenate incoming fragments onto an immutable bytes object using the += operator. Because Python bytes objects cannot be resized in-place, each fragment iteration allocates a new buffer and copies all previously accumulated bytes, resulting in quadratic O(N^2) time and memory copy complexity. An unauthenticated remote attacker can supply a highly fragmented ASN.1 stream to exhaust CPU cycles and stall application worker threads.
An algorithmic complexity vulnerability (CWE-407) in pyasn1 versions prior to 0.6.5 allows unauthenticated attackers to cause a Denial of Service (DoS) via crafted ASN.1 payloads. The flaw resides in the binary-encoded ASN.1 REAL mantissa deserialization routine within RealPayloadDecoder.valueDecoder. By performing iterative byte-string slicing and repeated bitwise shifts on a growing arbitrary-precision integer, the decoder exhibits quadratic time and memory allocation complexity relative to the mantissa length. Supplying a BER-, CER-, or DER-encoded payload with a large REAL mantissa causes excessive CPU consumption and blocks application worker processes.
A vulnerability classified under CWE-407 (Inefficient Algorithmic Complexity) exists in the pyasn1 library prior to version 0.6.5. When parsing constructed ASN.1 BIT STRING payloads under BER, CER, or schema-driven DER encoding rules, the BitStringPayloadDecoder repeatedly shifts and copies the entire accumulated bit value for each incoming fragment. Processing inputs with a large number of small constructed fragments induces quadratic CPU consumption, allowing unauthenticated remote attackers to cause a denial of service via resource exhaustion during the initial decoding phase.