T05 · Unauthorized Access and Privilege Escalation
- Location
scripts/chaoji_utils.py:139- Finding
Unrestricted Local File Paths Can Be Uploaded as Images
- Content
View full analysis
str: """ Prepare an image input. """ # If it is a URL, extract the path if image_input.startswith("http"): if ".com/" in image_input: return image_input.split(".com/", 1)[1] elif ".aliyuncs.com/" in image_input: return image_input.split(".aliyuncs.com/", 1)[1] return image_input # If it is an existing local file path, upload it if os.path.exists(image_input): if upload_func: return upload_func(image_input) raise RuntimeError(f"An upload function is required for local file: {image_input}") # Otherwise, treat it as an OSS path return image_input ``` The selected path is subsequently uploaded: ```python def upload_local_file(file_path: str, ak: str, sk: str) -> str: uploader = ChaojiOssUploader(ak, sk) result = uploader.upload_image(file_path) if not result["success"]: raise RuntimeError(f"Upload failed: {result.get('error')}") return extract_oss_path(result["url"]) ``` This behavior is reachable through the image parameters used by the try-on, shoe try-on, image-to-image, and cutout executors. ### Technical Analysis The code classifies any existing filesystem path as an image solely through `os.path.exists()`. It does not: - Restrict paths to the declared workspace directory. - Resolve and validate canonical paths. - Reject symbolic links. - Require the path to be a regular file. - Verify the extension, MIME type, or image signature. - Enforce a file-size limit. - Request explicit confirmation before uploading local dat ...[truncated 1247 chars]- Remediation
View remediation
