T05 · Unauthorized Access and Privilege Escalation
Warning
- Location
- scripts/generate.py:29
- Finding
- Mandatory Access to an Unused Tavily API Credential<![CDATA[ ## Vulnerability Details **File Location**: `scripts/generate.py`, lines 29-45 **Vulnerability Type**: Unnecessary access to a sensitive credential **Risk Level**: Medium ### Vulnerable Code ```python # 配置 - 从环境变量读取 POLLINATIONS_API_KEY = os.environ.get("POLLINATIONS_API_KEY") TAVILY_API_KEY = os.environ.get("TAVILY_API_KEY") # 验证 API Key 是否存在 if not POLLINATIONS_API_KEY: print("❌ 错误:未找到 POLLINATIONS_API_KEY 环境变量") print("请配置:export POLLINATIONS_API_KEY=\"your-api-key\"") print("或在 ~/.zshrc 中添加后运行:source ~/.zshrc") sys.exit(1) if not TAVILY_API_KEY: print("❌ 错误:未找到 TAVILY_API_KEY 环境变量") print("请配置:export TAVILY_API_KEY=\"your-api-key\"") print("或在 ~/.zshrc 中添加后运行:source ~/.zshrc") sys.exit(1) ``` The actual search implementation uses the Jina Reader service rather than Tavily: ```python baidu_url = f"https://baike.baidu.com/item/{urllib.parse.quote(theme)}" jina_url = f"https://r.jina.ai/{baidu_url}" ``` ### Technical Analysis The program reads `TAVILY_API_KEY` and refuses to operate unless the credential is available. However, no code in the project sends a request to Tavily or otherwise uses this value. Requiring an unrelated secret violates least-privilege principles. It unnecessarily expands the sensitive environment data available to the process and contradicts the documented architecture, which states that Tavily performs the search. The reviewed code does not transmit or print the Tavily key, so direct exfiltration was not identified. The security issue is the unnecessary credential-access requirement itself. ### Attack Path 1. A user follows the installation instructions and places a valid Tavily key in the environment. 2. The Skill process starts and reads that key into process memory. 3. The process does not use Tavily; searches are instead sent through `r.jina.ai`. 4. Any future compromise, unsafe diagnostic addition, imported-code flaw, or process-memory disclosure would expose a credential that t ...[truncated 361 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Remove `TAVILY_API_KEY` from `scripts/generate.py` unless the application actually uses Tavily. 2. Remove the corresponding requirement from `SKILL.md`, `README.md`, `INTRO.md`, `skill.yaml`, and `package.json`. 3. If Tavily integration is implemented later, load the credential only immediately before the request that requires it. 4. Use a narrowly scoped and revocable API key with the lowest available quota and permissions. 5. Document the actual search provider, currently `r.jina.ai`, so users can make an informed decision about transmitting search topics. 6. Add tests that verify the program starts without credentials for services it does not call. ]]>
