Skip to content

Fix unsafe command execution in V4L2 control#3143

Merged
MichaIng merged 1 commit intodevfrom
fix-unsafe-cmd
May 14, 2025
Merged

Fix unsafe command execution in V4L2 control#3143
MichaIng merged 1 commit intodevfrom
fix-unsafe-cmd

Conversation

@MichaIng
Copy link
Member

@MichaIng MichaIng commented May 13, 2025

When using the camera_add/add motionEye web API, the camera device path for obtaining supported resolutions is passed via post request body. Adding single quotes to this input lifts the single-quotation in the final command string, allowing command substitution and hence remote command injection/execution. In this case, the final command is executed in shell context to allow piping and parsing the output with grep.

Use shlex.quote() to safely single-quote the input, and have embedded single-quotes escaped, to prevent any possible shell expansion, including variables and command substitutions.

Thanks to @hyperlyz for reporting this security vulnerability: #3142

When using the camera_add/add motioneye web API, the camera device path for obtaining supported resolutions is passed via post request body. Adding single quotes to this input lifts the single-quotation in the final command string, allowing command substitution and hence remote command injection/execution. In this case, the final command is executed in shell context to allow piping and parsing the output with grep.

Use shlex.quote to safely single-quote the input, and have embedded single-quotes escaped, to prevent any possible shell expansion, including variables and command substitutions.

Thanks to @hyperlyz for reporting this security vulnerability: #3142

Signed-off-by: MichaIng <micha@dietpi.com>
@MichaIng MichaIng requested a review from zagrim May 13, 2025 17:02
@MichaIng MichaIng changed the base branch from main to dev May 13, 2025 17:03
Copy link
Collaborator

@zagrim zagrim left a comment

Choose a reason for hiding this comment

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

👍

@MichaIng MichaIng merged commit a9e8165 into dev May 14, 2025
19 checks passed
@MichaIng MichaIng deleted the fix-unsafe-cmd branch May 14, 2025 13:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

[Security] RCE in add_camera Function Due to unsafe command execution in [motioneye-project/motioneye]

2 participants