T09 · Insecure Skill Coding Practices
- Location
scripts/test_citations.py:8- Finding
Hard-Coded Perplexity API Credential
- Content
View full analysis
Vulnerability Details
File Location:
scripts/test_citations.py:8-11
Vulnerability Type: Plaintext hard-coded secret
Risk Level: HighVulnerable Code
python # Set API credentials if not os.environ.get("OPENAI_API_KEY"): print("Warning: OPENAI_API_KEY not set"); os.environ["OPENAI_BASE_URL"] = "https://open.bigmodel.cn/api/coding/paas/v4" os.environ["PERPLEXITY_API_KEY"] = "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"Technical Analysis
The citation script contains a plaintext Perplexity API credential and places it in the process environment. Anyone who can access the source package or its repository history can extract the credential without authorization.
When the script imports and invokes Denario, the dependency may use
PERPLEXITY_API_KEYfor citation searches. This exposes the credential to code running in the same process and makes citation requests occur under a bundled credential rather than one explicitly supplied by the operator.Attack Path
- An attacker obtains a copy of the publicly or internally distributed skill package.
- The attacker reads
scripts/test_citations.py. - The attacker extracts the value assigned to
PERPLEXITY_API_KEY. - If the credential remains active, the attacker submits requests to the associated API outside the skill.
- Those requests consume the credential owner's quota and may incur charges or disrupt legitimate use.
Impact Assessment
Exploitation does not grant host operating-system privileges, but it may grant whatever API permissions and quota are associated with the exposed credential. Potential consequences include unauthorized API consumption, billing abuse, quota exhaustion, loss of attribution, and disruption of legitimate citation operations. The scope is limited by the provider-side permissions and usage limits assigned to the key.
- Remediation
View remediation
Remediation Suggestions
- Revoke and rotate the exposed credential immediately.
- Remove the credential from the current source tree, package releases, commit history, build artifacts, and logs.
- Obtain the credential from a secret manager or environment variable instead:
python perplexity_api_key = os.environ.get("PERPLEXITY_API_KEY") if not perplexity_api_key: raise RuntimeError("PERPLEXITY_API_KEY is required for citation generation") - Do not assign a secret literal in source code or provide a fallback credential.
- Add secret-scanning checks to pre-commit and CI workflows.
- Apply provider-side least privilege, spending limits, rate limits, expiration, and monitoring to the replacement key.
- Document that users must supply their own credential through an approved secret-management mechanism.
