T09 · Insecure Skill Coding Practices
- Location
scripts/table_ocr.py:57- Finding
Arbitrary Local Files Can Be Encoded and Uploaded to an External OCR Service
- Content
View full analysis
MAX_IMAGE_SIZE_BYTES: print( f"错误: 文件大小超过 {MAX_IMAGE_SIZE_BYTES // (1024 * 1024)}MB 限制", file=sys.stderr, ) sys.exit(1) return base64.b64encode(raw).decode("utf-8") ``` The resulting data is subsequently assigned to the Tencent Cloud OCR request: ```python if image_url: req.ImageUrl = image_url elif image_base64: req.ImageBase64 = image_base64 else: raise ValueError("必须提供 image_base64 或 image_url 之一") ``` ### Technical Analysis The `--image-base64` option accepts either a Base64 value or a local path. When the argument resolves to an existing file, the script reads the entire file and either treats it as pre-encoded Base64 or encodes its raw contents. No validation establishes that the selected file is actually a supported image. In particular, the code does not validate: - The file's canonical path or whether it belongs to the user-provided workspace. - PNG or JPEG magic bytes. - MIME type or decoded image structure. - File extension. - Whether a symbolic link resolves outside the expected input directory. - Whether the user explicitly approved transmission of that specific file. The 10 MB size restriction limits payload size but does not prevent disclosure of credentials, private keys, configuration files, or other sensitive lo ...[truncated 1974 chars]- Remediation
View remediation
