T09 · Insecure Skill Coding Practices
- Location
handler.py:13- Finding
Hardcoded SkillPay API Key Exposed in Source Code and Documentation
- Content
View full analysis
Vulnerability Details
File Location:
handler.py:13andSKILL.md:24
Vulnerability Type: Hardcoded credential exposure
Risk Level: HighThe same SkillPay API key is embedded in both the executable source code and the public-facing skill documentation.
python # handler.py:13 SKILLPAY_API_KEY = os.environ.get("SKILLPAY_API_KEY", "sk_93c5ff38cc3e6112623d361fffcc5d1eb1b5844eac9c40043b57c0e08f91430e")markdown <!-- SKILL.md:22-25 --> This skill uses SkillPay for payment processing: - API Key: sk_93c5ff38cc3e6112623d361fffcc5d1eb1b5844eac9c40043b57c0e08f91430e - Price: 0.001 USDT per callThe credential is subsequently used to authenticate billing requests:
python headers = { "Content-Type": "application/json", "X-API-Key": SKILLPAY_API_KEY } response = requests.post(f"{SKILLPAY_API_URL}/charge", json=payload, headers=headers, timeout=10)Technical Analysis
A secret embedded in a distributed skill package cannot be considered confidential. Any user with access to the package, source repository, build artifact, logs containing the source, or documentation can recover the API key.
Although an environment variable can override the value, the hardcoded fallback means the exposed credential is used whenever
SKILLPAY_API_KEYis absent. The documentation independently discloses the same value. The key has the appearance and usage of an authentication credential, but the audit did not attempt to verify whether it remains active.Attack Path
- An attacker downloads or otherwise obtains the skill package.
- The attacker reads
handler.pyorSKILL.mdand extracts the SkillPay API key. - The attacker constructs requests to the SkillPay billing API and supplies the key through the
X-API-Keyheader. - If the key remains active, the attacker invokes any billing operations permitted by its server-side privileges.
- Requests made with the shared key ...[truncated 581 chars]
- Remediation
View remediation
Remediation Suggestions
- Revoke and rotate the exposed API key immediately.
- Remove the key from
handler.py,SKILL.md, repository history, release artifacts, examples, and cached documentation. - Require the credential to be injected through a managed secret store or protected runtime environment variable.
- Do not provide a credential fallback:
python SKILLPAY_API_KEY = os.environ.get("SKILLPAY_API_KEY") if not SKILLPAY_API_KEY: raise RuntimeError("SKILLPAY_API_KEY is required") - Use a narrowly scoped key that can access only the required billing operation.
- Add secret-scanning checks to local hooks and CI pipelines to prevent future credential commits.
- Review billing logs for unauthorized activity involving the exposed key and establish periodic key rotation.
