Skip to content
SQL injection Write-up Advanced

CVE-2025–25257: FortiWeb SQL Injection to RCE Exposed

An unauthenticated SQL injection in FortiWeb's Fabric Connector allows attackers to inject SQL via the Authorization Bearer header, bypass authentication, and escalate to remote code execution with root privileges by writing a malicious Python .pth file.

medium.com

Published on medium.com

On July 8, 2025, Fortinet disclosed CVE-2025–25257, a severe SQL injection vulnerability in their FortiWeb web application firewall. This unauthenticated flaw allows attackers to execute arbitrary code with root privileges, posing a massive risk to organizations.

Kalariya Het, 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.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the get_fabric_user_by_token function concatenates unsanitised input from the Authorization Bearer header directly into an SQL query instead of using prepared statements.

Impact

An unauthenticated attacker could gain root-level code execution on the FortiWeb appliance, enabling backdoors, data exfiltration, and lateral movement; public PoCs and active exploitation are reported.

What the attacker needed

Network access to the FortiWeb admin interface; unpatched FortiWeb version

The fix

The vulnerability was fixed in patched versions that use prepared statements (mysql_stmt_prepare), and users should upgrade immediately.

How it was found

  1. Send a crafted HTTP request to the vulnerable endpoint /api/fabric/device/status.
  2. Inject an SQL payload via the Authorization Bearer header to manipulate database queries.
  3. Escalate to RCE using MySQL's INTO OUTFILE to write a malicious .pth file into a Python site-packages directory.
  4. The written .pth file is executed by /cgi-bin/ml-draw.py, granting root access.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

A web application firewall (FortiWeb) has a login check that builds a database query using text from an HTTP header without cleaning it. An attacker can send a special header value that changes the query, skip the login, and then use the database to write a file that the server later runs as root. This means an unauthenticated attacker can take full control of the device.

What is SQL injection?

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

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.