T09 · Insecure Skill Coding Practices
- Location
scripts/context7.py:15- Finding
Hard-Coded Context7 API Credential
- Content
View full analysis
Vulnerability Details
File Location:
scripts/context7.py, line 15
Vulnerability Type: Hard-coded API bearer token
Risk Level: HighVulnerable Code
python API_KEY = os.environ.get("CONTEXT7_API_KEY", "ctx7sk-d6069954-149e-4a74-ae8f-85092cbfcd6f")Technical Analysis
The script embeds a Context7 API key as the default value used whenever the
CONTEXT7_API_KEYenvironment variable is absent. Because the credential is distributed with the source code, anyone who can obtain the Skill package can extract it without executing the script.The environment-variable override does not protect the embedded fallback. The script subsequently places this credential in an HTTP
Authorization: Bearerheader for requests to Context7. Although HTTPS protects the credential in transit under normal certificate validation, it does not mitigate disclosure from the source code.Attack Path
- An attacker obtains or reads the distributed Skill package.
- The attacker opens
scripts/context7.pyand extracts the fallback bearer token from line 15. - The attacker submits authenticated requests to supported Context7 API endpoints using the exposed token.
- Requests consume the credential owner's API quota and are attributed to that credential until it is revoked or expires.
No additional local privilege escalation is required because the secret is directly readable from the source.
Impact Assessment
The attacker gains the Context7 API privileges assigned to the exposed credential. Potential consequences include unauthorized API use, quota or rate-limit consumption, unexpected service costs where applicable, activity attribution to the credential owner, and disruption if abuse causes throttling or revocation.
The audit found no evidence that this token grants local system privileges, accesses unrelated host secrets, or permits arbitrary code execution. The impact is limited to the authority and scope ...[truncated 48 chars]
- Remediation
View remediation
Remediation Suggestions
- Immediately revoke and rotate the exposed Context7 API credential.
- Remove the fallback secret and require explicit credential provisioning:
python API_KEY = os.environ.get("CONTEXT7_API_KEY") if not API_KEY: raise RuntimeError("CONTEXT7_API_KEY is required") - Supply the credential through a protected environment variable or secret-management service at runtime.
- Ensure secrets are excluded from source control, release archives, logs, examples, and documentation.
- Add automated secret scanning to commit and release workflows.
- Use a narrowly scoped credential with appropriate rate limits, expiration, monitoring, and rotation policies.
- Review Context7 access logs for unauthorized use of the disclosed credential.
