T09 · Insecure Skill Coding Practices
- Location
scripts/content_automator.py:136- Finding
Unescaped User-Controlled Title Enables FFmpeg Filtergraph Injection
- Content
View full analysis
Vulnerability Details
File Location:
scripts/content_automator.py, lines 136–142
Vulnerability Type: FFmpeg filtergraph injection
Risk Level: MediumVulnerable Code:
python ffmpeg_cmd = [ "ffmpeg", "-y", "-f", "lavfi", "-i", f"color=c=black:s=1920x1080:d={audio_duration}", "-i", str(audio_path), "-vf", f"drawtext=text='{title}':fontsize=48:fontcolor=white:x=(w-text_w)/2:y=(h-text_h)/2", "-c:v", "libx264", "-preset", "fast", "-crf", "23", "-c:a", "aac", "-b:a", "128k", "-shortest", str(output_path) ]Technical Analysis
The
titleparameter is incorporated directly into an FFmpeg-vffiltergraph expression without escaping FFmpeg filtergraph metacharacters. For thescriptcommand, this value originates from the user-controlled--titleargument and reachesassemble_video()at lines 222–223.Passing the command as an argument list correctly prevents conventional shell command injection. It does not, however, prevent injection into FFmpeg's own expression and filtergraph grammar. Characters such as single quotes, colons, commas, semicolons, and backslashes can terminate or modify the
drawtextexpression. FFmpeg expansion syntax may also cause unintended interpretation.An attacker who can control the title can therefore invalidate the graph or attempt to append additional filters supported by the installed FFmpeg build. The exact secondary effects depend on available FFmpeg filters, protocols, and operating-system permissions.
Attack Path
- An attacker supplies a crafted value through the
script --titlecommand-line argument. cmd_script()passesargs.titleunchanged toassemble_video()at lines 222–223.assemble_video()concatenates the value into thedrawtextfilter expression at line 139.- FFmpeg parses attacker-supplied metacharacters as filtergraph syntax rather than literal title text.
- The crafted grap ...[truncated 901 chars]
- An attacker supplies a crafted value through the
- Remediation
View remediation
Remediation Suggestions
- Do not concatenate untrusted titles directly into an FFmpeg filtergraph.
- Store the title in a controlled UTF-8 temporary text file and reference it through
drawtext'stextfileoption. - Disable text expansion with
expansion=nonewhere supported and suitable. - Properly escape both the text-file path and all FFmpeg filtergraph metacharacters; argument-list execution alone is insufficient.
- Apply a reasonable title-length limit and reject control characters or unsupported Unicode sequences before invoking FFmpeg.
- Run FFmpeg with least privilege in a sandbox or restricted container with minimal filesystem and network access.
- Restrict unnecessary FFmpeg protocols and capabilities, such as through an appropriate
-protocol_whitelist, after verifying the protocols required by the intended workflow. - Add tests using titles containing quotes, colons, commas, semicolons, brackets, percent signs, and backslashes to verify they are rendered literally rather than parsed as filter syntax.
