T09 · Insecure Skill Coding Practices
Error
- Location
- handler.py:11
- Finding
- Hard-Coded SkillPay API Credential Exposed in Source and Documentation<![CDATA[ ## Vulnerability Details **File Location**: `handler.py:11` and `SKILL.md:24` **Vulnerability Type**: Hard-coded secret exposure **Risk Level**: High ### Vulnerable Code `handler.py:11`: ```python SKILLPAY_API_KEY = "sk_93c5ff38cc3e6112623d361fffcc5d1eb1b5844eac9c40043b57c0e08f91430e" ``` `SKILL.md:24`: ```markdown - API Key: sk_93c5ff38cc3e6112623d361fffcc5d1eb1b5844eac9c40043b57c0e08f91430e ``` The credential is subsequently included in both the request payload and HTTP header in `handler.py:41-48`: ```python payload = { "api_key": SKILLPAY_API_KEY, "user_id": user_id, "amount": PRICE_USDT, "skill_id": SKILL_ID, "currency": "USDT", "description": "AI prompt generation" } 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 service credential is embedded directly in executable source code and public-facing Skill documentation. Anyone who can read or obtain the project package can extract the credential without needing runtime access. If the credential remains active, its holder may be able to authenticate directly to the SkillPay API. The precise operations available depend on the server-side permissions assigned to the key. Sending the same secret in both the JSON body and the `X-API-Key` header also unnecessarily duplicates sensitive data in locations that may be captured by application, proxy, or request-body logs. ### Attack Path 1. An attacker downloads, reads, or otherwise obtains the Skill package. 2. The attacker extracts the API key from `SKILL.md` or `handler.py`. 3. The attacker constructs direct requests to the SkillPay API using the exposed key. 4. If the key is active and sufficiently privileged, the attacker performs API operations under the credential owner's identity. 5. Resulting requests may consume quotas, create unauthorized billing activity, or obsc ...[truncated 377 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Revoke and rotate the exposed API key immediately; removing it from the current files does not invalidate copies in package archives or version-control history. 2. Remove the key from both `handler.py` and `SKILL.md`. 3. Load the replacement credential from an environment variable or managed secret store. 4. Abort startup when the required secret is absent rather than using a built-in default. 5. Restrict the replacement key to the minimum required operations, account, and transaction limits. 6. Apply server-side rate limiting and monitor the account for use of the compromised credential. 7. Avoid placing credentials in request bodies when header-based authentication is supported. 8. Add secret-scanning checks to CI and pre-commit workflows. ]]>
