T09 · Insecure Skill Coding Practices
- Location
SKILL.md:36- Finding
Unvalidated API Host Can Redirect Authentication Credentials
- Content
View full analysis
Vulnerability Details
File Location:
SKILL.md, lines 36-47
Vulnerability Type: Unvalidated endpoint configuration and credential disclosure
Risk Level: MediumVulnerable Code
text 配置有效后,所有 API 请求的基地址为 `https://{api_host}`,认证方式为在 URL 查询参数中附加 `key={api_key}`。 ## 核心查询流程 **必须严格遵循以下顺序,不可跳过步骤:** ### 第一步:GeoAPI 获取城市 LocationID 使用城市名称(中文)调用 GeoAPI 获取精确位置信息。**禁止直接使用城市名称调用天气 API。** GET https://{api_host}/geo/v2/city/lookup?location={城市名}&range=cn&number=3&key={api_key}Technical Analysis
The Skill reads
api_hostfrom an editable configuration file and uses it directly as the destination for authenticated HTTPS requests. It checks only whether the value is empty; it does not require the host to belong to QWeather, reject IP addresses or embedded credentials, restrict ports, or define redirect handling.Because the API key is included in the query string, every request to a substituted host discloses the credential to that host. HTTPS only secures transport to the selected server; it does not establish that the selected server is an authorized QWeather endpoint.
Attack Path
- An attacker or compromised installation process modifies
qweather_config.json. - The attacker sets
api_hostto a domain under their control while leaving a valid QWeather API key configured. - A user invokes the Skill for a weather query.
- The Skill constructs an HTTPS request to the attacker-controlled host.
- The complete query string, including
key={api_key}, is delivered to the attacker. - The attacker extracts the key and may use it against QWeather until it is revoked or expires.
Impact Assessment
Successful exploitation exposes the configured QWeather API credential and permits unauthorized API consumption within the credential's assigned quota and permissions. It also allows weather-query inputs, such as requested city names, to be sent to an unintended server. This f ...[truncated 192 chars]
- An attacker or compromised installation process modifies
- Remediation
View remediation
Remediation Suggestions
- Validate
api_hostagainst an explicit allowlist of official QWeather API domains. - Parse the configured value as a hostname rather than interpolating an unrestricted string.
- Reject URL schemes, paths, query strings, fragments, embedded credentials, IP literals, unexpected ports, and unapproved subdomains in
api_host. - Disable redirects or validate the destination of every redirect before forwarding authentication data.
- Fail closed with a clear configuration error when validation fails.
- Prefer a fixed, trusted API base URL where deployment requirements permit it.
- Add tests covering malicious values such as
attacker.example,user@host, IP addresses, added paths, and redirecting endpoints. - Rotate the API key if requests may already have been sent to an untrusted host.
- Validate
