GHSA-j945-qm58-4gjx motionEye vulnerable to RCE via unsanitized motion config parameter
SummaryA command injection vulnerability in MotionEye allows attackers to achieve Remote Code Execution (RCE) by supplying malicious values in configuration fields exposed via the Web UI. Because MotionEye writes user-supplied values directly into Motion configuration files without sanitization, attackers can inject shell syntax that is executed when the Motion process restarts. This issue enables full takeover of the MotionEye container and potentially the host environment (depending on container privileges).DetailsRoot Cause:MotionEye accepts arbitrary strings from fields such as **image_file_name**  and **movie_filename** in the Web UI. These are written directly into **/etc/motioneye/camera-*.conf**. When MotionEye restarts the Motion service (motionctl.start), the Motion binary reads this configuration. Because Motion treats these fields as shell-expandable, injected characters (e.g. $(), backticks) are interpreted as shell commands.Vulnerability flow:Dashboard (Web UI)
   ↓
ConfigHandler.set_config()
   ↓
camera-*.conf written
   ↓
motionctl.restart()
   ↓
Motion parses config → executes payloadAffected code:The issue arises in how config.py handles user input before writing to config files. No sanitization or allowlisting is applied to filename fields.Proof of Concept (PoC)The following steps reproduce the Remote Code Execution (RCE) vulnerability in MotionEye.  
Tested using the official Docker image.Environment Setup**Start MotionEye container**  
Launch the vulnerable container:**Verify version**  
Confirm the running version inside logs:**Result:****Container shell access (for verification later)**  
Keep a shell handy to verify results:Exploitation Steps**Access Web Interface**Open browser at: `http://127.0.0.1:9999`Login with default credentials: **admin** / *(blank password)*Add a sample RTSP network camera (required to enable camera-specific settings).**Attempt malicious filename input**Go to: **Camera Settings → Still Images**In the **Image File Name** field, try:**Observation:** This is blocked by client-side validation in the browser.**Client-Side Validation Discovery**The check is implemented in JavaScript:`/static/js/main.js?v=0.43.1b4` → references `/static/js/ui.js?v=0.43.1b4`Example validation function:**Bypass Validation**Open browser console (**F12 → Console tab**)Override the function to always return true:This bypasses client-side validation and allows arbitrary values.
<img width="819" height="539" alt="bypass" src="https://github.com/user-attachments/assets/c18d50cf-1f41-4f31-a23b-23ade9babaa2" />**Inject Payload**Set **Capture Mode**: `Interval Snapshots`Set **Interval**: `10`Set **Image File Name** to the payload:Click **Apply** to save settings.
<img width="565" height="344" alt="inject_payload" src="https://github.com/user-attachments/assets/f23e76b2-6af3-490d-bce3-60ac3f96241e" />**Verify Execution**Inside the container shell:**Result:** File `/tmp/test` is created with root permissions, confirming code execution.
<img width="554" height="164" alt="verify" src="https://github.com/user-attachments/assets/11122ba8-becf-4657-bc87-f88f293e8b02" />Weaponizing RCE (Reverse Shell Example)**Start attacker listener****Inject reverse shell payload**  
Enter the following into the **Image File Name** field:**Result**A reverse shell connects back to the attacker’s machine.Attacker gains full control of the MotionEye container environment.
<img width="1140" height="366" alt="final" src="https://github.com/user-attachments/assets/2a8f650f-68f3-43b2-8594-08d5035c16b9" />Root CauseMotionEye writes unsanitized values (e.g., `image_file_name`) from the Web UI directly into `camera-<id>.conf`.On restart, the `motion` binary parses these fields as shell-expandable strings, leading to arbitrary command execution.ImpactType: OS Command Injection → Remote Code ExecutionWho is impacted:Any MotionEye deployment where attackers can authenticate as admin (or where the UI is left exposed with default/no password).Containerized and bare-metal installs alike.Potential consequences:Full compromise of MotionEye container.Lateral movement or host compromise if the container runs with privileged permissions or mounts sensitive host volumes.
CVSS v3.1 score: 7.2