T09 · Insecure Skill Coding Practices
- Location
SKILL.md:232- Finding
API Credentials May Be Disclosed to an Untrusted Configurable Endpoint
- Content
View full analysis
Vulnerability Details
File Location:
SKILL.md, lines 232–243
Vulnerability Type: Unrestricted credential transmission
Risk Level: MediumVulnerable Code
python def __init__(self, base_url: str, app_key: str, sign: str): self.base_url = base_url.rstrip('/') self.app_key = app_key self.sign = sign def _request(self, endpoint: str, payload: dict = None) -> dict: url = f"{self.base_url}/api/v2/open{endpoint}" data = {"appKey": self.app_key, "sign": self.sign} if payload: data.update(payload) resp = requests.post(url, json=data) return resp.json()Technical Analysis
The example accepts an unrestricted
base_urland transmitsapp_keyandsignto that URL on every request. It does not enforce HTTPS, validate the destination hostname against an allowlist, or control redirects. If an attacker can influence configuration, deployment variables, or caller input used to initialize the client, the credentials can be sent to an attacker-operated endpoint.The request also lacks a timeout and HTTP status validation. An unavailable endpoint can therefore hold the connection open, while non-successful or malformed responses are processed without first calling
raise_for_status().Although this is documentation example code rather than an automatically executed component, copying it directly into a production integration would create an exploitable credential-disclosure condition.
Attack Path
- An application adopts the documented
MingDaoAPIclient. - An attacker influences
base_urlthrough configuration manipulation, an exposed environment setting, or untrusted caller input. - The application initializes the client with valid API credentials and the attacker-controlled URL.
- A worksheet operation invokes
_request(). - The client sends
appKeyandsignin the JSON body to the attacker-controlled server. - The attacker ca ...[truncated 813 chars]
- An application adopts the documented
- Remediation
View remediation
Remediation Suggestions
- Require an
https://scheme and reject plaintext HTTP. - Parse the URL and compare the normalized hostname and port against an explicit allowlist of approved Mingdao API endpoints.
- Prevent callers from supplying arbitrary API base URLs unless such configurability is strictly required.
- Disable redirects for credential-bearing requests or validate every redirect destination before following it.
- Add bounded connection and read timeouts, for example
timeout=(5, 30). - Call
resp.raise_for_status()before parsing the response body. - Validate that the response is expected JSON and handle decoding and network exceptions safely.
- Store
app_keyandsignin a managed secret store rather than source code or broadly readable configuration. - Use a dedicated API identity with the minimum worksheet and operation permissions required.
- Avoid logging request bodies, headers, or exception objects that may contain credentials.
- Update the documentation example to state that
base_urlmust never come from untrusted input.
- Require an
