T09 · Insecure Skill Coding Practices
- Location
scripts/llm_benchmark.py:28- Finding
API credentials and sample contents can be transmitted to an arbitrary endpoint
- Content
View full analysis
dict[str, Any]: """调用单个模型""" if not API_KEY: return {"status": "error", "time": 0, "error": "未设置 DASHSCOPE_API_KEY 环境变量"} start = time.time() try: resp = requests.post( API_BASE, headers={ "Authorization": f"Bearer {API_KEY}", "Content-Type": "application/json", }, json={ "model": model, "messages": [{"role": "user", "content": prompt}], "temperature": 0.3, "response_format": {"type": "json_object"}, }, timeout=timeout, ) ``` ### Technical Analysis Sending prompts to a remote model provider is necessary for the declared benchmarking functionality. The security issue is that `LLM_API_BASE` may specify any URL while the program always attaches the `DASHSCOPE_API_KEY` bearer credential and the complete generated prompt. The destination is not restricted to the documented DashScope service, and the code does not require HTTPS. Consequently, a malicious or mistakenly configured environment can redirect requests to an attacker-controlled server or a plaintext HTTP endpoint. The transmitted prompt contains the prompt template and up to 2,000 characters from each sample file. These files may contain proprietary text, source code, personal data, or other confidential benchmark material. The program provides no destination confirmation, sensitivity warning, or redaction mechani ...[truncated 1634 chars]- Remediation
View remediation
