T09 · Insecure Skill Coding Practices
- Location
scripts/ocr.py:172- Finding
Configurable API Endpoint Enables Disclosure of API Credentials and OCR Image Data
- Content
View full analysis
Vulnerability Details
File Location:
scripts/ocr.py:172-173, 229-230, 271-276, 285-290
Vulnerability Type: Unrestricted transmission of credentials and sensitive image data to a configurable endpoint
Risk Level: MediumVulnerable Code
python self.api_key = self.config.get("apiKey", "").strip() self.base_url = self.config.get("baseUrl", "https://api.siliconflow.cn/v1")python headers = { "Authorization": f"Bearer {self.api_key}", "Content-Type": "application/json" }python payload["messages"] = [ { "role": "user", "content": [ { "type": "image_url", "image_url": {"url": f"data:image/png;base64,{image_data}"} }, { "type": "text", "text": ocr_prompt } ] } ]python response = requests.post( f"{self.base_url}/chat/completions", headers=headers, json=payload, timeout=60 )Technical Analysis
The API endpoint is read directly from
config.jsonwithout validating its scheme or hostname. The same request sends the SiliconFlow API key in theAuthorizationheader and the OCR input image in the JSON body.For local images, base64 encoding is a normal transport mechanism required by the declared cloud OCR workflow. It is not encryption and does not protect the image from the request recipient. The encoding behavior is not, by itself, evidence of a covert exfiltration channel. The security issue is that the encoded image and bearer credential can be transmitted to any endpoint selected through
baseUrl.An attacker who can modify the skill configuration could set
baseUrlto an attacker-controlled HTTPS server. The implementation would then treat that server as trusted and disclose both the API key and the processed document. Although configuration modification ...[truncated 1503 chars]- Remediation
View remediation
Remediation Suggestions
- Remove
baseUrlconfigurability if only SiliconFlow is supported, and hardcode the reviewed HTTPS endpoint. - If custom endpoints are a required feature, validate the URL before sending any request:
- Require the
httpsscheme. - Use an explicit hostname allowlist.
- Reject embedded credentials, unexpected ports, IP literals, and deceptive subdomains.
- Normalize and parse the URL with a standard URL parser before comparison.
- Require the
- Never attach the SiliconFlow API key when the destination origin differs from the trusted SiliconFlow origin.
- Separate credentials by provider or endpoint instead of reusing one bearer token for arbitrary destinations.
- Protect
config.jsonwith restrictive file permissions and document that it contains a secret. - Warn users clearly that cloud OCR uploads image contents to a third-party service.
- Add automated tests confirming that untrusted schemes and hosts are rejected before request construction.
- Consider obtaining the API key from a protected secret store or environment variable rather than a project-local JSON file.
- Remove
