Description | This article describes how to troubleshoot WAF, collect debug logs and match Event IDs from logs to signatures (main-class). |
Scope | FortiGate. |
Solution
|
In order to use a WAF profile, the related policies should be in proxy mode. That way, the daemon/process responsible for handling this type is WAD.
Example:
Consider an example with a WAF profile configured with the following signatures.
This WAF profile will be used to protect a web server behind FortiGate on the following policy:
To test WAF, a simple SQL Injection attempt will be made using the following URL:
https://site.example.com/index.php?username=1'%20or%20'1'%20=%20'1&password=1'%20or%20'1'%20=%20'1,
On the machine being tested, the following error will appear:
Checking the logs from the FortiGate side will show the following:
If traffic was blocked as seen from the client side, it may seem strange to see a different Event ID on the FortiGate side and with Action passthrough.
First, it is necessary to understand how the signatures are grouped. Checking the 'default' WAF profile on the CLI will show the following:
config waf profile ...
Based on this, it is possible to conclude that the event we saw on the FortiGate (40000163) belongs to main-class 40000000 but the event from the client machine (30000040) belongs to main-class 30000000.
The association between 30000040 and the main-class 30000000 and what the main-class represents:
The 3000040 is a signature that belongs to the main-class 30000000. Regard the main-class as a group.
How to know what signature is 30000040 and if I the right one is being blocked:
Hovering the mouse over one of the signatures in the GUI will show the main-class.
Figure 5:
Figure 6:
Here, 30000040 belongs to the SQL Injection main-class and 40000163 belongs to SQL Injection (Extended).
If more detail is needed from these signatures, check in the CLI:
diagnose waf dump | grep 30000040
diagnose waf dump | grep 40000163
Now that the association between the Event ID, signatures, and main-class is known, perform debugging to see why different Event IDs are observed from the client machine and FortiGate. As mentioned in the start of this article, WAD is the daemon/process that must be debugged to capture the necessary debug logs.
diagnose debug console timestamp en
Below is an example collected from the WAD.
[I]2024-08-12 19:25:42.689695 [p:244][s:92681][r:1] wad_dump_http_request :2569 hreq=0x7ff5cfa0f500 Received request from client: 20.20.20.43:56313 GET /index.php?username=1%27%20or%20%271%27%20=%20%271&password=1%27%20or%20%271%27%20=%20%20%271, HTTP/1.1 [V]2024-08-12 19:25:42.689703 [p:244][s:92681][r:1] wad_http_marker_uri :1260 path=/index.php len=10 ... [I]2024-08-12 19:25:42.690110 [p:244][s:92681][r:1] wad_waf_sig_match_request :414 WAF sig=40000040 sig_flags=0x3 kw_sig_flags=0x403 check_body_args=0 ... [I]2024-08-12 19:25:42.690168 [p:244][s:92681][r:1] wad_waf_sig_match_request :414 WAF sig=40000163 sig_flags=0x3 kw_sig_flags=0x403 check_body_args=0
With this sample we can see that multiple signatures are matched. 40000040, 40000108, 40000163 and 30000040. We can see also that action and severity is using different numbers.
Based on this, it is possible to see that the only signature that was blocked was the one with Event ID 30000040, as seen on the client machine. Notably, the others were not blocked (40000040, 40000108 and 40000163) and the blocked signature (30000040) did not show up in the logs.
Checking the image from Figure 5 or Figure 6 will show that SQL Injection (Extended) - main-class 40000000 - is set to monitor. This explains why signatures from main-class 4000000 were not blocked
As for the log, checking the 'default' WAF profile again will reveal the following:
config waf profile ...
Adjusting the log setting (to enable) will show the block on FortiGate for SQL Injection main-class 30000000.
|
The Fortinet Security Fabric brings together the concepts of convergence and consolidation to provide comprehensive cybersecurity protection for all users, devices, and applications and across all network edges.
Copyright 2025 Fortinet, Inc. All Rights Reserved.