T09 · Insecure Skill Coding Practices
- Location
scripts/paddleocr_parse.py:30- Finding
Unrestricted OCR endpoints can receive sensitive documents and API credentials
- Content
View full analysis
Vulnerability Details
File Location:
scripts/paddleocr_parse.py:30-61,scripts/paddleocr_parse.py:69-105, andscripts/paddleocr_parse.sh:221-225
Vulnerability Type: Unvalidated sensitive-data transmission destination
Risk Level: HighVulnerable Code
python def sync_parse(file_path: str, file_type: int, api_url: str, token: str, verbose: bool = False) -> dict: """Synchronous document parsing.""" if file_path.startswith("http"): # URL mode payload = { "file": file_path, "fileType": file_type, "useDocOrientationClassify": False, "useDocUnwarping": False, } else: # Local file mode path = Path(file_path) if not path.exists(): print(f"Error: File not found: {file_path}", file=sys.stderr) sys.exit(1) file_bytes = path.read_bytes() file_data = base64.b64encode(file_bytes).decode("ascii") payload = { "file": file_data, "fileType": file_type, "useDocOrientationClassify": False, "useDocUnwarping": False, } headers = { "Authorization": f"token {token}", "Content-Type": "application/json" } if verbose: print(f"Making sync request to: {api_url}", file=sys.stderr) response = requests.post(api_url, json=payload, headers=headers, timeout=600)python if file_path.startswith("http"): # URL Mode headers["Content-Type"] = "application/json" payload = { "fileUrl": file_path, "model": model, "optionalPayload": optional_payload } job_response = requests.post(job_url, json=payload, headers=headers) else: # Local File Mode path = Path(file_path) if not path.exists(): print(f"Error: File no ...[truncated 3125 chars]- Remediation
View remediation
Remediation Suggestions
- Require
https://forPADDLEOCR_API_URL,PADDLEOCR_JOB_URL, and all derived service URLs. Reject plaintext HTTP. - Restrict destinations to documented PaddleOCR/Baidu domains or a configurable administrator-approved hostname allowlist.
- Parse URLs with a standard URL parser and reject embedded credentials, fragments, unexpected ports, malformed hosts, and non-HTTP schemes.
- Resolve destination hosts and reject loopback, private, link-local, multicast, and cloud-metadata address ranges unless an administrator has explicitly approved a private deployment.
- Revalidate the destination after DNS resolution and on every redirect, or disable redirects entirely.
- Display a clear confirmation or policy notice before uploading a local document, identifying the exact destination hostname.
- Use narrowly scoped, short-lived API tokens and rotate any token suspected of having been sent to an untrusted endpoint.
- Add connection and read timeouts to asynchronous requests, consistent with the synchronous request.
- Document that Base64 does not protect document confidentiality and that users must only configure trusted HTTPS endpoints.
- Require
