T09 · Insecure Skill Coding Practices
- Location
scripts/weather.py:49- Finding
Unencrypted Weather API Communication
- Content
View full analysis
Vulnerability Details
File Location:
scripts/weather.py, lines 49–52
Vulnerability Type: Plaintext HTTP communication
Risk Level: Mediumpython def get_weather(city: str) -> dict: """调用 wttr.in 获取天气数据""" try: # 使用 format=j1 获取 JSON 格式数据 cmd = ["curl", "-s", f"wttr.in/{city}?format=j1"] result = subprocess.run(cmd, capture_output=True, text=True, timeout=10)Technical Analysis
The request URL does not specify an HTTPS scheme. Curl consequently treats the destination as an HTTP URL, transmitting the city query and receiving weather data without transport encryption or server authentication.
This exposes the request to passive observation and active man-in-the-middle modification. The city value can reveal location-related information. When no city is supplied, the external service performs source-IP-based geolocation, which necessarily discloses the requester's public IP to that service.
Data returned by the service is parsed as JSON and several remote fields are inserted directly into terminal and Markdown output. A network attacker capable of modifying the plaintext response could therefore supply misleading weather information or inject terminal or Markdown control content. This does not directly provide local command execution because the response is never passed to a shell or code evaluator.
Attack Path
- A user invokes the Skill with a city name or uses its automatic IP-location mode.
- The script constructs
wttr.in/{city}?format=j1without an HTTPS scheme. - Curl sends the request over plaintext HTTP.
- An attacker positioned on the network observes the requested location or intercepts the response.
- The attacker returns modified, structurally valid JSON containing attacker-controlled display values.
- The script parses those values and prints them in terminal and Markdown output.
Impact Assessment
An attacker with a suitabl ...[truncated 452 chars]
- Remediation
View remediation
Remediation Suggestions
- Use an explicit HTTPS endpoint, such as
https://wttr.in/.... - URL-encode the city as a path component using
urllib.parse.quote(city, safe=""). - If curl remains in use, enforce secure transport and HTTP error handling with options such as
--proto =https,--tlsv1.2,--fail, and--show-error. - Prefer a Python HTTPS client to remove the subprocess dependency and simplify timeout, response-size, content-type, and status-code validation.
- Reject unexpectedly large responses and verify that the response content type and JSON structure match expectations.
- Sanitize externally supplied text before inserting it into terminal or Markdown output, including stripping terminal escape and control characters.
- Use an explicit HTTPS endpoint, such as
