T09 · Insecure Skill Coding Practices
Error
- Location
- scripts/billing.py:17
- Finding
- Hard-Coded Billing API Credential## Vulnerability Details **File Location**: `scripts/billing.py:17` **Vulnerability Type**: Hard-coded secret in source code **Risk Level**: High ```python API_KEY = os.environ.get("SKILL_BILLING_API_KEY", "sk_91dc212149c7ee3184de119159a89a3a432455bfbfb1d87cf3f3db4b8764ab0c") ``` ### Technical Analysis The billing module contains a live-looking API key as the default value when `SKILL_BILLING_API_KEY` is absent. Anyone who can download or inspect the skill package can recover this credential. Although the source comments describe the key as charge-only, its actual server-side permissions cannot be verified from the repository. The documentation compounds the issue by directing users to configure `SKILLPAY_API_KEY`, while the implementation reads `SKILL_BILLING_API_KEY`. Consequently, a user who follows the documented setup will not override the embedded credential, and billing calls will silently use the exposed fallback. ### Attack Path 1. An attacker downloads or otherwise obtains the publicly distributed skill package. 2. The attacker inspects `scripts/billing.py` and extracts the fallback API key. 3. The attacker submits requests to the documented SkillPay billing endpoints using the recovered key in the `X-API-Key` header. 4. The requests execute with whatever permissions SkillPay assigned to that credential, potentially allowing unauthorized billing operations, publisher impersonation, or quota consumption. 5. Because legitimate installations also default to the same credential, abuse may be difficult to distinguish from expected skill traffic. ### Impact Assessment The exposed credential can be reused outside the skill without local privilege escalation. The affected scope includes the associated SkillPay publisher or skill billing identity and any operations authorized to this API key. Potential consequences include unauthorized charge requests, service or quota abuse, attribution of attacker traffic to the publi ...[truncated 224 chars]
- Remediation
- ## Remediation Suggestions 1. Immediately revoke and rotate the exposed API key through the SkillPay provider. 2. Remove the hard-coded fallback and require the credential to be supplied securely: ```python API_KEY = os.environ.get("SKILL_BILLING_API_KEY") if not API_KEY: raise RuntimeError("SKILL_BILLING_API_KEY is required") ``` 3. Correct `SKILL.md` and `README.md` so that they consistently document `SKILL_BILLING_API_KEY`. 4. Prefer keeping publisher credentials on a controlled backend. The distributed skill should call that backend using a narrowly scoped user or installation token rather than shipping a publisher credential. 5. Restrict the replacement key to only the required endpoint and skill identifier, with rate limits, expiration, rotation, and audit logging. 6. Review provider logs for unauthorized use of the exposed key and invalidate any related sessions or derived credentials. 7. Add secret scanning to CI and release checks to prevent credentials from entering future packages.
