T09 · Insecure Skill Coding Practices
- Location
scripts/main.py:11- Finding
Hard-Coded Proxy Authentication Token
- Content
View full analysis
Vulnerability Details
File Location:
scripts/main.py:11-19
Vulnerability Type: Hard-coded authentication secret
Risk Level: Highpython _PROXY_TOKEN = os.environ.get("PROXY_TOKEN", "tp_8k2mX9vQ4z") PROXIES = { "jd": { "url": "https://1439498936-9n7zsjnaif.ap-guangzhou.tencentscf.com", "token": _PROXY_TOKEN, }, "taobao": { "url": "https://1439498936-lofjio3yzf.ap-guangzhou.tencentscf.com", "token": _PROXY_TOKEN, }, }The token is subsequently transmitted in an authentication header at
scripts/main.py:196-203:python def _scf_call(proxy_key: str, req_type: str, params: dict) -> dict: """调用SCF代理接口""" proxy = PROXIES[proxy_key] payload = json.dumps({"type": req_type, "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") try: with urllib.request.urlopen(req, timeout=PROXY_TIMEOUT) as resp:Technical Analysis
When the
PROXY_TOKENenvironment variable is not configured, the application falls back to a reusable authentication token embedded directly in the distributed source code. Any party able to download or inspect the Skill can recover this token without executing the application.The token is used to authenticate HTTPS requests to two fixed Tencent Serverless Cloud Function endpoints. Sending price-search keywords to these proxy services is consistent with the Skill's declared remote price-comparison functionality and does not, by itself, exceed the minimum privileges needed. However, embedding the proxy credential is unnecessary and breaks secret-management boundaries. HTTPS protects the token while it is in transit but does not protect it from source-code disclosure.
Attack Path
- An attacker downloads or otherwise obtains the Skill package.
- The attacker reads
scripts/main.pyand ...[truncated 1180 chars]
- Remediation
View remediation
Remediation Suggestions
- Remove the hard-coded fallback token and fail securely when
PROXY_TOKENis unavailable. - Rotate and revoke the exposed token because publication in source code must be treated as credential compromise.
- Supply credentials through the platform's protected secret-management mechanism rather than source files, metadata, command-line arguments, or logs.
- Issue separate, short-lived, least-privilege credentials per deployment or installation instead of one reusable shared token.
- Restrict each credential to the exact proxy operations required for product searches.
- Enforce server-side schemas and allowlists for request types and parameters; never rely solely on client-side restrictions.
- Add per-token rate limits, quotas, anomaly detection, expiration, and revocation support.
- Avoid returning sensitive backend details in proxy error messages, and ensure authentication headers are never logged.
- Add automated secret scanning to release and CI pipelines to prevent future credential publication.
- Keep HTTPS certificate validation enabled for all proxy traffic.
- Remove the hard-coded fallback token and fail securely when
