T09 · Insecure Skill Coding Practices
- Location
test_minimax.py:5- Finding
Hardcoded MiniMax API Credential in Executable Test Script
- Content
View full analysis
' url = 'https://api.minimax.chat/v1/text/chatcompletion_v2' headers = { 'Authorization': 'Bearer ' + api_key, 'Content-Type': 'application/json' } payload = { 'model': 'MiniMax-M2.5', 'messages': [ {'role': 'system', 'content': '你是一个新闻搜索助手。请搜索并返回结构化结果。'}, {'role': 'user', 'content': '搜索关于"人工智能"的最新新闻,返回 JSON 格式:标题、URL、摘要、来源'} ], 'tools': [{'type': 'web_search'}], 'temperature': 0.3 } response = requests.post(url, headers=headers, json=payload, timeout=30) ``` The credential value is redacted from this report to avoid further disclosure. The audited file contains the complete plaintext value. ### Technical Analysis An API credential is embedded directly in an executable Python file. Anyone with access to the project archive, source repository, package cache, build artifacts, or source history can recover it without running the program. The script transmits the credential as a bearer token when executed. Although transmission is directed to an HTTPS MiniMax endpoint, embedding the credential in source code violates secret-management boundaries and makes access control dependent on the confidentiality of the entire source tree. ### Attack Path 1. An attacker obtains a copy of the Skill package or repository. 2. The attacker opens `test_minimax.py` and extracts the plaintext API key. 3. The attacker sends authenticated requests to the MiniMax API using that key. 4. Requests consume the victim's quota and may incur charges or access data and capabilities associated with the credential. 5. If the credential was committed to version control, deleting it from the current file does not remove it from repository history. ### Impact Assessment An attacker can impe ...[truncated 505 chars]- Remediation
View remediation
