T09 · Insecure Skill Coding Practices
- Location
scripts/mxchip_mcp_client.py:59- Finding
OAuth Bearer Token Can Be Disclosed to an Arbitrary Endpoint
- Content
View full analysis
Vulnerability Details
File Location:
scripts/mxchip_mcp_client.py, lines 59-62, 76-87, and 118-122
Vulnerability Type: Unrestricted credential destination
Risk Level: MediumVulnerable Code
python def __init__( self, oauth_token: Optional[str] = None, base_url: str = "https://app.api.cloud.mxchip.com:2443/mcp" ): self.oauth_token = oauth_token or os.getenv("MXCHIP_OAUTH_TOKEN") if not self.oauth_token: raise AuthenticationError( "OAuth token required. Set MXCHIP_OAUTH_TOKEN environment variable " "or pass oauth_token parameter. Get token at: " "https://app.api.cloud.mxchip.com:2443/oauth2/mcp/oauth" ) self.base_url = base_url self.headers = { "Authorization": f"Bearer {self.oauth_token}", "Content-Type": "application/json", "Accept": "text/event-stream" } self.session = requests.Session() self.session.headers.update(self.headers)python response = self.session.post( self.base_url, json=payload, timeout=30 )Technical Analysis
The client accepts an unrestricted
base_urland places the user's OAuth token in the default headers of a persistentrequests.Session. Every request made through that session therefore transmits the token to the configured URL.The implementation does not require HTTPS, validate the destination hostname and port, or restrict the destination to the documented MXCHIP service. Consequently, a caller that controls or influences
base_urlcan redirect authenticated requests to an attacker-operated endpoint. This is especially sensitive because the token authorizes operations against physical smart-home devices.Attack Path
- The victim has a valid
MXCHIP_OAUTH_TOKENin the environment or passes one to the constructor. - An attacker influences application configuration or supplied cod ...[truncated 1369 chars]
- The victim has a valid
- Remediation
View remediation
Remediation Suggestions
- Remove the configurable endpoint if alternate MCP servers are not a supported requirement.
- If configurability is necessary, parse the URL and enforce:
- Scheme:
https - Hostname:
app.api.cloud.mxchip.com - Port:
2443 - Expected path:
/mcp
- Scheme:
- Reject embedded credentials, fragments, unexpected ports, malformed hosts, and hostname suffix tricks.
- Disable redirects or validate every redirect target before following it:
python response = self.session.post( self.base_url, json=payload, timeout=30, allow_redirects=False ) - Avoid setting authorization globally on a session that might later be used for another origin. Attach the token only after validating the destination immediately before each request.
- Add tests confirming that HTTP URLs, lookalike domains, alternate ports, and cross-origin redirects are rejected.
- Support intentional custom endpoints only through an explicit high-risk option that requires separately scoped credentials.
