T09 · Insecure Skill Coding Practices
- Location
scripts/test-scrpt.js:1- Finding
Hardcoded API Credential in Source Code
- Content
View full analysis
Vulnerability Details
File Location:
scripts/test-scrpt.js, line 1
Vulnerability Type: Hardcoded secret
Risk Level: LowVulnerable Code
javascript const API_KEY = 'abc';Technical Analysis
The script embeds an API key directly in its source code instead of obtaining it from the
TEST_API_KEYenvironment variable declared inSKILL.md. Anyone who can access the source package can recover embedded credentials.The current value appears to be a test placeholder, and the script does not include it in the outbound request. Therefore, no direct credential-based compromise is demonstrated in the reviewed implementation. Nevertheless, this pattern creates a security risk if the value is replaced with a valid credential or reused elsewhere.
Attack Path
- An attacker obtains read access to the distributed Skill package or source repository.
- The attacker opens
scripts/test-scrpt.js. - The attacker extracts the credential from line 1.
- If the credential is valid for another service or later becomes active, the attacker submits it to that service's API.
- The attacker performs operations permitted by the credential's assigned privileges and rate limits.
Impact Assessment
If a valid secret were embedded here, an attacker could impersonate the credential owner and invoke any API operations authorized for that key. The scope would be limited to the key's permissions, environment, and service-side restrictions. In the current reviewed code, practical impact is low because the value is test-like and unused.
- Remediation
View remediation
Remediation Suggestions
- Remove the hardcoded
API_KEYconstant. - Read the credential from
process.env.TEST_API_KEY. - Terminate with a clear error when the required environment variable is absent.
- Add the credential only to the authorization header required by the target API.
- Never print the credential or include it in error output.
- Keep secrets out of source control and distribute them through an approved secret-management mechanism.
- Rotate the credential if
abchas ever represented a valid or reused secret. - Add automated secret scanning to the repository's development and release workflows.
A safer initialization pattern is:
javascript const API_KEY = process.env.TEST_API_KEY; if (!API_KEY) { console.error("Missing TEST_API_KEY"); process.exit(1); }- Remove the hardcoded
