T09 · Insecure Skill Coding Practices
Error
- Location
- scripts/run.js:18
- Finding
- Hard-Coded Billing API Credential<![CDATA[ ## Vulnerability Details **File Location**: `scripts/run.js:18`, with credential use at `scripts/run.js:23-27` and `scripts/run.js:34-38` **Vulnerability Type**: Hard-coded secret **Risk Level**: High ### Vulnerable Code ```javascript const BILLING_URL = process.env.SKILLPAY_BILLING_URL || 'https://skillpay.me/api/v1/billing'; const API_KEY = process.env.SKILL_BILLING_API_KEY || 'sk_74e1969ebc92fcf58257470c50f8bb76e36c9da0d201aa69861e28c62f5bd48e'; const SKILL_ID = process.env.SKILL_ID || 'ab787c89-1fe1-4ee2-b4f0-64ae89c79f8d'; const PRICE = Number(process.env.SKILLPAY_PRICE_TOKEN || '1'); async function getPaymentLink(amount = 7) { const r = await fetch(`${BILLING_URL}/payment-link`, { method: 'POST', headers: { 'content-type': 'application/json', 'x-api-key': API_KEY }, body: JSON.stringify({ user_id: userId, amount }), }).catch(() => null); } async function charge() { const r = await fetch(`${BILLING_URL}/charge`, { method: 'POST', headers: { 'content-type': 'application/json', 'x-api-key': API_KEY }, body: JSON.stringify({ user_id: userId, skill_id: SKILL_ID, amount: PRICE }), }).catch(() => null); } ``` ### Technical Analysis The source code contains a live-looking SkillPay API key as the fallback value when `SKILL_BILLING_API_KEY` is not configured. Because the Skill package is distributed to users, anyone who can read the script can recover this credential. The key is subsequently sent in the `x-api-key` header to the configured billing service. Environment-based override support does not protect the embedded fallback secret. The configurable billing URL also means the embedded credential may be transmitted to an operator-controlled endpoint if `SKILLPAY_BILLING_URL` is changed. ### Attack Path 1. An attacker downloads or otherwise reads the Skill package. 2. The attacker extracts the hard-coded `sk_...` credential from `scripts/run.js`. 3. T ...[truncated 985 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Immediately revoke and rotate the exposed API key. 2. Remove the key from the source code and repository history. 3. Require `SKILL_BILLING_API_KEY` to be supplied through a protected secret manager or deployment-time secret injection. 4. Fail closed when the credential is absent instead of using a shared fallback. 5. Restrict the key to only the billing operations required by this Skill and apply per-skill or per-deployment credentials. 6. Restrict the permitted billing host rather than allowing an arbitrary environment override to receive the credential. 7. Add server-side rate limits, transaction limits, credential rotation, and audit logging. 8. Scan release artifacts and commit history for additional copies of the exposed key. ]]>
