Credential Exfiltration and SSRF in utcp-http via OAuth2 tokenUrl
The utcp-http library fails to validate the tokenUrl field in OpenAPI specifications, enabling an attacker to redirect OAuth2 credential submissions to arbitrary endpoints or perform SSRF attacks.
The utcp-http library (versions <= 1.1.3) contains a critical trust boundary bypass vulnerability that allows for unauthorized credential exfiltration and Server-Side Request Forgery (SSRF). The library automatically extracts OAuth2 configuration, specifically the tokenUrl field, from remote OpenAPI specifications during the conversion process without performing any security validation. While the library enforces secure URL checks for discovery and tool invocation, these safeguards are omitted when performing OAuth2 token requests. An attacker can craft a malicious OpenAPI specification containing an arbitrary tokenUrl, which, when registered and triggered by a victim, causes the library to perform a POST request containing the victim's OAuth2 client_id and client_secret to an attacker-controlled endpoint. This vulnerability poses a significant risk to applications that register third-party OpenAPI specifications while utilizing OAuth2 authentication.
Attack Chain
- The attacker hosts a malicious OpenAPI specification on an accessible server, defining an OAuth2 security scheme with a custom, attacker-controlled
tokenUrl. - The victim registers the attacker's OpenAPI spec URL within their application using
utcp-http. - The
OpenApiConvertercomponent fetches and parses the specification, extracting the malicioustokenUrlinto anOAuth2Authobject without validation. - The victim invokes an OAuth2-protected tool via the
utcp-httpclient. - The
HttpCommunicationProtocoltriggers the_handle_oauth2method to retrieve an access token prior to the actual tool request. - The
_handle_oauth2method performs anasyncioPOST request using the verbatim, unvalidatedtokenUrlextracted from the specification. - The victim's application sends
client_idandclient_secretcredentials to the attacker's server, or performs an SSRF request to internal infrastructure. - The attacker captures the exfiltrated credentials to gain unauthorized access to protected resources on behalf of the victim.
Impact
Successful exploitation leads to immediate credential theft of OAuth2 client_id and client_secret pairs, providing attackers with full impersonation capabilities for the victim's identity. Furthermore, the lack of URL validation permits SSRF attacks against internal network resources, such as cloud metadata services (e.g., 169.254.169.254) or private internal APIs that are otherwise inaccessible from the public internet. Organizations that rely on utcp-http to integrate third-party or untrusted OpenAPI specifications are at high risk.
Recommendation
Prioritized, concrete actions for detection and remediation:
- Upgrade
utcp-httpto a patched version once available or implement the suggested remediation patch manually. - Implement the
ensure_secure_url()check withinopenapi_converter.pyandhttp_communication_protocol.pyto validatetokenUrlparameters before use. - Audit all registered OpenAPI specifications to ensure
tokenUrldomains align with known, trusted identity providers. - Monitor web application logs for outgoing POST requests from the
utcp-httpclient to unusual or external IP addresses in thetokenUrlfield. - Restrict the network environment of the service using
utcp-httpto prevent egress to unauthorized endpoints, reducing the impact of potential SSRF.
Immediate actions
Patch or upgrade utcp-http to remediate the missing ensure_secure_url() check.
Threat Hunt
Analyze outgoing POST requests from services using utcp-http for suspicious token endpoint domains.
Data: Egress proxy logs, Application network logs