T09 · Insecure Skill Coding Practices
- Location
scripts/run_seedance.py:188- Finding
Unrestricted Local File Upload Can Expose Sensitive Host Data
- Content
View full analysis
Vulnerability Details
File Location:
scripts/run_seedance.py:188-201, with the resulting network transmission atscripts/run_seedance.py:219-225andscripts/run_seedance.py:255-262
Vulnerability Type: Arbitrary local file disclosure through unrestricted multipart upload
Risk Level: HighVulnerable Code
python def open_files_for_upload(paths: List[str]) -> List[Tuple[str, Tuple[str, Any, str]]]: """Open local files and return list of (form_key, (filename, fileobj, content_type)) for multipart upload.""" result = [] for path in paths: path = path.strip() if not path: continue if not os.path.isfile(path): raise FileNotFoundError(f"File not found: {path}") f = open(path, "rb") name = os.path.basename(path) mime, _ = mimetypes.guess_type(path) mime = mime or "application/octet-stream" result.append(("files", (name, f, mime))) return resultThe files selected by this function are passed directly to the remote service:
python upload_paths = filter_files_by_url_overrides( file_paths=args.files or [], image_urls=image_urls or [], video_urls=video_urls or [], audio_urls=audio_urls or [], ) file_tuples = open_files_for_upload(upload_paths) if upload_paths else []python resp = requests.post( VID_URL, headers={ "Authorization": f"Bearer {api_key}", }, data=data, files=file_tuples, timeout=120, )Technical Analysis
The
--filesargument accepts arbitrary filesystem paths. The implementation checks only whether each path refers to a regular file. It does not:- Restrict files to a dedicated upload or workspace directory.
- Resolve and validate canonical paths against an approved root.
- Reject symbolic links that resolve outside an approved directory.
- Restrict uploads to supported image, video, or audio formats.
- Validate file contents against their claime ...[truncated 1970 chars]
- Remediation
View remediation
Remediation Suggestions
- Create a dedicated media-upload directory, such as
workspace/assets, and permit uploads only from that directory. - Resolve every supplied path with
Path.resolve(strict=True)and verify that the canonical path remains under the approved root. - Reject symbolic links or open files using platform-supported no-follow protections to reduce symlink and time-of-check/time-of-use risks.
- Allowlist supported media types and extensions. Reject
otherfiles rather than uploading them asapplication/octet-stream. - Inspect file signatures with a trusted media parser instead of relying solely on filename-based
mimetypes.guess_type(). - Enforce per-file and aggregate upload-size limits before opening or transmitting data.
- Require explicit user confirmation listing the canonical path, detected media type, size, and destination before upload.
- Run the Skill under an operating-system identity with access only to the intended workspace and no unnecessary credential directories.
- Log upload metadata without recording file contents or authorization tokens.
- Create a dedicated media-upload directory, such as
