Skip to content

Command Injection Vulnerability #2319

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
aydinnyunus opened this issue Apr 24, 2025 · 0 comments
Open

Command Injection Vulnerability #2319

aydinnyunus opened this issue Apr 24, 2025 · 0 comments

Comments

@aydinnyunus
Copy link

📌 Description

The following line of code is vulnerable to command injection:

os.system("ffmpeg -i %s -vn %s -q:a 2 -y" % (path, opt_format_path))

The inputs path and opt_format_path are directly concatenated into a shell command without any sanitization or validation. If a malicious user is able to influence the content of either path or opt_format_path, they could inject arbitrary shell commands, leading to remote code execution (RCE).


✅ Proof of Concept

If path is set to a malicious input like:

path = "input.wav; rm -rf /important_data"

The constructed command would become:

ffmpeg -i input.wav; rm -rf /important_data -vn output.wav -q:a 2 -y

Which would execute the destructive rm -rf command.


🔧 Recommendation

Avoid using os.system() with unsanitized inputs. Use the subprocess module with argument lists to avoid shell injection:

import subprocess
subprocess.run(["ffmpeg", "-i", path, "-vn", opt_format_path, "-q:a", "2", "-y"], check=True)

This ensures each argument is passed safely, regardless of its content.

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

No branches or pull requests

1 participant