T09 · Insecure Skill Coding Practices
- Location
stockhistory.py:17- Finding
API Credential Exposed in URL Query Parameters
- Content
View full analysis
Vulnerability Details
File Location:
stockhistory.py, lines 17–25
Vulnerability Type: API credential exposure through URL query strings
Risk Level: MediumVulnerable Code:
python def _call_api(path: str, appkey: str, params: dict = None): if params is None: params = {} 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 code adds the value of
JISU_API_KEYtoall_paramsasappkeyand passes that dictionary torequests.get()through theparamsargument. The Requests library serializes these parameters into the request URL, resulting in a URL resembling:text https://api.jisuapi.com/stockhistory/query?appkey=SECRET_VALUE&code=300917HTTPS encrypts the request while it is in transit, but it does not prevent complete URLs from being recorded at either endpoint or by trusted infrastructure. Query strings may appear in reverse-proxy access logs, API gateway logs, application telemetry, debugging output, monitoring systems, or HTTP client instrumentation. Consequently, personnel or attackers with access to those records may recover the API credential.
This is an insecure credential-handling practice consistent with CWE-598, “Use of GET Request Method With Sensitive Query Strings.”
Attack Path
- A user configures a valid JisuAPI credential in the
JISU_API_KEYenvironment variable. - The user invokes the skill's
query,list, ordetailcommand. _call_api()inserts the credential into the GET request's URL query string.- An API gateway, reverse proxy, endpoint server, telemetry component, or debugging facility records the complete request URL.
- An attacker or unauthorized operator gains read access to the relevant logs or telemetry.
...[truncated 856 chars]
- A user configures a valid JisuAPI credential in the
- Remediation
View remediation
Remediation Suggestions
-
Prefer an authentication header, such as
Authorization, or a POST body if JisuAPI officially supports either mechanism:python headers = {"Authorization": f"Bearer {appkey}"} resp = requests.get(url, params=params, headers=headers, timeout=10) -
Follow the provider's documented authentication mechanism. Do not migrate the key to a custom header unless the service supports it, because doing so could break authentication.
-
If JisuAPI requires
appkeyin the query string:- Disable full-query logging where possible.
- Configure gateways, proxies, telemetry systems, and exception handlers to redact
appkey. - Ensure debug-level HTTP logging is disabled in production.
- Restrict access to request logs and apply short retention periods.
- Use a dedicated, least-privilege API credential for this skill.
- Configure usage limits, billing alerts, and anomaly monitoring.
- Rotate the credential periodically and immediately after suspected exposure.
-
Avoid including response or exception details that might reproduce sensitive request URLs in user-visible output.
-
Add an automated test that captures generated diagnostics and verifies that the configured API key never appears in logs or error messages.
-
