Skip to content
SQL injection Write-up Advanced

FreePBX CVE-2025–57819: From Unauthenticated SQL Injection to Remote Code Execution

An unauthenticated SQL injection in the FreePBX Endpoint module's brand parameter allows an attacker to manipulate the database, insert a record into the cron_jobs table, and achieve remote code execution via scheduled task execution.

Raj Kumar M Follow

Published on medium.com

Freepbx

Raj Kumar M, on medium.com

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 8 min read.

A vulnerability in a PBX system is more than just a web application security issue. A compromised PBX can expose extensions, call-routing information, voicemail, SIP configuration, administrative accounts, and the underlying server itself.

In August 2025, a critical vulnerability was disclosed in the FreePBX Endpoint module. CVE-2025-57819 allows an unauthenticated attacker to exploit SQL injection in the Endpoint module and, through a chain of database manipulation and scheduled task execution, achieve remote code execution.

NVD currently rates the vulnerability 9.8 Critical under CVSS 3.1 and records a 10.0 Critical CVSS 4.0 score from the CNA. The vulnerability is associated with CWE-89 (SQL Injection) and CWE-288 (Authentication Bypass Using an Alternate Path or Channel). It is also listed in CISA's Known Exploited Vulnerabilities catalogue.

Context

FreePBX is an open-source, web-based graphical management interface for Asterisk. Asterisk provides the underlying PBX and VoIP functionality, while FreePBX provides a web interface through which administrators can configure and manage that functionality.

For example, administrators can use FreePBX to manage:

  • Extensions
  • SIP devices
  • Trunks
  • Call routing
  • IVR
  • Voicemail
  • Ring groups
  • Conferences
  • Endpoint provisioning

A simplified architecture looks like this:

Text
                    Administrator
                          |
                          v
                  FreePBX Web Interface
                          |
                          v
                    Apache / PHP
                          |
              +-----------+-----------+
              |                       |
              v                       v
       FreePBX Framework          FreePBX Modules
                                      |
                                      v
                               Endpoint Manager
                                      |
                                      v
                               MariaDB / MySQL
                                      |
                                      v
                                   Asterisk

The important part for this vulnerability is the modular architecture. FreePBX functionality is divided into modules, and the Endpoint module provides functionality related to managing and provisioning supported VoIP endpoints. This module is at the center of CVE-2025-57819.

Setup

The report describes testing in an authorised lab environment. It does not name specific lab versions beyond the affected ranges below, and it does not describe accounts or roles used.

The affected Endpoint versions are:

Text
FreePBX 15  → versions before 15.0.66
FreePBX 16  → versions before 16.0.89
FreePBX 17  → versions before 17.0.3

The corresponding fixed versions are:

Text
15.0.66
16.0.89
17.0.3

These versions are documented by NVD and the FreePBX security advisory.

Finding it

CVE-2025-57819 affects the FreePBX Endpoint module. The vulnerability is caused by insufficient sanitisation of user-supplied data. Under affected configurations, an attacker can reach the vulnerable functionality without normal authentication and use SQL injection to manipulate database content. The official vulnerability description summarises the impact as:

Text
Unauthenticated Access
        |
        v
Database Manipulation
        |
        v
Remote Code Execution

The vulnerable functionality is associated with the Endpoint module. The main HTTP entry point involved in the attack is:

Text
/admin/ajax.php

However, /admin/ajax.php is not itself the vulnerable SQL function. It acts as an AJAX dispatcher. The request specifies the Endpoint module through the module parameter. The important value is:

Text
FreePBX\modules\endpoint\ajax

Therefore, the request flow can be represented as:

Text
HTTP Request
     |
     v
/admin/ajax.php
     |
     | module=FreePBX\modules\endpoint\ajax
     v
Endpoint AJAX Handler
     |
     v
Input Processing
     |
     v
Database Query

The relevant module is located under:

Text
/admin/modules/endpoint/

with the AJAX implementation under:

Text
/admin/modules/endpoint/ajax.php

This distinction is important when analysing the source code.

A simplified request looks like this:

Text
POST /admin/ajax.php

with parameters such as:

Text
module=FreePBX\modules\endpoint\ajax
command=model
template=x
model=model
brand=<user-controlled input>

The complete flow can be represented as:

Text
/admin/ajax.php
      |
      v
module=FreePBX\modules\endpoint\ajax
      |
      v
command=model
      |
      v
brand=<input>
      |
      v
Endpoint functionality
      |
      v
SQL processing

The parameter that becomes particularly interesting during SQL injection testing is brand. It is processed by the Endpoint functionality.

From a security-testing perspective, the question is whether the input is treated purely as data or whether it can influence the SQL statement. The expected secure flow would be:

Text
User Input
    |
    v
Validation
    |
    v
Prepared SQL Statement
    |
    v
Database

The vulnerable behaviour allows attacker-controlled input to reach SQL processing in an unsafe way:

Text
User Input
    |
    v
brand
    |
    v
Endpoint AJAX Handler
    |
    v
SQL Processing
    |
    v
Database

That creates the SQL injection primitive.

Exploitation

Step 1: Confirm the SQL injection with a time-based test

Before attempting to demonstrate the full impact, the researcher first wanted to establish whether the brand parameter was actually influencing SQL execution. For this purpose, a time-based SQL injection can be used in an authorised lab. A controlled test introduces a database-side delay:

Text
brand=x' ;SELECT SLEEP(5); --

The concept is straightforward. A normal request should return quickly:

Text
Normal Request
      |
      v
SQL Query
      |
      v
Fast Response

A request that causes the database to execute the delay should take significantly longer:

Text
Injected Request
      |
      v
SQL Query
      |
      v
SLEEP(5)
      |
      v
Delayed Response

The request used for the measurement:

Bash
curl -s -o /dev/null -w 'sleep5 POST: %{time_total}s\n' -X POST \
'http://<LAB-HOST>/admin/ajax.php?module=FreePBX%5Cmodules%5Cendpoint%5Cajax&command=model&template=x&model=model&brand=x%27%20%3BSELECT%20SLEEP(5)%3B%20--%20' \
-H 'X-Requested-With: XMLHttpRequest' \
-H 'Origin: http://<LAB-HOST>' \
-H 'Referer: http://<LAB-HOST>/admin/config.php'

The important portion is: brand=x' ;SELECT SLEEP(5); --

From the original on medium.com

The response-time difference provides evidence that the supplied input is reaching SQL processing. At this point, the first major component is established:

Text
Attacker-Controlled Input
          |
          v
     brand parameter
          |
          v
     SQL Injection

But SQL injection is not the end of the story. The next question is what the attacker can do with the database access obtained through this vulnerability.

Step 2: Move from SQL injection to database manipulation

SQL injection becomes much more serious when the compromised database contains functionality that can influence application behaviour. The high-level chain is:

Text
SQL Injection
      |
      v
Database Manipulation
      |
      v
Application-Controlled Data
      |
      v
Further Exploitation

During analysis of the FreePBX environment, the cron_jobs functionality becomes particularly interesting. The reason is simple:

Text
Database
   |
   v
cron_jobs
   |
   v
FreePBX Scheduled Task
   |
   v
Command Execution

This creates a bridge between the database and operating-system-level execution. The exploitation path uses the SQL injection to insert a row into the cron_jobs table, with the scheduled job then executing a supplied command.

A database table normally contains data. But if application logic treats database records as instructions, modifying those records can become much more powerful. In this case:

Text
SQL Injection
      |
      v
Insert cron_jobs record
      |
      v
FreePBX processes the record
      |
      v
Scheduled command execution

This is the point where the SQL injection can be chained toward code execution. The important security concept is that the database is not only storing information; certain database records influence what the application executes.

Step 3: Scheduled execution

At a high level, the attack becomes:

Text
                   SQL Injection
                          |
                          v
                  Database INSERT
                          |
                          v
                     cron_jobs
                          |
                          v
                  Scheduled Task
                          |
                          v
                   Command Execution

In the authorised lab environment, this behaviour was used to demonstrate the next stage of the attack chain.

From the original on medium.com

This demonstrates that the vulnerability is capable of going beyond simply reading database information.

Step 4: From scheduled execution to RCE

Once attacker-controlled data reaches a mechanism capable of executing commands, the exploitation chain reaches its final stage. The simplified chain is:

Text
SQL Injection
      |
      v
Database Manipulation
      |
      v
Scheduled Execution
      |
      v
Command Execution
      |
      v
Remote Code Execution

At this point, the attacker is no longer limited to manipulating database content. The underlying server can potentially be controlled through the resulting execution primitive.

From the original on medium.com

For validation in an authorised lab, a harmless command such as hostname or id can be used to demonstrate that execution has reached the underlying operating system.

Complete attack chain

Text
              CVE-2025-57819
                     |
                     v
          Unauthenticated Access
                     |
                     v
              /admin/ajax.php
                     |
                     v
       Endpoint AJAX Module
                     |
                     v
              brand parameter
                     |
                     v
              SQL Injection
                     |
                     v
         Database Manipulation
                     |
                     v
                cron_jobs
                     |
                     v
          Scheduled Execution
                     |
                     v
           Command Execution
                     |
                     v
                    RCE

Root cause

The vulnerability is caused by insufficient sanitisation of user-supplied data in the Endpoint module. The brand parameter, processed by the Endpoint functionality reached through the AJAX dispatcher at /admin/ajax.php, is not kept separate from the SQL statement, so attacker-controlled input reaches SQL processing in an unsafe way instead of being bound as data in a prepared statement.

The second half of the chain is that FreePBX treats records in the cron_jobs table as instructions. A record inserted through the SQL injection is later processed as a scheduled task and its command is executed, which turns write access to that table into operating-system command execution.

The CVE is associated with CWE-288 (Authentication Bypass Using an Alternate Path or Channel).

Impact

Under affected configurations, an unauthenticated attacker can use the SQL injection to manipulate database content, insert a record into cron_jobs, and have the scheduled task execute a supplied command, reaching remote code execution on the underlying server. Because a PBX concentrates call-routing information, voicemail, SIP configuration and administrative accounts, compromise of the server exposes all of that.

The report hedges the final stage: the underlying server can potentially be controlled through the resulting execution primitive.

Fix

Upgrade the Endpoint module to one of the fixed versions:

Text
15.0.66
16.0.89
17.0.3

These are the versions documented by NVD and the FreePBX security advisory.

Variants to test

  1. Other Endpoint commands. The dispatcher takes command=model alongside module=FreePBX\modules\endpoint\ajax. Try other command values handled by the Endpoint AJAX handler with the same brand payload; a positive result is the same measurable SLEEP(5) delay.
  2. Other Endpoint parameters. The request also carries template and model. Send the time-based payload in each of them in turn; a positive result is a response delayed by roughly the injected interval while a normal request returns quickly.
  3. Other modules through the same dispatcher. /admin/ajax.php selects the handler through module. Point it at other modules' AJAX classes and repeat the time-based test on their string parameters; a positive result is the same delay pattern.
  4. Other tables consumed as instructions. The cron_jobs bridge works because FreePBX executes records as tasks. Look for other tables whose rows are later interpreted as commands or configuration by scheduled or background processing, and check whether the injection can write to them; a positive result is a harmless command such as hostname or id appearing in its output.
  5. Unauthenticated reachability. Repeat the confirmed time-based request without any session; a positive result is the same delay, confirming the alternate-path access described by CWE-288.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 19 min read.

What happened, in plain words

Imagine the phone system of a company. It is not just a box that makes phones ring. It holds the list of every extension, the rules for where calls go, the voicemail of every employee, the settings that connect the company to the outside telephone network, and the login details of the people who administer all of it. If someone takes control of that system, they get all of that at once, and possibly the computer it runs on too.

In August 2025, a serious flaw was disclosed in a piece of software called FreePBX, specifically in one of its parts called the Endpoint module. The flaw has an identifier, CVE-2025-57819. An attacker who has never logged in can send a specially crafted request to the web interface, and that request can slip instructions into the database behind the system. From there, the attacker can plant a record that the system later treats as a scheduled job, and that job runs a command on the server. The end result is remote code execution: the attacker can make the server run commands of their choosing.

The National Vulnerability Database (NVD) rates it 9.8 Critical under CVSS 3.1, and the CNA records a 10.0 Critical score under CVSS 4.0. It is associated with CWE-89 (SQL Injection) and CWE-288 (Authentication Bypass Using an Alternate Path or Channel), and it appears in CISA's Known Exploited Vulnerabilities catalogue, which is a public list of flaws known to be used in real attacks.

This article walks through the whole chain slowly, from the first harmless-looking request to the final command execution, explaining every term as it appears.

What FreePBX is

FreePBX is an open-source, web-based graphical management interface for Asterisk. That sentence contains two products, so let us unpack it.

A PBX (Private Branch Exchange) is the telephone system inside an organisation. It is what connects internal phones to each other and to the public phone network. Asterisk is the software that does the actual telephone work: it handles calls, connects them, plays voicemail greetings, and so on.

Asterisk on its own is configured through text files, which is not friendly for most administrators. FreePBX sits on top of it and gives you a web page, in a browser, where you click and fill in forms instead of editing files. When you save a form, FreePBX writes the corresponding configuration for Asterisk.

Through FreePBX, administrators can manage:

  • Extensions (the internal numbers people dial)
  • SIP devices (the phones and softphones that register with the system)
  • Trunks (the connections to the outside telephone network)
  • Call routing (which call goes where)
  • IVR (the automated menus that say "press 1 for sales")
  • Voicemail
  • Ring groups (several phones ringing together)
  • Conferences
  • Endpoint provisioning (setting up the physical phones automatically)

A simplified picture of how the pieces fit together:

Text
                    Administrator
                          |
                          v
                  FreePBX Web Interface
                          |
                          v
                    Apache / PHP
                          |
              +-----------+-----------+
              |                       |
              v                       v
       FreePBX Framework          FreePBX Modules
                                      |
                                      v
                               Endpoint Manager
                                      |
                                      v
                               MariaDB / MySQL
                                      |
                                      v
                                   Asterisk

Read it from the top. The administrator uses a browser to reach the FreePBX web interface. That interface is served by Apache, a web server program, and written in PHP, a programming language commonly used for websites. Apache hands the request to PHP code. That code is split into a framework (the shared plumbing) and modules (separate packages, each adding one area of functionality). One of those modules is the Endpoint Manager. The modules talk to a database, here MariaDB / MySQL, which stores all the settings. Finally, Asterisk reads that configuration and runs the phone system.

The important part for this vulnerability is that FreePBX is built in a modular way. Each area of functionality is a separate module, and the Endpoint module is the one that deals with managing and provisioning supported VoIP endpoints. That module is at the centre of CVE-2025-57819.

What CVE-2025-57819 is

CVE-2025-57819 affects the FreePBX Endpoint module. The cause is insufficient sanitisation of user-supplied data. Sanitisation means cleaning input before using it: checking that what a user typed is what you expected, and neutralising anything dangerous. When that cleaning is missing, input that was meant to be a simple value can be interpreted as part of a command.

Under affected configurations, an attacker can reach the vulnerable functionality without normal authentication, meaning without logging in, and use SQL injection to manipulate database content. The official vulnerability description summarises the impact as:

Text
Unauthenticated Access
        |
        v
Database Manipulation
        |
        v
Remote Code Execution

Three stages, top to bottom. Unauthenticated access means getting in without a username and password. Database manipulation means changing what is stored in the database. Remote code execution (RCE) means making the server run code or commands that the attacker chose, from a distance.

The CVE is associated with two weakness categories:

CWE-89, SQL Injection, and CWE-288, Authentication Bypass Using an Alternate Path or Channel. A CWE is a standard catalogue entry describing a class of weakness. We will explain SQL injection in detail below; CWE-288 means the vulnerable functionality can be reached through a different route than the normal login-protected one.

The affected Endpoint versions are:

Text
FreePBX 15  → versions before 15.0.66
FreePBX 16  → versions before 16.0.89
FreePBX 17  → versions before 17.0.3

This is read as: if you run FreePBX 15 and your Endpoint module is older than 15.0.66, you are affected; the same logic applies to 16 and 17. The corresponding fixed versions are:

Text
15.0.66
16.0.89
17.0.3

These versions are documented by NVD and the FreePBX security advisory.

Where the vulnerability lives

The vulnerable functionality is in the Endpoint module. The main HTTP entry point involved in the attack is:

Text
/admin/ajax.php

An HTTP entry point is simply a URL that the web server accepts requests on. HTTP is the language browsers and servers use to talk to each other. /admin/ajax.php is a PHP file in the admin folder of the website.

However, /admin/ajax.php is not itself the vulnerable SQL function. It acts as an AJAX dispatcher. AJAX is the technique web pages use to fetch or send data in the background, without reloading the whole page; when you type in a search box and suggestions appear without the page blinking, that is AJAX. A dispatcher is a switchboard: one front door that looks at the request and forwards it to the right internal handler, like a receptionist sending a visitor to the correct department.

The request specifies the Endpoint module through the module parameter. A parameter is a named value sent with a request, like a field in a form. The important value here is:

Text
FreePBX\modules\endpoint\ajax

This is the internal name of the Endpoint module's AJAX handler. The backslashes are separators in a naming scheme, similar to folders in a path.

So the request flow can be represented as:

Text
HTTP Request
     |
     v
/admin/ajax.php
     |
     | module=FreePBX\modules\endpoint\ajax
     v
Endpoint AJAX Handler
     |
     v
Input Processing
     |
     v
Database Query

A request arrives at the dispatcher. The dispatcher reads the module parameter and forwards the request to the Endpoint AJAX handler. That handler processes the input and builds a database query. A database query is a question or instruction sent to the database, written in a language called SQL.

The relevant module is located under:

Text
/admin/modules/endpoint/

with the AJAX implementation under:

Text
/admin/modules/endpoint/ajax.php

This distinction matters when analysing the source code: the file at /admin/ajax.php is the front door, and the file at /admin/modules/endpoint/ajax.php is the room behind it where the actual work happens.

A simplified request looks like this:

Text
POST /admin/ajax.php

POST is one of the HTTP methods; it is used when you send data to the server, as opposed to GET, which is used when you simply ask for a page. The request carries parameters such as:

Text
module=FreePBX\modules\endpoint\ajax
command=model
template=x
model=model
brand=<user-controlled input>

Each line is a name and a value. module picks the handler. command=model tells the handler which operation to perform. template and model are further values the handler expects. brand=<user-controlled input> is the interesting one: user-controlled input means a value that the person sending the request can set to anything they like.

The complete flow can be represented as:

Text
/admin/ajax.php
      |
      v
module=FreePBX\modules\endpoint\ajax
      |
      v
command=model
      |
      v
brand=<input>
      |
      v
Endpoint functionality
      |
      v
SQL processing

The request hits the dispatcher, which selects the Endpoint module, which runs the model command, which uses the brand value, which ends up in SQL processing.

The parameter that becomes particularly interesting during SQL injection testing is brand. It is processed by the Endpoint functionality.

From a security-testing perspective, the question is whether the input is treated purely as data or whether it can influence the SQL statement. Think of a SQL statement as a sentence and the input as a word inserted into it. If the input is treated as data, it stays a word inside the sentence. If it is not, the input can add its own words and change the meaning of the sentence.

The expected secure flow would be:

Text
User Input
    |
    v
Validation
    |
    v
Prepared SQL Statement
    |
    v
Database

Validation is checking the input. A prepared statement is a way of building a SQL query where the structure is fixed first and the values are attached separately afterwards, so a value can never be mistaken for part of the instruction. It is like a form with blanks: whatever you write in a blank stays in the blank.

The vulnerable behaviour allows attacker-controlled input to reach SQL processing in an unsafe way:

Text
User Input
    |
    v
brand
    |
    v
Endpoint AJAX Handler
    |
    v
SQL Processing
    |
    v
Database

Here the input goes straight into the query text, with no separation. That creates the SQL injection primitive. A primitive in security means a basic capability you have obtained, which you can then build on.

Step 1: Confirming the SQL injection with a time-based test

Before attempting to demonstrate the full impact, the researcher first wanted to establish whether the brand parameter was actually influencing SQL execution. This is a sensible order of work: prove the small thing before claiming the big thing.

For this purpose, a time-based SQL injection can be used in an authorised lab. A time-based test asks the database to wait, and then you measure how long the response took. It simply asks the database to wait, and then you measure how long the response took. If the response is slow by exactly the amount you asked for, you know your input reached the database as an instruction. An authorised lab is a test environment the researcher is allowed to attack, typically a copy they set up themselves.

A controlled test introduces a database-side delay:

Text
brand=x' ;SELECT SLEEP(5); --

Let us take this apart character by character, because every piece has a purpose.

  • brand= is the parameter name, the blank being filled in.
  • x is an ordinary value, so the query starts out looking normal.
  • ' is a single quote. In SQL, text values are wrapped in single quotes. Closing the quote early ends the text value the application started, so whatever comes next is no longer inside the text.
  • ; is a semicolon, which in SQL ends one statement and allows another to begin.
  • SELECT SLEEP(5); is a complete SQL statement that asks the database to pause for five seconds. SLEEP is a built-in function that waits.
  • -- starts a comment in SQL. Everything after it is ignored, which neatly disposes of whatever the application had written after our input, so the query does not break.

The concept is straightforward. A normal request should return quickly:

Text
Normal Request
      |
      v
SQL Query
      |
      v
Fast Response

A request that causes the database to execute the delay should take significantly longer:

Text
Injected Request
      |
      v
SQL Query
      |
      v
SLEEP(5)
      |
      v
Delayed Response

The request used for the measurement:

Bash
curl -s -o /dev/null -w 'sleep5 POST: %{time_total}s\n' -X POST \
'http://<LAB-HOST>/admin/ajax.php?module=FreePBX%5Cmodules%5Cendpoint%5Cajax&command=model&template=x&model=model&brand=x%27%20%3BSELECT%20SLEEP(5)%3B%20--%20' \
-H 'X-Requested-With: XMLHttpRequest' \
-H 'Origin: http://<LAB-HOST>' \
-H 'Referer: http://<LAB-HOST>/admin/config.php'

Line by line:

  • curl is a command-line tool that sends HTTP requests. It is the browser equivalent of typing a URL, but with full control over every detail.
  • -s means silent: do not print progress noise.
  • -o /dev/null throws away the response body. We do not care what the page says; we only care how long it took.
  • -w 'sleep5 POST: %{time_total}s\n' prints a custom line after the request finishes. %{time_total} is a placeholder that curl replaces with the total time in seconds, and \n ends the line. This is the stopwatch.
  • -X POST says use the POST method.
  • The long quoted string is the URL. Inside it, %5C is the URL encoding of a backslash, %27 is a single quote, %20 is a space, and %3B is a semicolon. URL encoding is how special characters are written so they survive being placed in a URL; a browser does this for you automatically. Decoded, the brand value is exactly x' ;SELECT SLEEP(5); --.
  • -H 'X-Requested-With: XMLHttpRequest' adds a header. Headers are extra pieces of information sent alongside a request, like the label on a parcel. This particular header tells the server the request came from a background AJAX call, which is what the real web page would send.
  • -H 'Origin: http://<LAB-HOST>' says which site the request originates from. Browsers send this automatically; curl does not, so it is added by hand to look like a normal browser request.
  • -H 'Referer: http://<LAB-HOST>/admin/config.php' says which page the request came from. Again, a browser sends this by itself; adding it makes the request resemble one a logged-in administrator's browser would produce.

The important portion is: brand=x' ;SELECT SLEEP(5); --

From the original on medium.com

That response-time difference provides evidence that the supplied input is reaching SQL processing. At this point, the first major component is established:

Text
Attacker-Controlled Input
          |
          v
     brand parameter
          |
          v
     SQL Injection

But SQL injection is not the end of the story. The next question is what the attacker can do with the database access obtained through this vulnerability.

Step 2: From SQL injection to database manipulation

SQL injection becomes much more serious when the compromised database contains functionality that can influence application behaviour. The high-level chain is:

Text
SQL Injection
      |
      v
Database Manipulation
      |
      v
Application-Controlled Data
      |
      v
Further Exploitation

In other words: first you can inject, then you can change stored data, then the application reads that data and behaves differently, and from there you can go further.

During analysis of the FreePBX environment, the cron_jobs functionality becomes particularly interesting. cron is the traditional name for the part of an operating system that runs tasks on a schedule: every minute, every hour, every night. A cron job is one such scheduled task. FreePBX keeps its scheduled tasks in a database table called cron_jobs. A table is how a database organises data: rows and columns, like a spreadsheet. A row is one record in that table.

The reason this matters is simple:

Text
Database
   |
   v
cron_jobs
   |
   v
FreePBX Scheduled Task
   |
   v
Command Execution

The database holds the cron_jobs table. FreePBX reads that table and treats its rows as scheduled tasks. A scheduled task runs a command. So a row in that table is effectively a command waiting to happen.

This creates a bridge between the database and operating-system-level execution. The exploitation path uses the SQL injection to insert a row into the cron_jobs table, with the scheduled job then executing a supplied command.

A database table normally contains data. But if application logic treats database records as instructions, modifying those records can become much more powerful. Compare it to a noticeboard: normally it just displays notes, but if the building manager reads every note as an instruction and carries it out, then anyone who can pin a note to the board can give orders. In this case:

Text
SQL Injection
      |
      v
Insert cron_jobs record
      |
      v
FreePBX processes the record
      |
      v
Scheduled command execution

This is the point where the SQL injection can be chained toward code execution. The important security concept is that the database is not only storing information; certain database records influence what the application executes.

Step 3: Scheduled execution

At a high level, the attack becomes:

Text
                   SQL Injection
                          |
                          v
                  Database INSERT
                          |
                          v
                     cron_jobs
                          |
                          v
                  Scheduled Task
                          |
                          v
                   Command Execution

An INSERT is the SQL instruction that adds a new row to a table. So the injection is used to add a row to cron_jobs, FreePBX picks that row up as a scheduled task, and the task runs a command.

In the authorised lab environment, this behaviour was used to demonstrate the next stage of the attack chain.

From the original on medium.com

This demonstrates that the vulnerability is capable of going beyond simply reading database information.

Step 4: From scheduled execution to RCE

Once attacker-controlled data reaches a mechanism capable of executing commands, the exploitation chain reaches its final stage. The simplified chain is:

Text
SQL Injection
      |
      v
Database Manipulation
      |
      v
Scheduled Execution
      |
      v
Command Execution
      |
      v
Remote Code Execution

At this point, the attacker is no longer limited to manipulating database content. The underlying server can potentially be controlled through the resulting execution primitive.

From the original on medium.com

For validation in an authorised lab, a harmless command such as hostname or id can be used to demonstrate that execution has reached the underlying operating system. hostname prints the name of the machine, and id prints which user the command is running as. Both are harmless: they only report information, they change nothing. That is exactly why they are good proof: if their output comes back, you know commands are running, without causing any damage.

The complete attack chain

Putting every stage together:

Text
              CVE-2025-57819
                     |
                     v
          Unauthenticated Access
                     |
                     v
              /admin/ajax.php
                     |
                     v
       Endpoint AJAX Module
                     |
                     v
              brand parameter
                     |
                     v
              SQL Injection
                     |
                     v
         Database Manipulation
                     |
                     v
                cron_jobs
                     |
                     v
          Scheduled Execution
                     |
                     v
           Command Execution
                     |
                     v
                    RCE

Read from the top: the flaw lets someone in without logging in, through the dispatcher at /admin/ajax.php, which forwards to the Endpoint AJAX module, which uses the brand parameter, which is injectable, which allows changing the database, which allows adding a row to cron_jobs, which is run as a scheduled task, which executes a command, which is remote code execution.

Why it happens

The vulnerability is caused by insufficient sanitisation of user-supplied data in the Endpoint module. The brand parameter, processed by the Endpoint functionality reached through the AJAX dispatcher at /admin/ajax.php, is not kept separate from the SQL statement, so attacker-controlled input reaches SQL processing in an unsafe way instead of being bound as data in a prepared statement.

The second half of the chain is that FreePBX treats records in the cron_jobs table as instructions. A record inserted through the SQL injection is later processed as a scheduled task and its command is executed, which turns write access to that table into operating-system command execution.

The CVE is associated with CWE-288 (Authentication Bypass Using an Alternate Path or Channel).

What the impact is

Under affected configurations, an unauthenticated attacker can use the SQL injection to manipulate database content, insert a record into cron_jobs, and have the scheduled task execute a supplied command, reaching remote code execution on the underlying server. Because a PBX concentrates call-routing information, voicemail, SIP configuration and administrative accounts, compromise of the server exposes all of that.

The report hedges the final stage: the underlying server can potentially be controlled through the resulting execution primitive.

How to fix it

Upgrade the Endpoint module to one of the fixed versions:

Text
15.0.66
16.0.89
17.0.3

These are the versions documented by NVD and the FreePBX security advisory.

Other things worth testing

  1. Other Endpoint commands. The dispatcher takes command=model alongside module=FreePBX\modules\endpoint\ajax. Try other command values handled by the Endpoint AJAX handler with the same brand payload; a positive result is the same measurable SLEEP(5) delay.
  2. Other Endpoint parameters. The request also carries template and model. Send the time-based payload in each of them in turn; a positive result is a response delayed by roughly the injected interval while a normal request returns quickly.
  3. Other modules through the same dispatcher. /admin/ajax.php selects the handler through module. Point it at other modules' AJAX classes and repeat the time-based test on their string parameters; a positive result is the same delay pattern.
  4. Other tables consumed as instructions. The cron_jobs bridge works because FreePBX executes records as tasks. Look for other tables whose rows are later interpreted as commands or configuration by scheduled or background processing, and check whether the injection can write to them; a positive result is a harmless command such as hostname or id appearing in its output.
  5. Unauthenticated reachability. Repeat the confirmed time-based request without any session; a positive result is the same delay, confirming the alternate-path access described by CWE-288.

Glossary

  • AJAX: a technique where a web page exchanges data with the server in the background, without reloading the whole page.
  • Apache: a widely used web server program that receives HTTP requests and passes them to application code.
  • Asterisk: open-source software that provides the actual telephone (PBX and VoIP) functionality.
  • Authentication: proving who you are, usually with a username and password.
  • Authorised lab: a test environment the researcher is permitted to attack, typically one they control.
  • CISA: the US Cybersecurity and Infrastructure Security Agency, which publishes the Known Exploited Vulnerabilities catalogue.
  • CNA: CVE Numbering Authority, an organisation authorised to assign CVE identifiers and scores.
  • Command execution: making a computer run an operating-system command.
  • cron job: a task an operating system runs automatically on a schedule.
  • cron_jobs: the FreePBX database table that holds its scheduled tasks.
  • curl: a command-line tool for sending HTTP requests with full control over method, URL and headers.
  • CVE: a public identifier for a specific disclosed vulnerability.
  • CVSS: a standard scoring system for the severity of a vulnerability.
  • CWE: a catalogue entry describing a class of software weakness.
  • CWE-89: the catalogue entry for SQL Injection.
  • CWE-288: the catalogue entry for Authentication Bypass Using an Alternate Path or Channel.
  • Database: organised storage for data, queried with SQL.
  • Database query: an instruction or question sent to a database in SQL.
  • Dispatcher: a single entry point that forwards a request to the correct internal handler.
  • Endpoint: a device or software phone that connects to the phone system; the Endpoint module manages them.
  • Extension: an internal telephone number within an organisation.
  • FreePBX: an open-source web interface for managing an Asterisk phone system.
  • Header: extra information sent alongside an HTTP request or response, such as the origin or the type of client.
  • HTTP: the protocol browsers and servers use to exchange requests and responses.
  • INSERT: the SQL instruction that adds a new row to a table.
  • IVR: an automated phone menu that lets callers choose options.
  • MariaDB / MySQL: database server software.
  • Module: a self-contained package of functionality within a larger application.
  • NVD: the National Vulnerability Database, which records and scores vulnerabilities.
  • Parameter: a named value sent with a request, like a form field.
  • PBX: Private Branch Exchange, the telephone system inside an organisation.
  • PHP: a programming language commonly used to build websites.
  • POST: an HTTP method used to send data to a server.
  • Prepared statement: a way of building a SQL query so that values are attached separately and can never be read as instructions.
  • Primitive: a basic capability obtained during an attack, which can be built upon.
  • Remote code execution (RCE): making a remote server run code or commands chosen by the attacker.
  • Row: one record in a database table.
  • Sanitisation: cleaning and checking user input so dangerous content cannot be interpreted as instructions.
  • SIP: the protocol used for setting up and managing VoIP calls.
  • SLEEP: a SQL function that pauses the database for a given number of seconds.
  • SQL: the language used to query and modify databases.
  • SQL injection: a flaw where user input is interpreted as part of a SQL statement, letting an attacker change the query.
  • Table: a set of rows and columns in a database, like a spreadsheet.
  • Time-based SQL injection: a test that proves injection by making the database wait and measuring the response time.
  • Trunk: a connection between the phone system and the outside telephone network.
  • Unauthenticated access: reaching functionality without logging in.
  • URL encoding: writing special characters in a URL in a safe form, such as %27 for a single quote.
  • Validation: checking that input matches what is expected before using it.
  • VoIP: Voice over IP, carrying telephone calls over a data network.
  • Voicemail: recorded messages left when a call is not answered.

More by Raj Kumar M

View all

2 more disclosed reports, best first.

Similar reports

View all

Same bug class and techniques, clearest first.

SQL injection

The lesson behind this report.

Input reaches a database query as code, letting an attacker read or change data the application never meant to expose.