T09 · Insecure Skill Coding Practices
- Location
scripts/search.py:13- Finding
Unrestricted Endpoint Overrides Can Expose the Baidu Bearer Credential and Search Queries
- Content
View full analysis
Vulnerability Details
File Location:
scripts/search.py, lines 13–19, 78–87, 102–112, and 126–129
Vulnerability Type: Unvalidated credential-bearing network destination
Risk Level: HighVulnerable Code
python def _post_json(url, api_key, request_body): headers = { "Authorization": f"Bearer {api_key}", "X-Appbuilder-From": "openclaw", "Content-Type": "application/json", } resp = requests.post(url, json=request_body, headers=headers, timeout=30)python def _search_chain_urls(): # Baidu updates may cause chat and web_search to return equivalent references. # Prefer web_search and retain chat as a compatibility fallback. web_url = os.getenv("BAIDU_WEB_SEARCH_ENDPOINT", DEFAULT_WEB_SEARCH_URL) chat_url = os.getenv("BAIDU_CHAT_SEARCH_ENDPOINT", DEFAULT_CHAT_URL) urls = [("web_search", web_url)] if chat_url and chat_url != web_url: urls.append(("chat", chat_url)) return urlspython def _run_summary_last_chain(api_key, request_body): summary_url = os.getenv("BAIDU_SUMMARY_ENDPOINT", DEFAULT_SUMMARY_URL) errors = [] try: return _run_search_chain(api_key, request_body) except Exception as e: errors.append(str(e)) try: return _run_endpoint(summary_url, api_key, request_body, "web_summary")python if mode == "summary": summary_url = os.getenv("BAIDU_SUMMARY_ENDPOINT", DEFAULT_SUMMARY_URL) return _run_endpoint(summary_url, api_key, request_body, "web_summary")Technical Analysis
The Skill obtains endpoint URLs from
BAIDU_WEB_SEARCH_ENDPOINT,BAIDU_CHAT_SEARCH_ENDPOINT, andBAIDU_SUMMARY_ENDPOINTwithout validating their scheme, hostname, port, or trust boundary._post_jsonthen attaches theBAIDU_API_KEYas an HTTP Bearer credential to whichever URL was selected.Consequently, a configured endpoin ...[truncated 2284 chars]
- Remediation
View remediation
Remediation Suggestions
-
Prefer fixed service endpoints. Remove endpoint overrides if they are not essential to the Skill's declared functionality.
-
Enforce HTTPS and an explicit hostname allowlist. Before attaching the credential, parse the URL and require:
- The
httpsscheme. - An approved Baidu hostname, such as the exact expected
qianfan.baidubce.comhost. - No embedded username or password.
- No unexpected port.
- No IP-literal destination.
- An expected API path or a narrowly defined path prefix.
- The
-
Bind credentials to trusted destinations. Never attach
Authorizationwhen the validated destination is outside the approved Baidu trust boundary. -
Control redirects. Disable automatic redirects with
allow_redirects=False, or validate every redirect destination before resending a request. Ensure authorization headers cannot be forwarded to an unapproved host. -
Fail closed. Reject invalid endpoint settings with a clear configuration error rather than silently using or contacting an arbitrary destination.
-
Separate development overrides. If custom endpoints are required for testing, require an explicit development-only switch and a separate non-production credential. Do not enable arbitrary overrides in normal operation.
-
Protect query confidentiality. Avoid printing complete parsed requests by default because user queries may contain sensitive information. Use opt-in debug logging with appropriate redaction.
-
