
Unauthenticated SQL injection to RCE exploit for FreePBX 16 Endpoint Manager (CVE-2025-57819). Demonstrates stacked queries to write a webshell via cron_jobs and escalate to root.
Proof-of-concept for CVE-2025-57819, an unauthenticated stacked SQL injection in
the FreePBX Endpoint Manager module (admin/ajax.php, brand parameter). The
injection is escalated to remote code execution by INSERTing a row into
FreePBX's own cron_jobs table, so the appliance cron runner writes an attacker
webshell within about 60 seconds and runs it as the asterisk user. An optional
local privilege-escalation step proves root.
FreePBX framework < 16.0.89 (Endpoint Manager module). Confirm against the vendor advisory for the exact fixed release.
admin/ajax.php?module=FreePBX\modules\endpoint\ajax&command=model passes the
brand parameter into a SQL query without parameterization, and the driver
allows stacked statements. An unauthenticated request can therefore run
additional statements, including an INSERT into the cron_jobs table that
FreePBX's own cron runner later executes, turning SQL injection into command
execution as asterisk.
The optional root step abuses an appliance-local path: /etc/incron.d/legacy
makes root run /etc/init.d/dahdi, which sources the asterisk-writable
/etc/dahdi/init.conf.
python3 -m pip install requests
python3 exploit.py <target> [--vhost <name>] [--scheme https] [--root] [--cmd '<shell cmd>']
| Flag | Description |
|---|---|
target | IP or hostname of the FreePBX target |
--vhost | Host header, if the target is name-based vhosted |
--scheme | URL scheme (default https) |
--root | Also run the incron/dahdi init.conf privesc and prove root |
--cmd | Run one command through the planted webshell and exit |
Examples:
python3 exploit.py <target>
python3 exploit.py <target> --vhost pbx.example.local --root
python3 exploit.py <target> --cmd 'id'
Expected result: the script confirms the injection (leaked DB user via
EXTRACTVALUE), plants the webshell, and prints id / uname -a as asterisk.
With --root it appends to init.conf, triggers the dahdi restart, and prints
uid=0(root) from a SUID bash.
Cleanup (the script reminds you): remove the appended line from
/etc/dahdi/init.conf and delete the docroot drops (webshell, rce_sh,
.rce_root_check).
Unauthenticated remote code execution as asterisk, escalating to root on a
default appliance. Full compromise of the PBX host.
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H (9.8) for the unauthenticated SQLi
to RCE, per the NVD entry for CVE-2025-57819 (confirm against the current NVD
vector).
CWE-89 (SQL injection) leading to CWE-78 (OS command execution).
For authorized security testing and education only. Use this only against systems you own or have explicit written permission to test. The author accepts no liability for misuse.
Dilanka Kaushal Hewage (r3vpwnx)
MIT - see LICENSE.