T09 · Insecure Skill Coding Practices
- Location
scripts/main.py:20- Finding
Hard-Coded Proxy Authentication Token
- Content
View full analysis
Vulnerability Details
File Location:
scripts/main.py, lines 20 and 126–128
Vulnerability Type: Hard-coded secret in distributed source code
Risk Level: MediumVulnerable Code
python PROXY_TOKEN = os.environ.get("PROXY_TOKEN", "tp_8k2mX9vQ4z")The embedded token is subsequently added to requests sent to the proxy endpoints:
python payload = json.dumps({"type": "jingfen", "params": params}).encode("utf-8") headers = {"Content-Type": "application/json", "X-Proxy-Token": PROXY_TOKEN} req = urllib.request.Request(proxy_url, data=payload, headers=headers, method="POST")Technical Analysis
The application reads
PROXY_TOKENfrom the environment but falls back to a static authentication token embedded directly in the source code. Because the Skill package is distributed to users, the fallback token must be considered publicly exposed.An attacker can extract the token without executing the Skill and use it outside the intended client. If the backend treats this shared token as sufficient authorization, possession of the package grants the attacker the same proxy access associated with the Skill. Environment-based configuration does not mitigate the exposed fallback because the literal remains valid unless it has been revoked server-side.
Attack Path
- Download or otherwise obtain the published Skill package.
- Inspect
scripts/main.pyand extract the fallback value assigned toPROXY_TOKENat line 20. - Identify the fixed Tencent Cloud Function endpoints from the
CHANNELSconfiguration. - Construct POST requests using the expected JSON payload and set the extracted value in the
X-Proxy-Tokenheader. - Submit arbitrary supported proxy queries independently of the intended Skill runtime.
- Repeatedly invoke the endpoints to consume backend resources or quota, subject to server-side validation and rate limits.
Impact Assessment
Successful exploitation may allow unauthorized use of the proxy service wit ...[truncated 584 chars]
- Remediation
View remediation
Remediation Suggestions
- Remove the hard-coded fallback and require the credential to be supplied through secure runtime secret injection:
python PROXY_TOKEN = os.environ.get("PROXY_TOKEN") if not PROXY_TOKEN: raise RuntimeError("PROXY_TOKEN is required")- Revoke and rotate the exposed token immediately; removing it from a later source revision does not invalidate copies already distributed.
- Store the replacement in a managed secret store and avoid placing it in source code, package metadata, logs, examples, or error messages.
- Do not rely on a secret embedded in client-distributed code as the sole authorization control. Where feasible, issue short-lived, narrowly scoped credentials at runtime.
- Enforce server-side request validation, endpoint and operation scoping, quotas, rate limits, abuse detection, and credential rotation.
- Add automated secret scanning to source-control and release pipelines to prevent future credential publication.
