T09 · Insecure Skill Coding Practices
- Location
scripts/generate_lego_build_plan.py:65- Finding
API Credential Exposed in URL Query String in LEGO Python Client
- Content
View full analysis
Vulnerability Details
File Location:
scripts/generate_lego_build_plan.py, lines 65-66
Vulnerability Type: API credential exposure through URL query parameters
Risk Level: MediumVulnerable Code
python query = parse.urlencode({"onekey": api_key}) url = f"{ENDPOINT}?{query}"Technical Analysis
The script reads
DEEPNLP_ONEKEY_ROUTER_ACCESSand embeds its value in the request URL as theonekeyquery parameter. Although the endpoint uses HTTPS, query strings are frequently recorded by destination access logs, reverse proxies, monitoring systems, tracing infrastructure, and diagnostic tools.Credential transmission is necessary for the declared hosted API operation, but placing the credential in a URL is not necessary. Authentication should use a request header designed for sensitive credentials.
The script does not intentionally print the URL or credential. Exploitation therefore depends on the credential-bearing URL being retained or exposed by infrastructure handling the request.
Attack Path
- A user configures a paid API credential in
DEEPNLP_ONEKEY_ROUTER_ACCESS. - The script copies that credential into the request URL.
- The destination server, a reverse proxy, or monitoring infrastructure records the complete URL.
- An attacker or unauthorized operator with access to those records extracts the
onekeyvalue. - The attacker submits requests using the recovered credential.
Impact Assessment
Successful exploitation could allow unauthorized use of the affected OneKey Gateway account, including quota consumption, paid request generation, and activity attributed to the credential owner. The exposed privilege is limited to the authorization scope granted to the API key; this finding does not provide direct local system access.
- A user configures a paid API credential in
- Remediation
View remediation
Remediation Suggestions
- Transmit the credential in an authentication header, such as
Authorization: Bearer ..., if supported by the service. - If the service uses a custom scheme, use a dedicated header such as
X-API-Key. - Ensure error handling, tracing, and debugging logic redact authentication headers.
- Never print or persist a credential-bearing URL.
- Configure gateway and proxy logs to redact existing
onekeyquery parameters. - Rotate credentials that may already have been retained in logs.
- Transmit the credential in an authentication header, such as
