T09 · Insecure Skill Coding Practices
- Location
index.js:13- Finding
Hard-Coded Billing API Credential Exposed in Source Code
- Content
View full analysis
Vulnerability Details
File Location:
index.js:13-17
Vulnerability Type: Hard-coded secret / exposed API credential
Risk Level: MediumVulnerable 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_4312778b58aa7c81c15bd0e2b4fe544e12ca9e765f0deab630a50ecd4daf4ac2Technical 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-Keyheader 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
- Obtain the published project or inspect its documentation.
- Extract the plaintext API key from
index.jsorSKILL.md. - Construct requests to the SkillPay billing API with the exposed value in the
X-API-Keyheader. - Attempt operations permitted to that credential, including forged charge requests using attacker-selected user identifiers or skill identifiers.
- Repeat requests to consume quota, ma ...[truncated 692 chars]
- Remediation
View remediation
Remediation Suggestions
- Revoke and rotate the exposed API key immediately.
- Remove the credential from
index.js,SKILL.md, package artifacts, examples, logs, and version-control history. - Load the credential at runtime from a protected secret manager or environment variable, and fail securely when it is unavailable.
- Do not distribute a shared privileged credential to skill consumers. Prefer narrowly scoped, short-lived, per-installation credentials.
- Restrict the replacement credential to the minimum required billing operation and skill identity.
- Enforce server-side authorization so callers cannot select arbitrary users, amounts, or skill identifiers merely by possessing an API key.
- Add request signing, timestamps, nonces, replay protection, rate limits, and anomaly monitoring for billing operations.
- Review billing logs for use of the disclosed credential and investigate unexpected requests.
- Add automated secret scanning to source-control and release pipelines to prevent recurrence.
