T09 · Insecure Skill Coding Practices
Warning
- Location
- scripts/billing.py:16
- Finding
- Hardcoded SkillPay API Credential Exposed in Source Code## Vulnerability Details **File Location**: `scripts/billing.py:16-19` **Vulnerability Type**: Hardcoded API credential **Risk Level**: Medium ### Vulnerable Code ```python BILLING_URL = "https://skillpay.me/api/v1/billing" API_KEY = os.environ.get("SKILL_BILLING_API_KEY", "sk_91dc212149c7ee3184de119159a89a3a432455bfbfb1d87cf3f3db4b8764ab0c") SKILL_ID = os.environ.get("SKILL_ID", "paythefly") HEADERS = {"X-API-Key": API_KEY, "Content-Type": "application/json"} ``` ### Technical Analysis A live-looking SkillPay API key is embedded directly in the distributed source code and used whenever `SKILL_BILLING_API_KEY` is absent. Environment-variable support does not protect the fallback credential because every person with access to the package can extract it. The credential is placed in the `X-API-Key` request header and used for billing API operations. The source comment describes it as a publisher-side, charge-only credential, so the exposed privilege appears limited to the permissions assigned by SkillPay rather than fund withdrawal. Nevertheless, it must be treated as compromised because its actual server-side permissions cannot be verified from the repository. ### Attack Path 1. An attacker downloads or otherwise obtains the publicly distributed skill. 2. The attacker opens `scripts/billing.py` and extracts the hardcoded `sk_...` credential. 3. The attacker constructs direct HTTPS requests to the SkillPay billing API using the credential in the `X-API-Key` header. 4. The requests are processed under the publisher credential's identity and permissions. 5. The attacker can continue using the credential until it is revoked or rotated. ### Impact Assessment An attacker can impersonate the skill's publisher when accessing API operations authorized for this key. Depending on the server-side permission model, this may enable unauthorized billing requests, fabricated or abusive charge activity, quota consumption, and corr ...[truncated 329 chars]
- Remediation
- ## Remediation Suggestions 1. Immediately revoke and rotate the exposed SkillPay API key. 2. Remove the hardcoded fallback and require the credential to be supplied through a protected runtime secret: ```python API_KEY = os.environ.get("SKILL_BILLING_API_KEY") if not API_KEY: raise RuntimeError("SKILL_BILLING_API_KEY is required") ``` 3. Store the replacement credential in a managed secrets service or the hosting platform's protected secret configuration. 4. Apply least privilege to the replacement key, restricting it to only the billing operation required by this skill. 5. Add secret scanning to pre-commit and CI pipelines to prevent future credential commits. 6. Review SkillPay logs for use of the exposed key and investigate anomalous requests. 7. If supported by SkillPay, add request-origin restrictions, short-lived credentials, key expiration, and per-key rate limits.
