T09 · Insecure Skill Coding Practices
- Location
scripts/common/ocr_client.py:158- Finding
Cross-Origin Redirect May Disclose the API Key and User Image
- Content
View full analysis
Vulnerability Details
File Location:
scripts/common/ocr_client.py, lines 158-180
Vulnerability Type: Sensitive data exposure through unrestricted HTTP redirects
Risk Level: MediumVulnerable Code:
python def _build_request_param(self, image_url: str = None, base64_data: str = None) -> Dict[str, Any]: """构建请求参数""" param = { "aiApiKey": self.api_key, "dataType": self.data_type, "scene": self.scene } if base64_data: param["dataBase64"] = base64_data else: param["dataUrl"] = image_url return param def _send_request(self, param: Dict[str, Any]) -> requests.Response: """发送 HTTP 请求到 OCR API""" headers = {"Content-Type": "application/json", "X-Appbuilder-From": "openclaw"} response = self.session.post( API_URL, json=param, headers=headers, timeout=REQUEST_TIMEOUT, allow_redirects=True ) return responseTechnical Analysis
The request body contains both the
SCAN_WEBSERVICE_KEYcredential and either the image Base64 content or its URL. Redirect following is enabled without validating the redirect destination.An HTTP
307 Temporary Redirector308 Permanent Redirectcan preserve the original HTTP method and request body. Consequently, if the configured OCR endpoint is compromised, misconfigured, or manipulated into returning a cross-origin redirect, therequestsclient may retransmit the API key and image payload to the redirected host.Encoding the image as Base64 is itself necessary for the documented OCR API and is not evidence of covert exfiltration. The vulnerability arises from combining sensitive request-body data with unrestricted redirect handling.
Attack Path
- A user invokes the Skill with a private image.
- The client creates a JSON request containing the image and
SCAN_WEBSERVICE_KEY. - The request is sent t ...[truncated 861 chars]
- Remediation
View remediation
Remediation Suggestions
- Disable automatic redirects by setting
allow_redirects=False. - If redirects are operationally required, process each redirect manually.
- Require every redirect destination to use HTTPS.
- Enforce an exact hostname allowlist before retransmitting the request body.
- Reject cross-origin redirects and downgrade redirects from HTTPS to HTTP.
- Prefer transmitting the API key in a dedicated authorization header rather than placing it in the JSON body.
- Add tests covering 301, 302, 303, 307, and 308 responses, including cross-origin destinations.
- Disable automatic redirects by setting
