T09 · Insecure Skill Coding Practices
- Location
scripts/main.py:66- Finding
Arbitrary Local File Contents Can Be Transmitted to the OCR Service
- Content
View full analysis
MAX_IMAGE_SIZE_BYTES: sys.exit(1) return encoded ``` The resulting content is assigned to the OCR request and sent to Tencent Cloud: ```python elif args.image_base64: req.ImageBase64 = load_image_base64(args.image_base64) try: resp = client.IDCardOCR(req) except TencentCloudSDKException as e: sys.exit(1) ``` ### Technical Analysis The `--image-base64` argument accepts either a Base64 value or any path for which `os.path.isfile()` returns true. When a path is supplied, the script reads the complete file. If the content is not already valid Base64 text, it Base64-encodes the raw bytes and submits them through the Tencent Cloud OCR SDK. Base64 encoding is a normal and documented transport mechanism for the OCR API, so the encoding operation is not inherently covert or malicious. However, the implementation does not verify that the selected file is actually an image. It does not check a trusted MIME type, image signature, supported format, or successful decoding through an image parser. Consequently, any readable file smaller than the 10 MB limit can be placed into the outbound OCR request. This exceeds the minimum file access needed for the declared ID-card image recognition functionality. ### Attack Path 1. An attacker gains influence over the arguments used to invoke the Skill, such as by supplying an untrusted path ...[truncated 1323 chars]- Remediation
View remediation
