T09 · Insecure Skill Coding Practices
- Location
scripts/generate.py:19- Finding
Hardcoded MiniMax API Credential
- Content
View full analysis
Vulnerability Details
File Location:
scripts/generate.py:19
Vulnerability Type: Hardcoded bearer credential
Risk Level: HighVulnerable Code
python # ============ 配置 ============ API_KEY = "sk-cp-F-oQWZsbhwv06vJlTx0ZdpsYS4lj6_SexMokhjTvL5I08cwoPHb22r49qvecJjxt8Qn1LHsIRlVJn12WLJjF9GIdjOcqJqyf8jSd33YhcYb3E9XciwvlrXM" API_BASE = "https://api.minimaxi.com/v1" DEFAULT_TIMEOUT = 600 # 600秒,等待音乐生成The credential is subsequently placed into authorization headers in
scripts/generate.py:27-30andscripts/generate.py:48-51:python headers = { "Content-Type": "application/json", "Authorization": f"Bearer {API_KEY}" }Technical Analysis
A live-looking MiniMax API bearer credential is embedded directly in distributable source code. Anyone with read access to the repository, a copied Skill package, an archive, a build artifact, or source history can recover and reuse it without executing the Skill.
Sending a bearer token to the documented MiniMax endpoint is necessary for API authentication. Bundling a shared credential in the Skill is not necessary, however, and violates secret-management and least-privilege principles. Bearer credentials generally grant access based on possession alone, so source-code exposure is sufficient for unauthorized use.
The key must be treated as compromised. Merely deleting it from the current file would not remove it from existing copies or version-control history.
Attack Path
- An attacker downloads, clones, or otherwise obtains read access to the Skill.
- The attacker inspects
scripts/generate.pyand extracts the credential from line 19. - The attacker constructs requests with:
http Authorization: Bearer [extracted credential] - The attacker submits requests directly to the MiniMax APIs independently of the Skill.
- Requests consume the credential owner's available quota or account funds until the key is revoked, restricted, or exhausted.
No local code exe ...[truncated 844 chars]
- Remediation
View remediation
Remediation Suggestions
-
Revoke and rotate the exposed credential immediately. Assume that it has already been copied. Review API usage records for unexpected requests, quota consumption, or charges.
-
Remove the credential from source code and version-control history. Purge it from prior commits and distributed artifacts where feasible. Rotation remains mandatory because history rewriting cannot invalidate existing copies.
-
Load credentials from a protected runtime source, such as an environment variable or secret manager:
python import os API_KEY = os.environ.get("MINIMAX_API_KEY") if not API_KEY: raise RuntimeError( "MINIMAX_API_KEY is required. Configure it through the environment." ) -
Require each user to supply their own credential. Do not distribute a shared project-owned bearer token.
-
Apply provider-side restrictions where supported, including minimum API/model scope, spending limits, rate limits, expiration, and usage alerts.
-
Prevent recurrence by enabling pre-commit and continuous-integration secret scanning, defining credential patterns, and blocking commits that contain API keys.
-
Avoid logging credentials or complete authorization headers. Ensure exceptions, debug output, and HTTP tracing redact bearer tokens.
-
