T09 · Insecure Skill Coding Practices
- Location
scripts/main.py:45- Finding
Geolocation Data Retrieved Over Plaintext HTTP
- Content
View full analysis
Vulnerability Details
File Location:
scripts/main.py, lines 45–51
Vulnerability Type: Plaintext transmission and unauthenticated response integrity
Risk Level: Mediumpython def get_ip_info(ip): """通过 ip-api 获取 IP 地理位置信息""" try: data = fetch_url(f"http://ip-api.com/json/{ip}?lang=zh-CN", timeout=5) obj = json.loads(data) return obj except Exception: return NoneTechnical Analysis
The geolocation request is sent to
ip-api.comover plaintext HTTP rather than a TLS-protected HTTPS connection. Consequently, neither the confidentiality nor the integrity of the request and response is protected against an attacker with an on-path network position.The returned JSON is parsed and trusted without authenticity, schema, or field-type validation. Its country, region, city, ISP, timezone, latitude, and longitude values are subsequently presented as trusted results. An attacker capable of intercepting network traffic could therefore observe the queried public IP address or replace the server response with attacker-controlled geolocation information.
Attack Path
- A user invokes the Skill to retrieve public IP and geolocation information.
- The Skill discovers an IP address through one of its HTTPS-backed IP providers.
- The Skill sends that IP address to
http://ip-api.com/json/...over plaintext HTTP. - An attacker positioned on the local network, compromised gateway, proxy, ISP path, or another intermediary intercepts the request.
- The attacker observes the queried IP address and returns modified JSON containing forged country, region, city, ISP, timezone, or coordinate values.
- The Skill parses the modified response and displays the forged data without warning or validation.
Impact Assessment
Exploitation does not grant local code execution, additional operating-system privileges, persistence, or access to local credentials. ...[truncated 340 chars]
- Remediation
View remediation
Remediation Suggestions
- Replace the plaintext endpoint with a geolocation service that supports HTTPS and has an appropriate privacy and data-retention policy.
- Do not silently downgrade or redirect from HTTPS to HTTP.
- Retain standard TLS certificate and hostname verification; do not introduce an unverified SSL context.
- Validate the response before using it:
- Require a JSON object with the expected schema.
- Verify status or success fields supplied by the selected provider.
- Enforce expected types and reasonable length limits for textual fields.
- Confirm latitude and longitude are numeric and within valid ranges.
- Validate that the discovered value is a syntactically valid public IP address before placing it into a request path, for example by using Python's
ipaddressmodule. - Treat remote geolocation output as untrusted and avoid using it directly in security-sensitive authorization or policy decisions.
- Fail closed with a clear error when secure transport or response validation fails rather than presenting unverified data.
