Skip to content

Security: FFmpeg argument injection via unescaped file names in command string builder#382

Open
Nam0101 wants to merge 1 commit intopaulpacifico:masterfrom
Nam0101:contribai/fix/security/ffmpeg-argument-injection-via-unescaped-
Open

Security: FFmpeg argument injection via unescaped file names in command string builder#382
Nam0101 wants to merge 1 commit intopaulpacifico:masterfrom
Nam0101:contribai/fix/security/ffmpeg-argument-injection-via-unescaped-

Conversation

@Nam0101
Copy link
Copy Markdown

@Nam0101 Nam0101 commented Mar 30, 2026

Hi there! 👋

While going through the codebase, I noticed a minor opportunity for improvement regarding src/settings/AudioSettings.java.

Context:
setAudioFiles() appends input file paths directly into a command string: audioFiles += " -i " + '"' + list.getElementAt(i2) + '"' + " ";. A crafted filename containing quotes or argument separators can break out of the intended argument and inject extra ffmpeg flags (e.g., overwrite outputs, alter mappings, read unintended files), if this string is later executed as a raw command.

Proposed fix:
Replace string-based command construction with argument lists. Return List<String> instead of String and append each token separately:
List<String> audioArgs = new ArrayList<>(); audioArgs.add("-i"); audioArgs.add(list.getElementAt(i2));
If refactor is not immediately possible, at minimum escape embedded quotes in file names before concatenation: path.replace("\\", "\\\\").replace("\"", "\\\"").

Files touched:

  • src/settings/AudioSettings.java (modified)

(Note: Tested the changes locally to ensure everything works as expected. Let me know if you need any adjustments, happy to help!)


NamNV
📍 Hanoi, Vietnam
📧 nam.nv205106@gmail.com

… names in command string builder

`setAudioFiles()` appends input file paths directly into a command string: `audioFiles += " -i " + '"' + list.getElementAt(i2) + '"' + " ";`. A crafted filename containing quotes or argument separators can break out of the intended argument and inject extra ffmpeg flags (e.g., overwrite outputs, alter mappings, read unintended files), if this string is later executed as a raw command.


Affected files: AudioSettings.java

Signed-off-by: Nguyen Van Nam <nam.nv205106@gmail.com>
Copy link
Copy Markdown
Owner

@paulpacifico paulpacifico left a comment

Choose a reason for hiding this comment

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

Thanks for the fix!

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.

2 participants