Repository navigation
feat: restrict input protocols and demuxers - #13
Conversation
Adapters take optional protocols and formats lists, passed as -protocol_whitelist and -format_whitelist before every ffmpeg input and to ffprobe. Both default to empty, which keeps current behaviour. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
🟢 Tier S · Ready to merge
Adds optional protocol and demuxer allowlists to FFmpeg and FFprobe inputs, with empty defaults preserving existing behavior. Documents using the allowlists with untrusted media and adds end-to-end coverage for playlist rejection, local-file protocol rejection, and normal MP4 probe, encode, and transcode behavior. Latest changes: The new commits add end-to-end checks that protocol-only allowlists reject local files in both probe and FFmpeg paths, and that standalone encoding still works with both allowlists enabled.
📂 Walkthrough · 5
Reviewed the commits since |
| $video = $info->hasVideo && ($rep === null || $rep->scaled()); | ||
|
|
||
| $args = $this->prefix(); | ||
| \array_push($args, ...$this->opens()); |
There was a problem hiding this comment.
Add coverage for the input whitelist arguments
The existing adapter and ffprobe tests do not verify these new flags or that they appear before each input. If the flags are later omitted or misplaced, configured adapters could silently allow playlist or nested resource opens again; please add command-level coverage for ffmpeg and ffprobe.
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/Video/Adapter/FFmpeg.php
Line: 101
Comment:
**Add coverage for the input whitelist arguments**
The existing adapter and ffprobe tests do not verify these new flags or that they appear before each input. If the flags are later omitted or misplaced, configured adapters could silently allow playlist or nested resource opens again; please add command-level coverage for ffmpeg and ffprobe.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.🟡 Minor · testing · Reply if this doesn't apply.
There was a problem hiding this comment.
Added tests/Video/E2E/WhitelistTest.php, which runs real ffprobe and ffmpeg: an unrestricted probe follows a local HLS playlist, while a restricted probe and a restricted encoder (with an open probe, so the refusal comes from ffmpeg) both fail on it, and a restricted encoder still probes and grabs from an MP4. Passes locally on ffmpeg 8.1.2.
There was a problem hiding this comment.
The end-to-end tests are useful, but they don’t fully cover the requested arguments. Both restricted cases allow file and exclude hls, so their failures demonstrate the format restriction, not that -protocol_whitelist was emitted. They also don’t assert the argument order for each input. The tests exercise playlist rejection, while opens() builds both flags.
Please add command-level assertions for the whitelist arguments and their placement before each FFmpeg input and the FFprobe source.
There was a problem hiding this comment.
Added cases that restrict protocols only (https,tls,tcp, no format list): ffprobe and ffmpeg (behind an open probe) each refuse a local MP4, so -protocol_whitelist reaches both commands independently of -format_whitelist. A restricted encode of an MP4 also runs. These stay end to end against real binaries rather than asserting argv, since the argv is built in protected methods with no seam to observe it.
There was a problem hiding this comment.
Understood. The end-to-end tests cover the restrictions against real ffprobe and ffmpeg binaries, so I’ve dismissed the command-level assertion finding. WhitelistTest.php
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Adds optional
protocolsandformatsconstructor arguments to every adapter. When set, they are passed as-protocol_whitelist/-format_whitelistbefore each ffmpeg-iand before ffprobe's input, so callers handling user uploads can stop playlist demuxers (hls,concat) from opening other files or URLs. Both default to empty, leaving current behaviour unchanged.Checked against ffmpeg 8.1.2: with
formatsset, an HLS playlist is rejected (Format not on whitelist) and no segment is requested, while an MP4 still probes and transcodes.🤖 Generated with Claude Code
Related: appwrite-labs/cloud#6673