T09 · Insecure Skill Coding Practices
- Location
scripts/fetch_ancbooks.py:73- Finding
API Credential Exposed in URL Query String
- Content
View full analysis
Vulnerability Details
File Location:
scripts/fetch_ancbooks.py:73-78
Vulnerability Type: API credential exposure through URL query parameters
Risk Level: Mediumpython params = { "key": self.api_key, "id": anc_id.strip() } query_string = urllib.parse.urlencode(params) url = f"{API_ENDPOINT}?{query_string}"Technical Analysis
The script embeds the TianAPI credential directly in the request URL. Although the endpoint uses HTTPS, TLS only protects the request while it is in transit. The complete URL may still be recorded by the API provider, reverse proxies, gateways, monitoring systems, exception diagnostics, or local debugging tools.
The Skill also permits the credential to be supplied through the
--keycommand-line option atscripts/fetch_ancbooks.py:107. Command-line secrets may be retained in shell history or exposed through process inspection while the command is running. These credential-handling methods unnecessarily increase the number of locations in which the API key can appear.Sending an authentication credential to TianAPI is necessary for the declared chapter-lookup functionality. The security concern is therefore not an undeclared network destination or excessive data collection, but the use of exposure-prone credential transport and input mechanisms.
Attack Path
- A user invokes the Skill with a valid TianAPI key.
- The script constructs a URL containing the key in its query string.
- A server, proxy, gateway, tracing service, or diagnostic system records the complete request URL.
- Alternatively, when
--keyis used, a local user obtains the key from shell history or process metadata. - An attacker with access to one of these records extracts the key.
- The attacker submits unauthorized TianAPI requests using the recovered credential.
Exploitation requires access to relevant local metadata, command history, infrastructure logs, or provider-side ...[truncated 636 chars]
- Remediation
View remediation
Remediation Suggestions
- If TianAPI supports it, send the credential in an authorization header or a POST request body rather than in the URL.
- Remove or deprecate the
--keycommand-line option. Prefer the dedicatedTIANAPI_ANCBOOKS_KEYenvironment variable or a protected credential store. - If TianAPI mandates query-string authentication, clearly document that limitation and configure all application, proxy, gateway, tracing, and error logs to redact the
keyparameter. - Avoid logging the constructed URL or exception objects that could contain it.
- If
.envsupport is retained, require owner-only file permissions and ensure the file is excluded from version control and package artifacts. - Update the usage documentation to recommend environment-based credential loading exclusively.
- Rotate any API key suspected of having appeared in shell history, process telemetry, or request logs.
