| Package Name | Ecosystem | Vulnerable Versions | First Patched Version |
|---|---|---|---|
| motioneye | pip | < 0.43.1b5 | 0.43.1b5 |
The vulnerability allows for Remote Code Execution by injecting shell commands into configuration fields in the MotionEye web UI. The provided vulnerability description explicitly mentions that the root cause is the lack of sanitization in config.py before writing to configuration files, and points to ConfigHandler.set_config() in the execution flow.
To pinpoint the exact vulnerable function, I analyzed the patch that fixed the vulnerability. The patch was identified by comparing the last vulnerable version (0.43.1b4) and the first patched version (0.43.1b5). The key commit f47d20088de1c15fba93c42e8a3ba4d888cc9a13 is titled "enh(backend): apply input sanity checks as well in backend".
This commit modifies the file motioneye/config.py and introduces server-side validation within the motion_camera_ui_to_dict function. Before this patch, user-controlled input for fields like movie_file_name and image_file_name was taken directly from the UI dictionary (ui) and placed into the configuration data structure. The patch adds calls to a new input_sanity_check function to validate these inputs against a regex, preventing the injection of shell metacharacters.
Therefore, the motion_camera_ui_to_dict function is the precise location where the vulnerability existed, as it was the function that processed the malicious input without proper validation. While ConfigHandler.set_config() is part of the chain, the lack of sanitization itself was within motion_camera_ui_to_dict.
motion_camera_ui_to_dictmotioneye/config.py
Verify Execution
ls -la /tmp
/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" />
Ongoing coverage of React2Shell