T09 · Insecure Skill Coding Practices
- Location
scripts/search-gold.mjs:51- Finding
Hard-Coded Shared Tavily API Credential
- Content
View full analysis
Vulnerability Details
File Location:
scripts/search-gold.mjs, lines 51–53
Vulnerability Type: Hard-coded API secret / plaintext sensitive credential
Risk Level: HighVulnerable Code
js const DEFAULT_API_KEY = "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"; const apiKey = (process.env.TAVILY_API_KEY ?? DEFAULT_API_KEY).trim();The related documentation in
SKILL.md, lines 15–21, explicitly advertises the embedded credential as a fallback:md **Optional environment variable:** - `TAVILY_API_KEY` - Tavily API key (optional; the built-in default key is used when unset) > A default API key is built in as a fallback.Technical Analysis
A live-looking Tavily API credential is stored directly in the distributed source code and is automatically selected whenever
TAVILY_API_KEYis not configured. Secrets embedded in a Skill package cannot be kept confidential because every user or attacker with access to the package can inspect and extract them.The fallback also causes separate installations to share one credential, eliminating effective per-user isolation and attribution. No source-code exploit is required: possession of the package is sufficient to recover the token and use it independently of the Skill.
Attack Path
- An attacker downloads or otherwise obtains the Skill package.
- The attacker opens
scripts/search-gold.mjsand extracts the token assigned toDEFAULT_API_KEY. - The attacker submits arbitrary requests directly to the Tavily API using the extracted credential.
- Requests are charged against, rate-limited under, or attributed to the credential owner.
- Sustained use may consume the available quota, generate costs, trigger abuse controls, or cause the provider to revoke the credential.
- Revocation can disrupt every legitimate installation that relies on the shared fallback token.
Impact Assessment
This issue grants unauthorized use of the Tavily API privileges associated ...[truncated 657 chars]
- Remediation
View remediation
Remediation Suggestions
- Immediately revoke and rotate the exposed Tavily API credential. Removing it from the current source alone is insufficient because it may remain in distributed copies or repository history.
- Delete
DEFAULT_API_KEYand require callers to provideTAVILY_API_KEYthrough an approved secret-management mechanism. - Fail safely with a clear error when the environment variable is missing, for example:
js const apiKey = process.env.TAVILY_API_KEY?.trim(); if (!apiKey) { console.error("Error: TAVILY_API_KEY is required."); process.exit(1); }- Update
SKILL.mdand its metadata so thatTAVILY_API_KEYis documented as mandatory rather than optional. - Store deployment credentials in a secret manager or protected runtime configuration, never in source code, examples, package artifacts, logs, or documentation.
- Where supported by the provider, apply least-privilege scopes, account-level spending limits, restrictive quotas, key expiration, and usage alerts.
- Review API access logs for unauthorized activity involving the exposed token and rotate any related credentials if compromise is suspected.
- Add automated secret scanning to source-control and release pipelines to prevent future credential exposure.
