T09 · Insecure Skill Coding Practices
- Location
scripts/i2i_workflow.py:125- Finding
Unrestricted Local File Upload to External Storage
- Content
View full analysis
str: """上传图片并返回 URL""" if not api_key: api_key = get_api_key() file_path = Path(file_path).resolve() if not file_path.exists(): print(f"❌ 文件不存在: {file_path}") sys.exit(1) file_name = file_path.name print(f"📁 上传图片: {file_name}") # 获取上传凭证 upload_params = get_upload_token(file_name, api_key) # 上传到 OSS if not upload_to_oss( region=upload_params["region"], endpoint=upload_params["endpoint"], bucket=upload_params["bucket"], object_key=upload_params["object_key"], file_path=str(file_path), access_key_id=upload_params["access_key_id"], access_key_secret=upload_params["access_key_secret"], security_token=upload_params["security_token"], ): sys.exit(1) ``` ### Technical Analysis The image-to-image workflow legitimately requires uploading a user-selected image. However, the implementation only verifies that the resolved path exists. It does not verify that the path: - Refers to a regular file. - Contains a valid image. - Has an approved image format. - Is within an expected user-controlled directory. - Is below a safe size limit. - Is not a symbolic link to a sensitive file. As a result, the `--image` argument can identify any locally readable filesystem object accepted by the OSS client. Sensitive files such as environment files, SSH private keys, cloud credentials, application configuration, or agent state could therefore be sent to external BizyAir-provided Alibaba OSS storage. This exceeds the minimum filesystem privileges necessary for the declared image-to-image functionality. ### Attack Path 1. An attacker supplies a request that presents a sensitive local ...[truncated 1260 chars]- Remediation
View remediation
