T09 · Insecure Skill Coding Practices
Error
- Location
- index.js:12
- Finding
- Hardcoded SkillPay API Credential Exposed in Source and Configuration<![CDATA[ ## Vulnerability Details **File Location**: `index.js:12`, `api.js:12`, `config.json:15` **Vulnerability Type**: Hardcoded secret / plaintext API credential **Risk Level**: High ### Vulnerable Code `index.js:12` ```javascript const API_KEY = process.env.SKILLPAY_API_KEY || 'sk_0e14dceabeea3a6371770165736b89add613f7ab8f729c57aef555525b0f1a00'; ``` `api.js:12` ```javascript const API_KEY = process.env.SKILLPAY_API_KEY || 'sk_0e14dceabeea3a6371770165736b89add613f7ab8f729c57aef555525b0f1a00'; ``` `config.json:15` ```json "api_key": "sk_0e14dceabeea3a6371770165736b89add613f7ab8f729c57aef555525b0f1a00", ``` The credential is subsequently attached to outbound requests: ```javascript const headers = { 'X-API-Key': API_KEY, 'Content-Type': 'application/json' }; ``` ### Technical Analysis A live-format SkillPay API credential is embedded directly in two JavaScript files and the public configuration file. Supporting an environment variable does not protect the credential because the hardcoded value is automatically used whenever the environment variable is absent. Anyone who can download the package, inspect a deployment artifact, or access repository history can recover the credential without executing the skill. The same credential is used for billing requests and paid analysis requests, increasing the scope of exposure. Secret values committed to source control must be considered compromised even after they are removed from the latest revision because they may remain in package caches, published releases, forks, logs, and repository history. ### Attack Path 1. An attacker downloads or otherwise obtains the skill package. 2. The attacker opens `index.js`, `api.js`, or `config.json`. 3. The attacker extracts the plaintext SkillPay API key. 4. The attacker constructs requests containing the header: `X-API-Key: sk_0e14dceabeea3a6371770165736b89add613f7ab8f729c57aef555525b0f1a00`. 5. The attacker submits requests to the billing or paid- ...[truncated 705 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Revoke and rotate the exposed credential immediately; deleting it from the current files is not sufficient. 2. Remove the key from `index.js`, `api.js`, `config.json`, published packages, deployment artifacts, and repository history. 3. Require `SKILLPAY_API_KEY` to be injected by an approved secret manager at deployment time. 4. Fail closed when the environment variable is absent instead of using a fallback credential: ```javascript const API_KEY = process.env.SKILLPAY_API_KEY; if (!API_KEY) { throw new Error('SKILLPAY_API_KEY is required'); } ``` 5. Do not include secret values in distributable configuration files. Configuration should describe only the environment-variable name. 6. Use separate, narrowly scoped credentials for billing and analysis so compromise of one service does not expose the other. 7. Apply key restrictions where supported, including endpoint scope, rate limits, source restrictions, expiration, and monitoring. 8. Review SkillPay access logs for unauthorized requests made with the exposed key. 9. Add automated secret scanning to CI and pre-commit checks to prevent recurrence. ]]>
