T09 · Insecure Skill Coding Practices
- Location
scripts/main.py:15- Finding
Hard-Coded Proxy Authentication Token
- Content
View full analysis
Vulnerability Details
File Location:
scripts/main.py, line 15
Vulnerability Type: Hard-coded secret in source code
Risk Level: MediumVulnerable Code
python PROXY_TOKEN = os.environ.get("PROXY_TOKEN", "tp_8k2mX9vQ4z")The token is subsequently used as an authentication header in
scripts/main.py, lines 27–29:python payload = json.dumps({"tool": tool_name, "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 embeds a default proxy authentication token directly in distributed source code. Although the
PROXY_TOKENenvironment variable can override it, installations without that variable automatically use the exposed credential.Source code is not an appropriate secret-storage mechanism. Anyone who can download or inspect the Skill package can recover the token without executing the Skill. The token can then be supplied in the
X-Proxy-Tokenheader when making requests to the default Tencent SCF proxy endpoint.Attack Path
- An attacker obtains the publicly distributed or otherwise accessible Skill package.
- The attacker opens
scripts/main.pyand extracts the default token from line 15. - The attacker identifies the default proxy endpoint from line 16.
- The attacker constructs HTTP POST requests containing the extracted token in the
X-Proxy-Tokenheader. - If the server accepts the embedded token, the attacker invokes proxy functionality outside the intended Skill runtime until the credential is revoked, restricted, or rotated.
Impact Assessment
Successful exploitation could permit unauthorized use of the proxy service within the permissions assigned to the exposed token. Potential effects include consumption of service quotas, increased operating costs, rate-limit exha ...[truncated 315 chars]
- Remediation
View remediation
Remediation Suggestions
- Remove the hard-coded fallback and require the token to be supplied through a protected environment variable or secret manager:
python PROXY_TOKEN = os.environ.get("PROXY_TOKEN") if not PROXY_TOKEN: raise RuntimeError("PROXY_TOKEN is required") - Rotate and revoke the exposed token because it must be treated as compromised after source distribution.
- Provision separate, scoped credentials for deployments rather than sharing one token across all installations.
- Restrict each token to the minimum required proxy method and resources.
- Apply server-side rate limits, expiration, usage quotas, and anomaly monitoring.
- Prevent tokens from appearing in source control, package artifacts, logs, exceptions, or diagnostic output.
- Add automated secret scanning to development and release pipelines.
- Remove the hard-coded fallback and require the token to be supplied through a protected environment variable or secret manager:
