T09 · Insecure Skill Coding Practices
- Location
scripts/claude_polish.py:42- Finding
Anthropic API Credential Disclosure Through a Configurable Request Origin
- Content
View full analysis
Dict: """Call the Anthropic Messages API with prompt caching enabled.""" api_key = os.environ.get("ANTHROPIC_API_KEY") if not api_key: raise RuntimeError( "Missing ANTHROPIC_API_KEY environment variable.\n" " • macOS/Linux: export ANTHROPIC_API_KEY=sk-ant-...\n" " • Or add it to ~/.zshrc / ~/.bashrc" ) body = { "model": model, "max_tokens": max_tokens, "temperature": temperature, "system": [ { "type": "text", "text": build_system_prompt(), "cache_control": {"type": "ephemeral"}, } ], "messages": [ { "role": "user", "content": f"{prompt}\n\nPlease output JSON.", }, { "role": "assistant", "content": "{", }, ], } req = Request( f"{ANTHROPIC_BASE}/v1/messages", data=json.dumps(body).encode("utf-8"), headers={ "Content-Type": "application/json", "x-api-key": api_key, "anthropic-version": ANTHROPIC_VERSION, }, method="POST", ) ``` ### Technical Analysis The `ANTHROPIC_BASE_URL` environment variable controls the complete destination origin, while the code unconditionally attaches the value of `ANTHROPIC_API_KEY` as an `x-api-key ...[truncated 1881 chars]- Remediation
View remediation
