Vulnerability
Incident response

Fortiweb CVE-2025-25257 - Understanding forensic artifacts

OWN-CERT
-
6/8/2025
OWN analysts explain how to detect malicious activity related to vulnerability CVE-2025-25257.OWN Security

Introduction

A patch for the critical vulnerability CVE-2025-25257 (CVSS score: 9.8) affecting FortiWeb products was released on July 8, 2025. This update applies to the following versions:

  • FortiWeb 7.6: versions 7.6.0 to 7.6.3 → Recommended update: 7.6.4 or later
  • FortiWeb 7.4: versions 7.4.0 to 7.4.7 → Recommended update: 7.4.8 or later
  • FortiWeb 7.2: versions 7.2.0 to 7.2.10 → Recommended update: 7.2.11 or later
  • FortiWeb 7.0: versions 7.0.0 to 7.0.10 → Recommended update: 7.0.11 or later

The vulnerability is initially based on an SQL injection through the /fabric/ API endpoint, allowing arbitrary code execution with a specially crafted request.

In the days following the release of the patch, several proof-of-concept (PoC) exploits were shared by various members of the community, including WatchTowr1 and BigShaq2.

Fortinet’s PSIRT updated the status of the vulnerability on July 18th, 2025, confirming ongoing campaign observed in the wild.

Some of the available PoCs also include usage of CGI scripts (Common Gateway Interface) to trigger the payload and obtain a reverse shell, thereby granting direct access to the compromised system.

Although an administration interface for this type of tool is not supposed to be accessible from the Internet, some instances are available as the Shodan3 search engine shows (2025/07/25):

Figure 1. Exposure of FortiWeb instances on the Internet. Source: Shodan (query: http.html:"FortiWeb")

Artifacts forensic

The following information is based on a FortiWeb instance running version 7.6.1.

Fortinet solutions, such as FortiWeb or FortiGate firewalls, are not always known for being easy to investigate. However, it remains certain artifacts accessible useful for analysis.

In this article, we will review the various sources of evidence that can be leveraged to detect malicious activity related to the CVE-2025-25257 vulnerability, starting with the most volatile elements.

Analysis of Running Processes (Live)

It is possible to analyze the processes running on the instance to search for unusual commands currently in execution. You can detect this activity by using the basic commands available in the FortiOS command‑line interface (/bin/cli). A RAM capture technique could be used, but it requires two prerequisites: successfully performing a RAM dump (hypervisor access) and retrieving the symbol table used by tools such as Volatility to analyze the dump. This capture method will not be covered in this blog post.

After connecting via SSH with an administrator account, the following commands can be used to display the currently running processes:

diagnose system top 

diagnose system ps 

Unlike the ps command, which displays a snapshot of processes at the moment of execution, top provides real-time monitoring updated every few seconds in a dynamic output.

Figure 2. Overview of the initial results from the top command. The malicious process does not appear among the first listed processes.

The top command is not particularly well-suited for analysis, but it is part of the limited set of commands that provide system information. Fortunately, the ps command is also natively available:

Figure 3. Output of the diagnose system ps command

In the red box, you can see the execution of a CGI script (webshell) after it was created as a result of exploiting the vulnerability. Here, it was used to establish a reverse shell. Observing this process indicates that the attacker has remote access to the server.

The native FortiOS CLI includes a few other commands:

  • dump: Dump process kernel stack
  • lsof: List open files
  • trace: Sample process instructions

Few of these provide useful information, although lsof can (as well) reveal a link to /migadmin/cgi-bin/.

Figure 4. Output of the command diagnose process lsof -p 31798 (bash process)

Next, it is possible to identify connections—particularly outbound connections on unusual ports that may indicate active use of a reverse shell—using the native netstat command:

 

diagnose network netstat 

 

Figure 5. Output of the command diagnose network netstat

Among the list of open connections, we can see a suspicious one highlighted in red in the image.

An incoming connection is established (from an internal IP 172.) using a dynamically allocated source port, and the destination is an external IP on the specific port 4000, rather than a randomly assigned return port from the usual ephemeral range (e.g., 40,000–50,000).

Analysis of Web Requests

An Apache service is used on the instance to handle HTTP requests to the administration interface. Access and error logs can be reviewed in the apache_logs/ directory, which contains access.log and error.log.

Figure 6. Example of administrator activity logs – accessing the attack summary dashboard (an .html file) via the UI.

Caracteristics of the vulnerability implies accesses to the path api/fabric/device/status, followed by access to ml-draw.py and the attacker’s crafted CGI file, in this case, “x.cgi” :

Figure 7. Apache logs during the compromise

It may be useful to analyze unique requests to the api/fabric/device/status endpoint to determine whether a simple file exfiltration has occurred. Correlating an access to the vulnerable endpoint with a subsequent access to an exposed file can indicate potential data exfiltration. In the image below, a single request was used to exploit the SQL vulnerability to copy the contents of a file into a new file named bootstrap.css.

Figure 8. File exfiltration via ”bootstrap.css”

The /migadmin/angular/ directory corresponds to the folder used (and exposed) by the portal’s web interface, containing all associated HTML, JS, and CSS files. The attacker then accessed the file through a simple web request 10 seconds later:

Figure 9. Data exfiltration via file copy to the exposed directory

Disk File Analysis

Different directories have been identified where malicious files may be written before being triggered through exploitation of the vulnerability:

  • lib/python3.10/ (mainly .py Python files, replacing legitimate packages)
  • lib/python3.10/site-packages/ (mainly .pth files)
  • /migadmin/cgi_bin/ (.cgi files)

A quick check can be performed from the native FortiOS CLI using the ls command via fnsysctl:

fnsysctl ls –al /migadmin/cgi_bin/ 

Figure 10. Overview of the cgi-bin/ content

In the example above, we can see the x.cgi file that was uploaded by the attacker.

Still using the CLI, and continuing with the file exfiltration example, we can trace this activity by identifying the modified files in the /migadmin/angular/ directory. However, be wary of timestomping attempts on files that an attacker has manipulated:

Figure 11. Analysis of files in /migadmin/angular/, exposed to the Internet

The use of the filename bootstrap.css helps disguise the data exfiltration by using a familiar and legitimate name typically associated with web framework files.

However, with the commands being limited, checking through multiple folders and subfolders can prove particularly time-consuming. Additionally, displaying file contents with the cat command (via fnsysctl cat) didn’t work on the files useful for analysis (the /migadmin/ and /lib/python3.10/ directories for example), and SHA256 hashing functionality is not available on this version of FortiWeb—unlike on other products like FortiGate.

Two solutions exist, depending on the available environment:

  • Develop an internal script to connect to the machine via SSH, list root files, and execute additional commands when folders are detected. This allows the creation of a Forti-specific filesystem map. Only the file path/name, modification date, and permissions will be available.
  • Create a disk image (if the instance is virtualized) to parse the data more easily and gain additional context.

When it comes to calculating file hashes, it is possible to quickly identify suspicious files based on their date, name/extension, and hash:

[root]# find ./lib/python3.10 -type f -exec sha256sum "{}" \; > output.txt
[root]# grep ".pth" output.txt   

e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855  ./lib/python3.10/site-packages/a.pth 2638ce9e2500e572a5e0de7faed6661eb569d1b696fcba07b0dd223da5f5d224  ./lib/python3.10/site-packages/distutils-precedence.pth 1603bfdee834ef511710a4fc9a038f054872aecc0fb4f0988cea540b26aeed45  ./lib/python3.10/site-packages/matplotlib-3.5.2-py3.10-nspkg.pth e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855  ./lib/python3.10/site-packages/x.pth e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855  ./lib/python3.10/z.pth e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855  ./lib/python3.10/y.pth 

Be cautious, however, of false positives (such as distutils-precedence.pth and matplotlib-3.5.2-py3.10-nspkg.pth in this case). The hashes can then be compared against available CTI databases, which may indicate malicious files previously observed in other campaigns.

Detection

Unfortunately, there is no real-time detection method available, as the Apache web logs cannot be forwarded to a SIEM system.

Sources

Footnote

1 Pre-Auth SQL Injection to RCE - Fortinet FortiWeb Fabric Connector (CVE-2025-25257) - https://labs.watchtowr.com/pre-auth-sql-injection-to-rce-fortinet-fortiweb-fabric-connector-cve-2025-25257/

2 FortiWeb CVE-2025-25257 exploit - https://github.com/0xbigshaq/CVE-2025-25257

3 http.html:"FortiWeb" - https://www.shodan.io/search?query=http.html%3A%22FortiWeb%22

Partager l'article :

Your OWN cyber expert.