T09 · Insecure Skill Coding Practices
- Location
scripts/gradelib.py:72- Finding
Untrusted Grade Specifications Are Executed as FFmpeg Filtergraphs
- Content
View full analysis
Vulnerability Details
File Location:
scripts/gradelib.py:72-78; execution sinks inscripts/apply_grade.py:33-39,scripts/bake_lut.py:36-38,55-57,scripts/render_looks.py:38-41, andscripts/make_clips.py:22-27
Vulnerability Type: FFmpeg filtergraph injection
Risk Level: HighVulnerable Code
python def full_chain(spec, look): """A look's full ffmpeg filter = corrective base + ',' + creative layer.""" base = (spec.get("base") or "").strip() layer = (look.get("chain") or "").strip() if look.get("prepend_base", True) and base: return base + ("," + layer if layer else "") return layer or "null"Representative execution sink in
scripts/apply_grade.py:python spec = gl.load_spec(args.looks); chain = gl.full_chain(spec, gl.get_look(spec, args.name)) gl.run(["ffmpeg", "-hide_banner", "-loglevel", "error", "-y", "-i", os.path.abspath(args.video), "-vf", chain, "-c:v", "libx264", "-crf", args.crf, "-preset", args.preset, "-pix_fmt", "yuv420p", "-c:a", "copy", "-movflags", "+faststart", os.path.abspath(args.out)])Representative execution sink in
scripts/make_clips.py:python gl.run(["ffmpeg", "-hide_banner", "-loglevel", "error", "-y", "-ss", str(ss), "-t", str(t), "-i", os.path.abspath(video), "-i", os.path.abspath(lp), "-filter_complex", f"[0:v]{chain}[g];[g][1:v]overlay=10:10[v]", "-map", "[v]", "-map", "0:a?", "-c:v", "libx264", "-crf", "20", "-preset", "veryfast", "-pix_fmt", "yuv420p", "-c:a", "aac", "-b:a", "128k", "-movflags", "+faststart", os.path.abspath(out)])Technical Analysis
The
baseandchainproperties are read from a user-supplied JSON specification and concatenated without validating their syntax, length, filter names, options, or referenced resources. The resulting value is passed directly to FFmpeg through-vfor embedded in `-fi ...[truncated 2157 chars]- Remediation
View remediation
Remediation Suggestions
- Replace arbitrary filtergraph strings with a structured grade schema containing only explicitly supported operations and numeric parameters.
- Allowlist the point filters required by the documented workflow, such as
colorbalance,eq,curves, andvibrance. - For every allowed filter, validate option names, numeric types, finite values, and conservative ranges.
- Reject unknown filters, source filters, path-taking options, metadata-output filters, external resource references, and graph-control syntax not required by the workflow.
- Apply maximum lengths to all filter expressions and limits to the number of filters in a chain.
- Validate legacy specifications as strictly as canonical grade plans.
- Run FFmpeg in a restricted environment where practical, using a low-privilege account, filesystem sandbox, resource limits, and disabled network access.
- Add negative tests proving that path-taking filters, unexpected graph labels, extra inputs, and oversized expressions are rejected before FFmpeg starts.
