T09 · Insecure Skill Coding Practices
- Location
scripts/claude_code_proxy.py:11- Finding
Hardcoded Upstream API Credential
- Content
View full analysis
Vulnerability Details
File Location:
scripts/claude_code_proxy.py:11-16
Vulnerability Type: Hardcoded bearer credential
Risk Level: HighVulnerable Code
python UPSTREAM_HOST = "api.53hk.cn" UPSTREAM_PATH = "/v1/chat/completions" API_KEY = "sk-4194e63b46b29886573888adcb69b5b10fcd41e8b9801f1ae66487c19d57a75a" LISTEN_PORT = 4002 MAX_RETRIES = 3 BASE_WAIT_SECONDS = 10The credential is subsequently transmitted to the upstream provider:
python upstream_url = f"https://{UPSTREAM_HOST}{UPSTREAM_PATH}" headers = { "Content-Type": "application/json", "Authorization": f"Bearer {API_KEY}", "Accept": "text/event-stream" }Technical Analysis
A live-format API key is embedded directly in distributed source code. Anyone with read access to the Skill package can recover the credential without executing the proxy. The proxy uses this value as a bearer token when submitting requests to
https://api.53hk.cn/v1/chat/completions.Hardcoded credentials cannot be safely rotated per installation, are likely to propagate into archives and source-control history, and make it impossible to distinguish authorized users of the credential. This exceeds least privilege because every recipient of the Skill receives access to the same upstream identity.
Attack Path
- An attacker downloads or otherwise obtains the Skill package.
- The attacker reads
scripts/claude_code_proxy.py. - The attacker extracts the value assigned to
API_KEY. - The attacker sends requests directly to the configured upstream endpoint with the extracted bearer token.
- Requests are charged to, rate-limited against, or attributed to the credential owner until the credential is revoked.
Impact Assessment
The exposed credential may permit unauthorized model requests under the upstream account's privileges. Potential impact includes quota theft, financial charges, service disruption thr ...[truncated 145 chars]
- Remediation
View remediation
Remediation Suggestions
- Revoke the exposed credential immediately and review upstream usage records for unauthorized activity.
- Remove all credentials from the distributed source and repository history.
- Read the key from a protected environment variable or operating-system secret store:
python import os API_KEY = os.environ.get("UPSTREAM_API_KEY") if not API_KEY: raise RuntimeError("UPSTREAM_API_KEY is required") - Give each deployment a separate, narrowly scoped credential with spending and rate limits.
- Add secret scanning to CI and pre-commit checks.
- Ensure exceptions and diagnostic output never print authorization headers.
