T09 · Insecure Skill Coding Practices
- Location
scripts/holiday_query.py:27- Finding
API Credential Transmitted Over Unencrypted HTTP
- Content
View full analysis
Vulnerability Details
File Location:
scripts/holiday_query.py, lines 27 and 70-78
Vulnerability Type: Plaintext transmission of sensitive credentials
Risk Level: HighVulnerable Code
python API_URL = "http://apis.juhe.cn/fapig/calendar/day"python params = { "key": api_key, "date": date, "detail": 1, } url = f"{API_URL}?{urllib.parse.urlencode(params)}" try: with urllib.request.urlopen(url, timeout=10) as resp: result = json.loads(resp.read().decode("utf-8"))Technical Analysis
The script places the Juhe API key in a URL query parameter and transmits the request using plaintext HTTP. HTTP provides neither transport confidentiality nor server authentication. Any party with network-path visibility—including a local network attacker, compromised router, transparent proxy, or Internet service provider—can inspect the URL and recover the API key.
An active man-in-the-middle can additionally alter the request or response. Because the response is not cryptographically authenticated, the script may display attacker-controlled holiday, calendar, or almanac information as though it came from the legitimate provider.
Sending the requested date to the API is necessary for the declared functionality. Sending the API credential without encrypted transport exceeds the minimum exposure necessary and is not required for the Skill to operate.
Attack Path
- A user configures a valid
JUHE_DATE_HOLIDAY_KEYand runs a normal holiday query. - The script constructs a URL containing
key=<API_KEY>. - The script sends that URL to
apis.juhe.cnover unencrypted HTTP. - An attacker with network-path visibility captures the HTTP request and extracts the key from its query string.
- The attacker reuses the credential against the provider's API, consuming its quota or accessing any API capabilities associated with that key.
- If actively interc ...[truncated 715 chars]
- A user configures a valid
- Remediation
View remediation
Remediation Suggestions
-
Replace the endpoint with the provider's HTTPS endpoint:
python API_URL = "https://apis.juhe.cn/fapig/calendar/day" -
Update the direct API example in
SKILL.mdto use HTTPS. -
Do not implement a fallback to plaintext HTTP if HTTPS fails.
-
If the provider supports it, transmit the credential in an authorization header instead of the URL. Query strings may be retained in browser, proxy, application-server, and monitoring logs even when HTTPS protects them in transit.
-
Handle HTTP and TLS errors without including the full request URL or credential in output or logs.
-
Rotate any API key that has already been used by this implementation because it may have been exposed on prior network paths.
-
Test that redirects cannot downgrade HTTPS requests to HTTP and that certificate validation remains enabled.
-
