T09 · Insecure Skill Coding Practices
- Location
src/baidu_search/main.py:44- Finding
Unauthenticated Search Proxy Can Expose the Operator's Baidu API Quota
- Content
View full analysis
SearchResponse: """ 搜索网页 - **query**: 搜索关键词 - **top_k**: 返回结果数量 (1-20, 默认 10) - **recency_filter**: 时间过滤 (day, week, month, year) - **site_filter**: 限定搜索的网站列表 """ return search(request) if __name__ == "__main__": import uvicorn uvicorn.run("baidu_search.main:app", host="0.0.0.0", port=8001) ``` ### Technical Analysis The `/search` endpoint has no authentication, authorization, rate limiting, or usage controls. When the module is executed directly, Uvicorn binds to `0.0.0.0`, making the endpoint reachable through every available network interface unless external firewall rules prevent access. Every accepted request is forwarded to Baidu using the server-side `BAIDU_API_KEY`. Consequently, any client able to reach the service can consume the operator's Baidu API quota without possessing the key. This creates a confused-deputy condition in which the application exercises the operator's provider privileges on behalf of arbitrary callers. Although the documented startup command binds to `127.0.0.1`, the direct-execution configuration is independently unsafe and can result in accidental network exposure. ### Attack Path 1. An operator launches the application directly with `python -m baidu_search.main` or otherwise executes `main.py`. 2. The application listens on `0.0.0.0:8001`. 3. An attacker discovers the reachable service through network scanning or deployment metadata. 4. The attacker repeatedly sends valid POST requests to `/search`. 5. The service authenticates each upstream request with the operator's `BAIDU_API_KEY`. 6. The attacker consumes the operator's quota, incurs provider costs, or exhausts service capa ...[truncated 445 chars]- Remediation
View remediation
