T09 · Insecure Skill Coding Practices
- Location
scripts/seedance.py:267- Finding
Arbitrary Command Execution Through an Unescaped Download Path on macOS
- Content
View full analysis
Vulnerability Details
File Location:
scripts/seedance.py, lines 267–278
Vulnerability Type: OS command injection
Risk Level: High
Affected Platform: macOSVulnerable Code
python if download_dir and video_url: download_path = Path(download_dir).expanduser() download_path.mkdir(parents=True, exist_ok=True) filename = f"seedance_{task_id}_{int(time.time())}.mp4" filepath = download_path / filename print(f"\nDownloading video to {filepath}...") try: urllib.request.urlretrieve(video_url, str(filepath)) print(f"Saved to: {filepath}") if sys.platform == "darwin": os.system(f'open "{filepath}"')Technical Analysis
The
--downloadcommand-line argument controlsdownload_dir, which is incorporated intofilepath. After a successful video download on macOS, the application interpolates this path directly into a command passed toos.system().os.system()invokes a command shell. Enclosing the path in double quotes does not make it safe because command substitutions such as$()and backticks are still evaluated inside double-quoted shell strings. Embedded quote characters can also terminate the intended quoted argument and introduce additional shell syntax.Consequently, a download directory containing shell syntax can cause arbitrary commands to execute when the generated video is opened. No shell is required for this operation because the
openutility can receive the path as a discrete argument through a subprocess API.Attack Path
- An attacker supplies, or persuades the Agent to use, a malicious value for the
--downloadargument. - The Agent invokes either
create --wait --download ...orwait --download ...on macOS. - The application creates the attacker-controlled directory and waits for a valid generation task to succeed.
- The generated video is downloaded into the crafted path.
...[truncated 981 chars]
- An attacker supplies, or persuades the Agent to use, a malicious value for the
- Remediation
View remediation
Remediation Suggestions
Eliminate the shell invocation and pass the executable and file path as separate arguments:
python import subprocess if sys.platform == "darwin": try: subprocess.run( ["open", str(filepath)], check=False, shell=False, ) except OSError as exc: print(f"Unable to open downloaded video: {exc}", file=sys.stderr)Additional hardening measures should include:
- Never use
shell=Trueoros.system()for opening downloaded files. - Validate that the destination resolves to an intended user-approved directory.
- Reject unexpected control characters, including null bytes and line breaks, in externally supplied paths.
- Continue treating the path as one opaque argument rather than attempting manual shell escaping.
- Add regression tests using paths containing spaces, quotes, semicolons, backticks, and literal
$()sequences to verify that none are interpreted as shell syntax. - Consider making automatic opening opt-in through a separate flag so downloading a file does not implicitly launch another local program.
- Never use
