T09 · Insecure Skill Coding Practices
- Location
scripts/fetch_ai_news.py:87- Finding
API Credential Exposure Through URL Query Parameters and Command-Line Arguments
- Content
View full analysis
Vulnerability Details
File Location:
scripts/fetch_ai_news.py:87-96; related usage guidance inSKILL.md:32-46andSKILL.md:73
Vulnerability Type: Sensitive credential exposure through URL and process metadata
Risk Level: MediumVulnerable Code
python params = { "key": self.api_key, "num": min(max(1, num), MAX_NEWS_LIMIT), "page": max(1, page), } if word: params["word"] = word.strip() query_string = urllib.parse.urlencode(params) url = f"{API_ENDPOINT}?{query_string}" try: req = urllib.request.Request(url, headers={"User-Agent": "OpenClaw-Skill/1.0"}) with urllib.request.urlopen(req, timeout=DEFAULT_TIMEOUT) as resp:The documentation also recommends supplying credentials directly through the command line:
bash python3 scripts/fetch_ai_news.py <API_KEY> python3 scripts/fetch_ai_news.py <API_KEY> [num] [word] [page]It additionally demonstrates embedding the key in a request URL:
bash GET https://apis.tianapi.com/ai/index?key=YOUR_API_KEY&word=大模型&num=10&page=1Technical Analysis
The Skill legitimately requires a TianAPI credential to retrieve AI news, and the credential is sent only to the declared HTTPS endpoint,
apis.tianapi.com. The outbound request is therefore necessary for the advertised functionality and is not evidence of malicious exfiltration.However, the credential is included in the URL query string. HTTPS protects the request in transit, but query strings can still be recorded by destination-server access logs, reverse proxies, monitoring products, exception reports, debugging tools, and local request instrumentation. Anyone with access to such records may recover the API key.
Supplying the key as a command-line argument creates an additional exposure channel. Command arguments may be retained in shell history or exposed to local process-inspection mechanisms while the process is running. T ...[truncated 1462 chars]
- Remediation
View remediation
Remediation Suggestions
-
If TianAPI supports header-based authentication, transmit the key in an authorization header rather than in the query string.
-
If the service requires query-string authentication, avoid logging the constructed URL and configure clients, proxies, observability systems, and server logs to redact the
keyparameter. -
Remove examples that encourage users to place credentials directly in command arguments. Prefer the environment variable or a protected credential store.
-
Align the documented environment variable with the implementation. The metadata and documentation use
TIANAPI_AI_NEWS_KEY, while the script readsTIANAPI_AI_KEY. -
When supporting
.env, require restrictive permissions, such as:bash install -m 600 /dev/null scripts/.env printf '%s\n' 'TIANAPI_AI_KEY=REPLACE_WITH_KEY' > scripts/.env chmod 600 scripts/.env -
Ensure
.envis excluded from version control and packaging. -
Redact credentials from exceptions, debug output, telemetry, and future request tracing.
-
Advise affected users to rotate any key that may already have appeared in shell history, process logs, proxy logs, or monitoring records.
-
