T09 · Insecure Skill Coding Practices
- Location
scripts/baidu_api.py:48- Finding
Baidu API credentials are transmitted in URL query parameters
- Content
View full analysis
Vulnerability Details
File Location:
scripts/baidu_api.py, lines 48–54
Vulnerability Type: Sensitive credential exposure through request URLs
Risk Level: MediumVulnerable Code
python params = { "grant_type": "client_credentials", "client_id": self.api_key, "client_secret": self.secret_key } try: response = requests.post(TOKEN_URL, params=params, timeout=10)Technical Analysis
The
requests.postcall supplies the API key and secret through theparamsargument. This causes both credentials to appear in the request URL query string rather than exclusively in the request body or an authorization header.Although the destination is the declared official Baidu HTTPS endpoint, request URLs can be retained by HTTP debugging systems, reverse proxies, endpoint monitoring software, server access logs, exception-reporting services, and network observability platforms. TLS protects the request in transit but does not prevent URL logging at either endpoint.
The application also converts request exceptions to strings and ultimately prints them. Depending on the exception generated by the HTTP library, this could further expose a request URL containing the credentials.
Attack Path
- A user configures
baidu_api_keyandbaidu_secret_keyin~/.openclaw/config.json. - The
BaiduApiconstructor calls_get_access_token(). - The API key and secret are added to the OAuth request URL as query parameters.
- A proxy, monitoring agent, HTTP debugger, server log, or exception collector records the full URL.
- An attacker with access to those records extracts the credentials.
- The attacker uses the credentials to request access tokens and consume services under the victim's Baidu account.
Impact Assessment
Successful exploitation can disclose the Baidu API key and secret key. An attacker may then impersonate the configured client, consume paid API capacity ...[truncated 187 chars]
- A user configures
- Remediation
View remediation
Remediation Suggestions
- Use an OAuth request body or authorization header supported by the Baidu API instead of URL query parameters.
- If the service mandates query parameters, explicitly disable request URL logging and redact
client_id,client_secret, andaccess_tokenfrom diagnostics. - Do not expose raw
requestsexception strings to standard output. Return a generic error and retain only sanitized diagnostic information. - Implement centralized secret-redaction logic for URLs, request metadata, and error messages.
- Store credentials in a dedicated secret manager or protected environment variables rather than a general configuration file.
- Ensure
~/.openclaw/config.jsonhas restrictive filesystem permissions and document credential rotation procedures. - Rotate the existing API credentials if request URLs may already have been logged.
