T09 · Insecure Skill Coding Practices
- Location
scripts/swap.py:9- Finding
API Credential Exposed in Request URLs
- Content
View full analysis
Vulnerability Details
File Location:
scripts/swap.py, lines 9–17
Vulnerability Type: API credential exposure through URL components
Risk Level: MediumVulnerable Code:
python def get_estimate(from_coin, to_coin, amount, api_key): url = f"{API_BASE}/exchange-amount/{amount}/{from_coin}_{to_coin}/?api_key={api_key}" res = requests.get(url) if res.status_code == 200: return res.json() return {"error": res.text} def create_transaction(from_coin, to_coin, amount, address, api_key): url = f"{API_BASE}/transactions/{api_key}"Technical Analysis
The ChangeNOW API credential is embedded directly in a query string for estimate requests and in the URL path for transaction requests. Although the requests use HTTPS, TLS only protects the URL while it is in transit. Full request URLs can still be recorded by the destination service, reverse proxies, application monitoring systems, debugging tools, exception trackers, or local instrumentation.
Credential placement in URLs therefore exposes the API key to more systems and logs than necessary. This exceeds minimum-privilege data handling because only the ChangeNOW authentication layer needs access to the credential, while infrastructure that records request targets may also receive it.
The destination wallet address, asset identifiers, transaction amount, and disclosed affiliate identifier are operationally relevant to the declared swap functionality. No transmission to unrelated hosts was identified. The issue is specifically the insecure transport location of the API credential.
Attack Path
- A request is made to ChangeNOW using a URL containing
CHANGENOW_API_KEY. - A server, reverse proxy, monitoring agent, debugger, or exception-reporting system records the complete URL.
- An attacker obtains access to those logs or telemetry records.
- The attacker extracts the API key from the query string or URL path ...[truncated 834 chars]
- A request is made to ChangeNOW using a URL containing
- Remediation
View remediation
Remediation Suggestions
- Migrate to a current ChangeNOW endpoint that supports authentication through an HTTP authorization header rather than a query string or URL path.
- Use a construction such as
Authorization: Bearer ...or the exact dedicated API-key header required by the upstream API. - Ensure request logging, proxy logging, exception reporting, and application telemetry redact authorization values and sensitive URL fields.
- Rotate the currently configured API key because it may already have appeared in historical logs.
- Restrict the key to the minimum required API operations, apply rate limits, and enable account-side monitoring where supported.
- Avoid including credentials in raised exceptions or diagnostic output.
- If ChangeNOW mandates URL-based authentication for the selected API version, document the residual risk, disable full-URL logging throughout the request path, and use a narrowly scoped key.
