Skip to content

πŸ›‘οΈ Sentinel: [HIGH] Fix FFmpeg Filter Injection Vulnerability#131

Open
Cukurikik wants to merge 1 commit into
mainfrom
sentinel/fix-ffmpeg-filter-injection-17547521219066521996
Open

πŸ›‘οΈ Sentinel: [HIGH] Fix FFmpeg Filter Injection Vulnerability#131
Cukurikik wants to merge 1 commit into
mainfrom
sentinel/fix-ffmpeg-filter-injection-17547521219066521996

Conversation

@Cukurikik
Copy link
Copy Markdown
Collaborator

@Cukurikik Cukurikik commented Mar 22, 2026

🚨 Severity: HIGH
πŸ’‘ Vulnerability: The watermark.engine.ts directly mapped unsanitized user inputs (opts.text) to an FFmpeg drawtext filter. If a user provided text with colons or specific characters (e.g., :textfile=/etc/passwd), they could potentially break out of the variable string and execute malicious local file reads via the FFmpeg engine.
🎯 Impact: Exploitation could lead to local file disclosure (LFI) via the underlying FFmpeg instance. It also caused functional bugs where legit colons in timestamps would cause a crash.
πŸ”§ Fix: Sanitized the user input using standard string escaping for FFmpeg: backslashes, colons, and single quotes.
βœ… Verification: Verified the fix mitigates injection directly at the engine layer and passes type checks.


PR created automatically by Jules for task 17547521219066521996 started by @Cukurikik

Summary by CodeRabbit

Bug Fixes

  • Fixed watermark text processing to properly handle special characters, preventing formatting errors when special characters are included in watermark text.

Co-authored-by: Cukurikik <266119688+Cukurikik@users.noreply.github.com>
@google-labs-jules
Copy link
Copy Markdown
Contributor

πŸ‘‹ Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a πŸ‘€ emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Mar 22, 2026

πŸ“ Walkthrough

Walkthrough

The buildWatermarkArgs function in the watermark engine now sanitizes user input by escaping special characters (backslashes, colons, and single quotes) in the text option before embedding it into the FFmpeg drawtext filter expression to prevent syntax errors.

Changes

Cohort / File(s) Summary
Input Sanitization
src/modules/video-engine/engines/watermark.engine.ts
Added character escaping for opts.text to escape backslashes, colons, and single quotes before passing to FFmpeg drawtext filter to prevent malformed filter syntax.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 A watermark text, once wild and free,
Now escapes its quotes with certainty,
Colons and backslashes tamed with care,
FFmpeg filters work beyond compare! ✨

πŸš₯ Pre-merge checks | βœ… 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
βœ… Passed checks (2 passed)
Check name Status Explanation
Description Check βœ… Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check βœ… Passed The title references a security fix for FFmpeg filter injection, which directly matches the core change in the pull request that sanitizes user input to prevent injection attacks.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
πŸ“ Generate docstrings
  • Create stacked PR
  • Commit on current branch
πŸ§ͺ Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch sentinel/fix-ffmpeg-filter-injection-17547521219066521996

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

πŸ€– Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/modules/video-engine/engines/watermark.engine.ts`:
- Line 4: The code assumes opts.text is a string when assigning to the local
variable text (let text = (opts.text as string) || "HEAVY-TOOLS"), which can
throw later when sanitizing non-string values; change the assignment to first
guard the runtime type (e.g., check typeof opts.text === "string") and only use
opts.text if it's a string, otherwise fall back to the default "HEAVY-TOOLS"
before any sanitization; update references to text and any subsequent
sanitization logic in watermark.engine.ts (the text variable and opts.text
usage) so non-string inputs are safely handled.

ℹ️ Review info
βš™οΈ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 24a64d64-4358-4659-bd5a-fc93ab620be1

πŸ“₯ Commits

Reviewing files that changed from the base of the PR and between 7cab4ed and 9f7fd6b.

πŸ“’ Files selected for processing (1)
  • src/modules/video-engine/engines/watermark.engine.ts

export interface WatermarkOptions { [key: string]: unknown; }
export async function buildWatermarkArgs(input: string, output: string, opts: WatermarkOptions, ffmpeg?: FFmpeg, files?: File[]): Promise<string[]> {
const text = (opts.text as string) || "HEAVY-TOOLS";
let text = (opts.text as string) || "HEAVY-TOOLS";
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Guard opts.text type before sanitization to prevent runtime crashes.

At Line 4, as string does not coerce runtime values. If opts.text is a truthy non-string, Line 8 will throw.

πŸ”§ Suggested fix
-  let text = (opts.text as string) || "HEAVY-TOOLS";
+  let text = typeof opts.text === "string" ? opts.text : "HEAVY-TOOLS";
πŸ“ Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
let text = (opts.text as string) || "HEAVY-TOOLS";
let text = typeof opts.text === "string" ? opts.text : "HEAVY-TOOLS";
πŸ€– Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/modules/video-engine/engines/watermark.engine.ts` at line 4, The code
assumes opts.text is a string when assigning to the local variable text (let
text = (opts.text as string) || "HEAVY-TOOLS"), which can throw later when
sanitizing non-string values; change the assignment to first guard the runtime
type (e.g., check typeof opts.text === "string") and only use opts.text if it's
a string, otherwise fall back to the default "HEAVY-TOOLS" before any
sanitization; update references to text and any subsequent sanitization logic in
watermark.engine.ts (the text variable and opts.text usage) so non-string inputs
are safely handled.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant