RMCP: Missing Resource Field Validation in OAuth Protected Resource Metadata Discovery
위협 신호 · CVSS · EPSS · KEV
이론적 심각도 점수
예측 데이터 없음
실측 악용 기록 없음
계획된 패치 주기 내 조치(60일 이내)
CVSS 벡터 · 메트릭
CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:H/I:L/A:N상세 설명
Summary
The rmcp library does not validate the resource parameter in OAuth Protected Resource metadata (RFC 9728), allowing a malicious MCP server to redirect OAuth flows to a legitimate authorization server and steal the resulting access tokens.
Details
RFC 9728 specifies two MUST requirements for resource parameter validation:
- Section 7.3: the client MUST ensure that the resource identifier URL it is using as the prefix for the metadata request exactly matches the
resourcevalue in the returned metadata document. - Section 3.3: if the
resourcevalue returned is not identical to the URL the client used, the data MUST NOT be used.
In the current implementation (crates/rmcp/src/transport/auth.rs), the ResourceServerMetadata struct (lines 390–394) does not include a resource field:
1struct ResourceServerMetadata { 2 authorization_server: Option<String>, 3 authorization_servers: Option<Vec<String>>, 4 scopes_supported: Option<Vec<String>>, 5}And discover_oauth_server_via_resource_metadata() (lines 1446–1465) proceeds without any resource URL validation.
Recommended fix
- Add the
resourcefield to the struct:text1struct ResourceServerMetadata {2 resource: Option<String>, // RFC 9728 REQUIRED field3 authorization_server: Option<String>,4 authorization_servers: Option<Vec<String>>,5 scopes_supported: Option<Vec<String>>,6} - Add validation logic after fetching metadata:
text1let Some(resource_metadata) = self2 .fetch_resource_metadata_from_url(&resource_metadata_url)3 .await?4else {5 return Ok(None);6};78// RFC 9728: validate that the resource identifier matches our target server9if let Some(resource) = &resource_metadata.resource {10 if resource.trim_end_matches('/') != self.base_url.as_str().trim_end_matches('/') {11 return Err(AuthError::MetadataError(format!(12 "Resource metadata mismatch: expected '{}', got '{}'",13 self.base_url, resource14 )));15 }16}
PoC
-
Attacker sets up a malicious MCP server at
fake-mcp.com/mcp. -
At
fake-mcp.com/mcp/.well-known/oauth-protected-resource, the attacker serves metadata declaring:- resource:
real-mcp.com/mcp(the legitimate server) - authorization_servers: the legitimate authorization server(s) of
real-mcp.com/mcp
- resource:
-
Victim configures any MCP client using
rmcpto connect tofake-mcp.com/mcp. -
rmcpfetches the protected resource metadata and, without validating that theresourcefield (real-mcp.com/mcp) differs from the configured server (fake-mcp.com/mcp), initiates an OAuth flow with the legitimate authorization server. -
The victim sees a legitimate authorization prompt and completes the flow.
-
The resulting access token — valid for
real-mcp.com/mcp— is sent tofake-mcp.com/mcpin subsequent requests. -
The attacker captures the token and can impersonate the victim on
real-mcp.com/mcp.
Impact
This is an access token theft vulnerability via OAuth resource metadata spoofing. All MCP clients built on rmcp that rely on OAuth-protected MCP servers are affected. An attacker who tricks a user into connecting to a malicious MCP server can steal valid access tokens for any legitimate MCP server, enabling full impersonation of the victim.
Credit
Jian Cui, Minsun Shim, Zhou Li, Xiaojing Liao
University of Illinois Urbana-Champaign (UIUC)
University of California, Irvine (UCI)
AI 심층 분석
공격 시나리오 · 재현 가능한 PoC 페이로드 · 즉시 적용 가능한 차단 패치를 한 번에 받아 보세요. 보안 운영팀이 그대로 점검·티켓팅에 쓸 수 있는 형태로 정리해 드립니다.
참고 자료 6
링크 내용 불러오는 중…