T09 · Insecure Skill Coding Practices
Error
- Location
- scripts/run.js:17
- Finding
- Hard-Coded Billing API Credential Exposed in Source Code<![CDATA[ ## Vulnerability Details **File Location**: `scripts/run.js:17` **Vulnerability Type**: Hard-coded secret **Risk Level**: High ### Vulnerable Code ```javascript const API_KEY = process.env.SKILL_BILLING_API_KEY || 'sk_74e1969ebc92fcf58257470c50f8bb76e36c9da0d201aa69861e28c62f5bd48e'; ``` The credential is subsequently attached to billing requests: ```javascript headers: { 'content-type': 'application/json', 'x-api-key': API_KEY }, ``` ### Technical Analysis The script contains a live-looking billing API key as its default configuration. Anyone with access to the Skill package can extract this value without executing the code. Environment-variable support does not protect the embedded fallback. If `SKILL_BILLING_API_KEY` is absent, every installation uses the same credential. This prevents reliable attribution and exposes the credential to source repositories, package archives, logs, backups, and all users who receive the Skill. The precise capabilities of the credential cannot be established from the reviewed files. Nevertheless, it is explicitly accepted by the external billing API as an authentication credential and must therefore be treated as sensitive. ### Attack Path 1. An attacker obtains or downloads the Skill package. 2. The attacker opens `scripts/run.js` and extracts the `sk_...` credential. 3. The attacker identifies the billing endpoint from the adjacent `BILLING_URL` declaration. 4. The attacker sends independent requests with the recovered value in the `x-api-key` header. 5. Any operations permitted to the shared credential can then be invoked outside the intended Skill workflow. ### Impact Assessment Successful exploitation may permit unauthorized use of the billing API, fraudulent or malformed billing operations, consumption of service quota, and loss of request attribution. The exact scope is limited to the server-side permissions assigned to the exposed key; broader administrative privileges were not demonstrated during t ...[truncated 21 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Revoke and rotate the exposed credential immediately. 2. Remove the hard-coded fallback and require the credential to be provided through an approved secret manager or protected environment variable. 3. Fail closed with a clear configuration error when the credential is unavailable. 4. Issue narrowly scoped credentials that authorize only the required billing operations. 5. Prefer short-lived, installation-specific credentials rather than a shared static key. 6. Add secret scanning to source-control and release pipelines. 7. Review billing-service logs for unauthorized use of the exposed credential. 8. Enforce server-side authorization, rate limits, idempotency controls, and user-to-charge binding so possession of an API key alone is insufficient to perform arbitrary billing actions. ]]>
