T09 · Insecure Skill Coding Practices
- Location
radar.py:18- Finding
Hard-Coded LLM API Credential Embedded in Source Code
- Content
View full analysis
str: url = "http://127.0.0.1:18790/anthropic/v1/messages" headers = { "Content-Type": "application/json", "x-api-key": "sk-RPBUoe2SH7KigJ0SZn6IPDirZtJ2fUaWSukEx1FwxjhWFx0G", "anthropic-version": "2023-06-01", } ``` The same credential is embedded in `_write_radar.py:67-70`: ```python TIMEOUT = 8 LLM_URL = "http://127.0.0.1:18790/anthropic/v1/messages" LLM_API_KEY = "sk-RPBUoe2SH7KigJ0SZn6IPDirZtJ2fUaWSukEx1FwxjhWFx0G" LLM_MODEL = "ppio/pa/claude-sonnet-4-6" ``` It is then transmitted in `_write_radar.py:94-106`: ```python def llm_call(prompt, system="你是龙虾公司的信息分析助理", max_tokens=300): headers = { "Content-Type": "application/json", "x-api-key": LLM_API_KEY, "anthropic-version": "2023-06-01", } data = json.dumps({ "model": LLM_MODEL, "max_tokens": max_tokens, "system": system, "messages": [{"role": "user", "content": prompt}] }).encode() req = urllib.request.Request(LLM_URL, data=data, headers=headers, method="POST") try: with urllib.request.urlopen(req, timeout=30) as resp: return json.loads(resp.read())["content"][0]["text"] ``` ### Technical Analysis An API credential is committed directly into two source files. Any person or process able to read the Skill package, source repository, archive, logs containing source code, or repository history can recover the key. Embedding the key is not necessary for the declared competitor-monitoring functionality. The Skill can retrieve public data without this credential, and optional AI scoring should obtain its credential from a protected runtime secret source. ...[truncated 1682 chars]- Remediation
View remediation
