Skip to content

Commit 3db6b28

Browse files
authored
[WAF] Update payload logging (#22291)
1 parent 89d03e0 commit 3db6b28

File tree

5 files changed

+69
-10
lines changed

5 files changed

+69
-10
lines changed
-78.4 KB
Loading
-84.4 KB
Loading

src/content/docs/waf/managed-rules/payload-logging/decrypt-in-logs.mdx

Lines changed: 64 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,13 @@ title: Store decrypted matched payloads in logs
33
pcx_content_type: how-to
44
sidebar:
55
order: 5
6-
76
---
87

9-
import { GlossaryTooltip } from "~/components"
8+
import { GlossaryTooltip, RuleID } from "~/components";
109

1110
You can include the encrypted matched payload in your [Logpush](/logs/about/) jobs by adding the **General** > [**Metadata**](/logs/reference/log-fields/zone/firewall_events/#metadata) field from the Firewall Events dataset to your job.
1211

13-
The payload, in its encrypted form, is available in the `encrypted_matched_data` property of the `Metadata` field.
12+
The payload, in its encrypted form, is available in the [`encrypted_matched_data` property](#structure-of-encrypted_matched_data-property-in-logpush) of the `Metadata` field.
1413

1514
However, you may want to decrypt the matched payload before storing the logs in your <GlossaryTooltip term="SIEM">SIEM system</GlossaryTooltip> of choice. Cloudflare provides a [sample Worker project](https://github.com/cloudflare/matched-data-worker) on GitHub that does the following:
1615

@@ -21,3 +20,65 @@ However, you may want to decrypt the matched payload before storing the logs in
2120
You will need to make some changes to the sample project to push the logs containing decrypted payload data to your log storage system.
2221

2322
Refer to the Worker project's [README](https://github.com/cloudflare/matched-data-worker/blob/main/README.md) for more information on configuring and deploying this Worker project.
23+
24+
## Structure of `encrypted_matched_data` property in Logpush
25+
26+
Matched payload information includes the specific string that triggered a rule, along with some text that appears immediately before and after the matched string.
27+
28+
Once you decrypt its value, the `encrypted_matched_data` property of the `Metadata` field in Logpush has a structure similar to the following:
29+
30+
```json
31+
{
32+
// for fields with only one match (such as URI or user agent fields):
33+
"<match_location>": {
34+
"before": "<text_before_match>",
35+
"content": "<matched_text>",
36+
"after": "<text_after_match>"
37+
},
38+
// for fields with possible multiple matches (such as form, header, or body fields):
39+
"<match_location>": [
40+
{
41+
"before": "<text_before_match_1>",
42+
"content": "<matched_text_1>",
43+
"after": "<text_after_match_1>"
44+
},
45+
{
46+
"before": "<text_before_match_2>",
47+
"content": "<matched_text_2>",
48+
"after": "<text_after_match_2>"
49+
}
50+
]
51+
}
52+
```
53+
54+
The `before` and `after` properties are optional (there may be no content before/after the matched text) and will contain at most 15 bytes of content appearing before and after the match.
55+
56+
Below are a few examples of payload matches:
57+
58+
```json title="URI match"
59+
{
60+
"http.request.uri": {
61+
"before": "/admin",
62+
"content": "/.git/",
63+
"after": "config"
64+
}
65+
}
66+
```
67+
68+
```json title="Header value match"
69+
{
70+
"http.request.headers.values[3]": [
71+
{ "content": "phar://", "after": "example" }
72+
]
73+
}
74+
```
75+
76+
```json title="Raw body content match"
77+
{
78+
"http.request.body.raw": {
79+
"before": "NY>",
80+
"content": "<!ENTITY xxe SYSTEM \"file:///dev/random\">] > ",
81+
"after": "<foo>&xxe;</foo>"
82+
}
83+
}
84+
```

src/content/docs/waf/managed-rules/payload-logging/index.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ sidebar:
77

88
import { GlossaryTooltip } from "~/components";
99

10-
The WAF allows you to log the request information that triggered a specific rule of a managed ruleset. This information is known as the payload. Payload logging is especially useful when diagnosing the behavior of WAF rules. Since the values that triggered a rule may contain sensitive data, they are encrypted with a customer-provided public key so that only you can examine them later.
10+
The WAF allows you to log the request information that triggered a specific rule of a managed ruleset. This information is known as the payload. Payload information includes the specific string that triggered the rule, along with the text that appears immediately before and after the match.
1111

12-
:::note
12+
Payload logging is especially useful when diagnosing the behavior of WAF rules. Since the values that triggered a rule may contain sensitive data, they are encrypted with a customer-provided public key so that only you can examine them later.
1313

14+
:::note
1415
This feature is only available for customers on an Enterprise plan.
15-
1616
:::
1717

1818
## Turn on payload logging

src/content/docs/waf/managed-rules/payload-logging/view.mdx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,16 @@ View the content of the matched rule payload in the dashboard by entering your p
1111

1212
2. Under **Sampled logs**, expand the details of an event triggered by a rule whose managed ruleset has payload logging enabled.
1313

14-
3. Under **Payload match**, select **Decrypt payload log**.
14+
3. Under **Matched service**, select **Decrypt payload match**.
1515

1616
![Example of a firewall event with available payload match data (still encrypted)](~/assets/images/waf/transform-rules/payload-logging-example.png)
1717

18-
The **Payload match** section is not available if the action taken by the matched rule is _Log_.
19-
2018
4. Enter your private key in the pop-up window and select **Decrypt**.
2119

2220
:::note
2321
The private key is not sent to a Cloudflare server. The decryption occurs entirely in the browser.
2422
:::
2523

26-
If the private key you entered decrypts the encrypted payload successfully, the **Payload match** card displays the payload content in clear text.
24+
If the private key you entered decrypts the encrypted payload successfully, the dashboard will show the name of the fields that matched and the matched string in clear text, along with some text appearing before and after the match.
2725

2826
![Viewing the decrypted payload match data after entering your private key in the dashboard](~/assets/images/waf/transform-rules/payload-decrypted.png)

0 commit comments

Comments
 (0)