T09 · Insecure Skill Coding Practices
- Location
scripts/weather.py:22- Finding
API Credential and Query Data Transmitted over Plaintext HTTP
- Content
View full analysis
Vulnerability Details
File Location:
scripts/weather.py:22-23andscripts/weather.py:70-73
Vulnerability Type: Plaintext transmission of sensitive information
Risk Level: HighVulnerable Code
python WEATHER_API_URL = "http://apis.juhe.cn/simpleWeather/query" LIFE_API_URL = "http://apis.juhe.cn/simpleWeather/life"python def _request(url: str, params: dict) -> dict: """发起 HTTP GET 请求""" full_url = f"{url}?{urllib.parse.urlencode(params, encoding='utf-8')}" try: with urllib.request.urlopen(full_url, timeout=15) as resp: return json.loads(resp.read().decode("utf-8")) except Exception as e: return {"error_code": -1, "reason": f"网络请求失败: {e}"}Technical Analysis
The weather and lifestyle API endpoints use unencrypted HTTP. The
_requestfunction includes the Juhe API key and the user-supplied city in the URL query string before transmitting the request.Although sending an API credential to the declared weather provider is necessary for the Skill's functionality, sending it without transport encryption is not necessary and violates least-risk handling of credentials. Any party able to observe or modify traffic between the host and the API server—including a local-network attacker, compromised gateway, ISP-level observer, or malicious proxy—can read the API key and city value.
Placing the credential in a URL also increases exposure because complete URLs may be retained in proxy logs, access logs, network monitoring systems, or diagnostic records.
Attack Path
- A user configures a valid API key through
JUHE_WEATHER_KEY,scripts/.env, or the--keyargument. - The user invokes the script with a city name.
- The script constructs a URL such as:
http://apis.juhe.cn/simpleWeather/query?key=API_KEY&city=CITY - The complete URL is transmitted over plaintext HTTP.
- An attacker with network visibility ca ...[truncated 883 chars]
- A user configures a valid API key through
- Remediation
View remediation
Remediation Suggestions
-
Replace both plaintext endpoints with provider-supported HTTPS endpoints:
python WEATHER_API_URL = "https://apis.juhe.cn/simpleWeather/query" LIFE_API_URL = "https://apis.juhe.cn/simpleWeather/life" -
Ensure requests never fall back or redirect to HTTP. Validate the final response URL and reject any non-HTTPS scheme.
-
If supported by the provider, transmit the API key in an authorization header or POST body instead of the query string to reduce exposure in URL logs.
-
Update the direct-call examples in
SKILL.md:102-107to use HTTPS exclusively. -
Prefer the environment variable or a permission-restricted secret file for key configuration. Deprecate the
--keyoption because command-line arguments can be exposed through shell history and process listings. -
Rotate any API key that has previously been used through the current HTTP implementation, because it may already have been exposed.
-
