T09 · Insecure Skill Coding Practices
Warning
- Location
- index.js:13
- Finding
- Hard-Coded Billing API Credential Exposed in Source Code## Vulnerability Details **File Location**: `index.js:13-17` **Vulnerability Type**: Hard-coded secret / exposed API credential **Risk Level**: Medium ### Vulnerable Code ```js // SkillPay Configuration const BILLING_URL = 'https://skillpay.me/api/v1/billing'; const API_KEY = 'sk_4312778b58aa7c81c15bd0e2b4fe544e12ca9e765f0deab630a50ecd4daf4ac2'; const SKILL_ID = '1481cef0-2cd0-4768-83d9-a51c57a46180'; const headers = { 'X-API-Key': API_KEY, 'Content-Type': 'application/json' }; ``` The same credential is additionally disclosed in `SKILL.md:23-26`: ```markdown ## Integration - Billing: SkillPay.me - API Key: sk_4312778b58aa7c81c15bd0e2b4fe544e12ca9e765f0deab630a50ecd4daf4ac2 ``` ### Technical Analysis A reusable billing API credential is stored in plaintext in executable source code and duplicated in project documentation. Any party that can download, inspect, or redistribute the package can recover the credential without needing runtime access. The code uses this shared secret as the `X-API-Key` header when submitting billing requests: ```js const { data } = await axios.post(BILLING_URL + '/charge', { user_id: userId, skill_id: SKILL_ID, amount: 1, }, { headers }); ``` If the remote service treats possession of this key as sufficient authorization, an attacker can reproduce requests independently of the skill. The exact operations and privileges available to the key depend on server-side controls and cannot be established from the audited repository alone. ### Attack Path 1. Obtain the published project or inspect its documentation. 2. Extract the plaintext API key from `index.js` or `SKILL.md`. 3. Construct requests to the SkillPay billing API with the exposed value in the `X-API-Key` header. 4. Attempt operations permitted to that credential, including forged charge requests using attacker-selected user identifiers or skill identifiers. 5. Repeat requests to consume quota, ma ...[truncated 692 chars]
- Remediation
- ## Remediation Suggestions 1. Revoke and rotate the exposed API key immediately. 2. Remove the credential from `index.js`, `SKILL.md`, package artifacts, examples, logs, and version-control history. 3. Load the credential at runtime from a protected secret manager or environment variable, and fail securely when it is unavailable. 4. Do not distribute a shared privileged credential to skill consumers. Prefer narrowly scoped, short-lived, per-installation credentials. 5. Restrict the replacement credential to the minimum required billing operation and skill identity. 6. Enforce server-side authorization so callers cannot select arbitrary users, amounts, or skill identifiers merely by possessing an API key. 7. Add request signing, timestamps, nonces, replay protection, rate limits, and anomaly monitoring for billing operations. 8. Review billing logs for use of the disclosed credential and investigate unexpected requests. 9. Add automated secret scanning to source-control and release pipelines to prevent recurrence.
