T09 · Insecure Skill Coding Practices
- Location
caipiao.py:19- Finding
API Credential Exposed in URL Query String
- Content
View full analysis
Vulnerability Details
File Location:
caipiao.py, lines 19–23
Vulnerability Type: API credential exposure through URL query parameters
Risk Level: MediumVulnerable Code
python all_params = {"appkey": appkey} all_params.update({k: v for k, v in params.items() if v not in (None, "")}) url = f"{BASE_URL}/{path}" try: resp = requests.get(url, params=all_params, timeout=10)Technical Analysis
The
JISU_API_KEYvalue is inserted intoall_paramsasappkeyand passed torequests.getthrough theparamsargument. The Requests library serializes these parameters into the request URL, producing a request resembling:text https://api.jisuapi.com/caipiao/query?appkey=SECRET_VALUE&caipiaoid=13TLS protects the URL while it travels between the client and the HTTPS endpoint. However, URL query strings can be retained in HTTP client diagnostics, reverse-proxy logs, API gateway logs, server access logs, monitoring platforms, and error reports. Consequently, personnel or systems with access to those records may also obtain the credential.
Exploitation requires access to infrastructure or diagnostic records that capture the complete request URL. There is no evidence that this skill itself writes the URL to local logs.
Attack Path
- A user configures a valid API credential in the
JISU_API_KEYenvironment variable. - The skill copies that credential into the
appkeyquery parameter. requests.gettransmits a URL containing the credential to the external API.- A proxy, gateway, API server, monitoring service, or diagnostic facility records the complete URL.
- An attacker or unauthorized operator with access to those records extracts the API key.
- The attacker submits requests to JisuAPI using the exposed key until it is revoked, expires, or reaches its usage limit.
Impact Assessment
Successful exploitation does not grant local system privileges ...[truncated 472 chars]
- A user configures a valid API credential in the
- Remediation
View remediation
Remediation Suggestions
-
Use an authorization header instead of a URL parameter if JisuAPI supports header-based authentication:
python headers = {"Authorization": f"Bearer {appkey}"} resp = requests.get(url, params=params, headers=headers, timeout=10) -
If the provider supports POST authentication, place the credential in the request body rather than the URL.
-
If JisuAPI mandates the
appkeyquery parameter, configure clients, proxies, gateways, servers, and observability platforms to redactappkeyvalues and avoid recording full query strings. -
Use a dedicated key with the minimum required API permissions and conservative request or spending limits.
-
Rotate the key periodically and immediately rotate any key suspected of appearing in logs.
-
Restrict the key by source IP, permitted endpoint, or service scope when the provider offers those controls.
-
Document that query-string authentication is provider-mandated and warn operators not to enable verbose HTTP logging in production.
-
