Repository navigation
fix(green-screen): validate and sanitize bg_color to prevent filter injection - #716
Merged
calesthio merged 1 commit intoNov 8, 2026
Merged
Conversation
…njection Validate bg_color hex format in GreenScreenProcessor before interpolating into FFmpeg filter graph commands in _process_chromakey or parsing RGB channels in _process_rembg. Rejects malformed strings and filter graph delimiter injections. Reported-by: BS.ehlas.cz
Contributor
Author
|
Gentle ping on this one: it validates |
calesthio
approved these changes
Nov 7, 2026
calesthio
left a comment
Collaborator
There was a problem hiding this comment.
Thank you for validating background colors before filter construction. Reviewed the complete diff against main 63d1087a: accepted 3/6/8-digit hex forms are normalized, invalid/filter syntax is rejected before subprocess launch, and both background-removal paths use the validation. Validation: isolated offline suite — 18 passed, including native FFmpeg chroma-key rendering.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Validates and sanitizes
bg_colorinGreenScreenProcessor(tools/video/green_screen_processor.py) to prevent FFmpeg filter graph injection.Previously,
bg_colorwas only stripped of#(bg_color.lstrip("#")) and directly interpolated into the filter graph string in_process_chromakey():f"color=c=0x{bg_hex}:size={width}x{height}"If an attacker supplied a crafted
bg_colorstring containing filter graph delimiters (such as commas, colons, or filter expressions like000000,drawbox=...), arbitrary FFmpeg filter chains could be injected.Changes
_validate_hex_color(bg_color: str) -> strto enforce strict 3, 6, or 8 character hexadecimal formatting and expansion (e.g.000->000000).bg_colorupfront inexecute()so invalid color inputs return a cleanToolResult(success=False, error=...)without launching subprocesses._process_chromakey()and_process_rembg()before passing into FFmpeg filter graph definitions or slicing RGB channels.tests/tools/test_green_screen_chromakey.pycovering valid colors and rejecting filter injection payloads / malformed hex values.Testing
uv run --with pytest pytest tests/tools/test_green_screen_chromakey.py(18 passed)uv run --with-requirements requirements-dev.txt --with filelock pytest tests/contracts/(1229 passed, 7 skipped)Checklist
make test-contracts/make test) where applicable.Disclaimer: Vulnerability spotted while test-driving BudgetScan https://huge.github.io/nano-analyzer static analysis. Fix human-verified.