T01 · Skill Instruction Hijacking
- Location
scripts/generate_edl.py:133- Finding
Untrusted transcript content can influence unvalidated FFmpeg rendering instructions
- Content
View full analysis
str: """Build the prompt sent to the LLM.""" ``` The resulting transcript is inserted directly into the prompt: ```python prompt = template.format( transcript_text=transcript_text, **merged, custom_prompt=params.get("custom_prompt", "无特殊要求"), ) ``` `scripts/render_edl.py:191-225`: ```python for i, edit in enumerate(edits): edit_type = edit.get("type", "keep") if edit_type not in ("keep",): print(f" [{i+1}/{len(edits)}] 跳过 {edit_type} (暂不支持)") continue source_id = edit.get("source", edit.get("source_id", "src0")) src_info = sources.get(source_id, {}) src_path = src_info.get("path", "") start = edit.get("start", 0) end = edit.get("end", 0) reason = edit.get("reason", "") params = edit.get("params", {}) if not src_path or end <= start: continue seg_file = os.path.join(tmp_dir, f"seg_{i:04d}.mp4") print(f" [{i+1}/{len(edits)}] {start:.1f}s-{end:.1f}s ({end - start:.1f}s)" f" — {reason[:50]}") if not extract_segment(src_path, start, end, seg_file): continue current = seg_file if params.get("color_grade"): graded = os.path.join(tmp_dir, f"seg_{i:04d}_graded.mp4") ...[truncated 4326 chars]- Remediation
View remediation
start`, maximum segment lengths, and source-duration bounds. - Add `srt_path` to the schema only with explicit validation if it is intended to be supported. 3. Restrict source paths: - Resolve paths with `Path.resolve()`. - Require source and subtitle files to remain inside user-approved directories. - Reject URL schemes and FFmpeg pseudo-protocols unless the user explicitly authorizes them. - Consider invoking FFmpeg with a restrictive `-protocol_whitelist` appropriate to local processing. 4. Secure FFmpeg filter construction: - Escape path and style values according to FFmpeg filtergraph rules. - Avoid direct string interpolation into filter expressions. - Allowlist fonts, colors, positions, and other style fields. 5. Enforce approval at the trust boundary: - Display source-path and subtitle-path changes prominently. - Require explicit confirmation before rendering EDLs produced by an LLM. - Do not rely solely on workflow documentation for approval. 6. Add resource controls: - Apply subprocess timeouts and file-size, duration, resolution, and output-size limits. - Run FFmpeg with reduced privileges and constrained network access when processing untrusted media. ]]>
