T09 · Insecure Skill Coding Practices
Error
- Location
- billing.py:8
- Finding
- Hardcoded SkillPay API Credential Exposed in Source Code## Vulnerability Details **File Location**: `billing.py:7-8`, with credential use at `billing.py:14`, `billing.py:30-35`, and `billing.py:59-64` **Vulnerability Type**: Hardcoded secret and reusable API credential **Risk Level**: High ### Vulnerable Code ```python BILLING_API_URL = "https://skillpay.me" BILLING_API_KEY = "sk_0c57911690182c45404f945f2908a9e2e32ed448055895ac02227856eaf226ad" SKILL_ID = "6a3b1843-5266-40c6-8f0c-408512bb6f43" ``` The credential is attached to multiple requests: ```python headers = {"X-API-Key": BILLING_API_KEY} ``` ```python headers = { "X-API-Key": BILLING_API_KEY, "Content-Type": "application/json" } ``` ### Technical Analysis A credential that appears to be a live SkillPay API key is embedded directly in the distributed Python source. Any party able to download, inspect, or execute the Skill can recover the key without authentication. The key is reused for balance queries, user charges, and payment-link creation. Although billing is part of the functionality declared in `SKILL.md`, distributing a reusable billing credential to every installation is not necessary and violates least-secret-exposure practices. The monitor should obtain a narrowly scoped credential at deployment or use a trusted server-side billing broker. Whether the exposed key permits access outside the configured Skill depends on SkillPay's server-side authorization. Client-side constants such as `SKILL_ID` do not provide a security boundary because an attacker can modify them. ### Attack Path 1. An attacker downloads or otherwise gains read access to the Skill package. 2. The attacker opens `billing.py` and extracts `BILLING_API_KEY`. 3. The attacker sends independent HTTPS requests to the documented SkillPay endpoints with the extracted key in the `X-API-Key` header. 4. The attacker attempts balance queries, payment-link generation, or charge operations for chosen user identifiers. 5. ...[truncated 707 chars]
- Remediation
- ## Remediation Suggestions 1. Revoke and rotate the exposed API key immediately; removing it from a later revision does not invalidate copies already distributed. 2. Remove all credentials from source code and repository history. 3. Load deployment secrets from a managed secret store or a protected environment variable. 4. Prefer short-lived, narrowly scoped tokens instead of a reusable account-level key. 5. Restrict the credential server-side to the required Skill, endpoints, amount limits, and expected caller identity. 6. Require independent server-side authorization for each user and charge; never treat possession of the API key alone as authorization. 7. Add rate limits, transaction limits, replay protection, audit logging, and anomaly alerts to billing operations. 8. Add automated secret scanning to development and release pipelines.
