| ID | Technique | Tactic |
|---|---|---|
| T1190 | Exploit Public-Facing Application | Initial Access |
Detection: Zeek HTTP Malformed Base64 Padding
Description
The analytic hunts for an HTTP header, POST body, or URI containing at least one 64-character Base64 block followed by a short padded fragment. This malformed shape can reach a vulnerable Java Base64 decoder, but its presence in traffic alone does not prove that the server decoded it.
Search
1(
2 `zeek_http_request_headers`
3 header_value="*=*"
4 truncated=false
5)
6OR
7(
8 `zeek_http_post_body`
9 body="*=*"
10 truncated=false
11)
12OR
13(
14 `zeek_http_uri`
15 uri IN ("*=*","*%3D*","*%3d*")
16)
17
18| eval request_value=case(
19 isnotnull(header_value),header_value,
20 isnotnull(body),body,
21 isnotnull(uri),urldecode(uri)
22 ),
23 carrier=case(
24 isnotnull(header_value),header_name,
25 isnotnull(body),"POST body",
26 isnotnull(uri),"URI"
27 ),
28 dest_port=coalesce(dest_port,'id.resp_p'),
29 dest=coalesce(dest,dest_ip,'id.resp_h'),
30 src=coalesce(src,src_ip,'id.orig_h')
31
32
33| rex field=request_value "(?<![A-Za-z0-9+/_-])(?<malformed_base64>(?:(?:[A-Za-z0-9+/]{64})+(?:[A-Za-z0-9+/]{0,2}=
34|[A-Za-z0-9+/]?==)
35|(?:[A-Za-z0-9_-]{64})+(?:[A-Za-z0-9_-]{0,2}=
36|[A-Za-z0-9_-]?==)))(?![A-Za-z0-9+/_=-])"
37
38
39| where isnotnull(malformed_base64)
40
41
42| stats count
43 min(_time) AS firstTime
44 max(_time) AS lastTime
45 values(carrier) AS carrier
46 values(uid) AS zeek_uid
47 values(uri) AS uri
48 values(body) AS body
49 BY src dest dest_port method malformed_base64
50
51| `security_content_ctime(firstTime)`
52
53| `security_content_ctime(lastTime)`
54
55| `zeek_http_malformed_base64_padding_filter`
Data Source
| Name | Platform | Sourcetype | Source |
|---|---|---|---|
| Zeek HTTP Request Headers | Web | 'zeek:http_request_header:json' |
'http_request_headers.log' |
| Zeek HTTP POST Body | Web | 'zeek:http_post_body:json' |
'http_post_body.log' |
| Zeek HTTP | Web | 'zeek:http' |
'http.log' |
Macros Used
| Name | Value |
|---|---|
| zeek_http_post_body | sourcetype="zeek:http_post_body:json" |
| zeek_http_malformed_base64_padding_filter | search * |
zeek_http_malformed_base64_padding_filter is an empty macro by default. It allows the user to filter out any results (false positives) without editing the SPL.
Annotations
CVE
Default Configuration
This detection is configured by default in Splunk Enterprise Security to run with the following settings:
| Setting | Value |
|---|---|
| Disabled | true |
| Cron Schedule | 0 * * * * |
| Earliest Time | -70m@m |
| Latest Time | -10m@m |
| Schedule Window | auto |
| Creates Finding (Notable) | No |
| Creates Intermediate Finding (Risk Event) | Yes |
Implementation
Install the TA for Zeek to parse standard HTTP logs. Configure zeek_http_uri for their index and sourcetype, and confirm that uri, method, uid, id.orig_h, id.resp_h, and id.resp_p are extracted. To collect the optional request-header and POST-body streams, install the custom scripts from https://gist.github.com/nasbench/8581572459af92b7c30599f1068c791f (request headers) and https://gist.github.com/nasbench/4cd18a938056cbfbc8a9832edb26f4c4 (POST bodies), following the corresponding data source instructions. These scripts are not included with ESCU or the TA for Zeek. Configure zeek_http_request_headers and zeek_http_post_body to select their JSON events, and confirm that header_name, header_value, body, and truncated are extracted as applicable. The sensor must see HTTP request plaintext. Capture enough of each header or body for the Base64 value to be complete, and use only truncated=false custom events.
Known False Positives
Legitimate but malformed Base64, binary structured fields, or unrelated encoded values can match. Confirm that the application actually decodes the field before treating this as an exploit attempt. Scripts that construct the trigger after receiving the request may not put a literal Base64 value on the wire.
Associated Analytic Story
Intermediate Findings
| Message | Entity Field | Entity Type | Risk Score |
|---|---|---|---|
| Malformed Base64 padding was observed in [$carrier$] on HTTP traffic from $src$ to [$dest$:$dest_port$] [$method$; $count$ events]. | dest | system | 20 |
References
Detection Testing
| Test Type | Status | Dataset | Source | Sourcetype |
|---|---|---|---|---|
| Validation | ✅ Passing | N/A | N/A | N/A |
| Unit | ✅ Passing | Dataset | http_post_body.log |
zeek:http_post_body:json |
| Integration | ✅ Passing | Dataset | http_post_body.log |
zeek:http_post_body:json |
Replay any dataset to Splunk Enterprise by using our replay.py tool or the UI.
Alternatively you can replay a dataset into a Splunk Attack Range
Source: GitHub |
Version: 1