| ID | Technique | Tactic |
|---|---|---|
| T1190 | Exploit Public-Facing Application | Initial Access |
Detection: HTTP Base64 Activity With JVM Errors
Description
The analytic associates each Zeek request containing a malformed Base64 value or a scripted decoder trigger with a nearby Base64-related HotSpot argument exception on the same server and Java PID. Sysmon child process, file creation, or process termination events from that PID add context and can raise confidence.
Search
1(
2 `zeek_http_request_headers`
3 header_name IN (
4 "AUTHORIZATION",
5 "HTTP2-SETTINGS",
6 "CONTENT-TYPE",
7 "CONTENT-DISPOSITION",
8 "PRIORITY",
9 "X-CONSOLEANNOTATOR",
10 "X-CONNECT-AUTHORIZATION",
11 "X-CSRF-TOKEN"
12 )
13 header_value="*=*"
14 truncated=false
15)
16OR
17(
18 `zeek_http_post_body`
19 body="*=*"
20 truncated=false
21)
22OR
23(
24 `zeek_http_uri`
25 uri IN ("*=*","*%3D*","*%3d*")
26)
27OR
28(
29 `java_hotspot_exceptions`
30 (
31 "*Input byte array has wrong*"
32 OR
33 "*IllegalArgumentException*"
34 OR
35 "*Base64$Decoder*"
36 OR
37 "*java/util/Base64*"
38 )
39)
40OR
41(
42 `sysmon_linux`
43 (
44 (EventID=1 ParentImage="*/java")
45 OR
46 (EventID=5 Image="*/java")
47 OR
48 (
49 EventID=11
50 Image="*/java"
51 NOT TargetFilename IN ("*/_state/*","*/indices/*")
52 )
53 )
54)
55
56
57| rex field=_raw "^\[(?<jvm_event_time_raw>[^\]]+)\]\[(?<jvm_pid_raw>\d+)\]\[(?<jvm_level_raw>[^\]]+)\]\[(?<jvm_tags_raw>[^\]]+)\]\s*(?<jvm_message_raw>.*)"
58
59
60| eval jvm_pid=coalesce(jvm_pid_raw,jvm_pid),
61 jvm_tags=coalesce(jvm_tags_raw,jvm_tags),
62 jvm_message=coalesce(jvm_message_raw,jvm_message)
63
64
65
66| eval event_time=_time,
67 is_network=if(isnotnull('id.resp_h'),1,0)
68
69
70| eval observed_target=if(is_network=1,'id.resp_h',coalesce(dest,host,dest_ip))
71
72
73| eval request_value=case(
74 isnotnull(header_name),header_value,
75 isnotnull(body),body,
76 is_network=1,urldecode(uri)
77 ),
78 carrier=case(
79 isnotnull(header_name),header_name,
80 isnotnull(body),"POST body",
81 is_network=1,"URI"
82 )
83
84
85| where is_network=0 OR len(request_value)>=65
86
87
88| eval malformed_b64=if(
89 is_network=1
90 AND match(request_value,"(?<![A-Za-z0-9+/_-])(?:(?:[A-Za-z0-9+/]{64})+(?:[A-Za-z0-9+/]{0,2}=
91|[A-Za-z0-9+/]?==)
92|(?:[A-Za-z0-9_-]{64})+(?:[A-Za-z0-9_-]{0,2}=
93|[A-Za-z0-9_-]?==))(?![A-Za-z0-9+/_=-])"),
94 1,0
95 ),
96 scripted_b64=if(
97 is_network=1 AND isnotnull(body)
98 AND like(body,"%Base64.getDecoder()%")
99 AND like(body,"%new byte[65]%")
100 AND like(body,"%[64] = (byte)61%"),
101 1,0
102 )
103
104
105| eval event_kind=case(
106 is_network=1 AND (malformed_b64=1 OR scripted_b64=1),"request",
107 isnotnull(jvm_pid) AND like(jvm_tags,"%exceptions%"),"jvm",
108 EventID=1 OR EventID=5 OR EventID=11,"sysmon"
109 )
110
111
112| eval java_pid=case(
113 event_kind="request","network",
114 event_kind="jvm",tostring(jvm_pid),
115 EventID=1,tostring(ParentProcessId),
116 EventID=5 OR EventID=11,tostring(ProcessId)
117 ),
118 request_uid=if(event_kind="request",uid,"-")
119
120
121| where isnotnull(event_kind)
122 AND isnotnull(observed_target)
123 AND isnotnull(java_pid)
124 AND isnotnull(request_uid)
125
126
127| eval argument_error=if(event_kind="jvm"
128 AND match(jvm_message,"(?i)IllegalArgumentException
129|Input byte array has wrong"),1,0),
130 decoder_evidence=if(event_kind="jvm"
131 AND match(jvm_message,"Base64[$]Decoder
132|java/util/Base64
133|Input byte array has wrong"),1,0),
134 shell_child=if(EventID=1
135 AND match(Image,"/(ash
136|bash
137|csh
138|dash
139|eshell
140|fish
141|ion
142|ksh
143|mksh
144|rbash
145|sh
146|tcsh
147|zsh)$"),1,0),
148 child_process=if(EventID=1,1,0),
149 file_created=if(EventID=11,1,0),
150 java_terminated=if(EventID=5,1,0),
151 suspicious_file=if(EventID=11
152 AND match(TargetFilename,"(?i)(?:[.](?:jsp
153|sh
154|so)$
155|/(?:tmp
156|var/tmp
157|dev/shm
158|webapps)/)"),1,0)
159
160
161| eval request_marker=case(
162 event_kind="request" AND scripted_b64=1,"scripted_decoder_trigger",
163 event_kind="request" AND malformed_b64=1,"malformed_base64_request"
164 ),
165 src_ip=if(event_kind="request",'id.orig_h',null()),
166 request_uri=if(event_kind="request",uri,null()),
167 http_method=if(event_kind="request",method,null()),
168 child_image=if(EventID=1,Image,null()),
169 created_file=if(EventID=11,TargetFilename,null())
170
171
172| bin _time span=1s
173
174
175| stats min(event_time) AS first_seen
176 max(event_time) AS last_seen
177 max(argument_error) AS argument_error
178 max(decoder_evidence) AS decoder_evidence
179 max(shell_child) AS shell_child
180 max(child_process) AS child_process
181 max(file_created) AS file_created
182 max(java_terminated) AS java_terminated
183 max(suspicious_file) AS suspicious_file
184 values(src_ip) AS src_ips
185 values(request_uri) AS uris
186 values(http_method) AS methods
187 values(carrier) AS carriers
188 values(request_marker) AS request_markers
189 values(child_image) AS child_images
190 values(created_file) AS created_files
191 BY _time observed_target java_pid request_uid event_kind
192
193
194| rename observed_target AS dest
195
196
197| `get_asset(dest)`
198
199
200| eval target=coalesce(dest_asset_id,dest),
201 bucket=floor(first_seen/15)
202
203
204| eval request_json=if(
205 event_kind="request",
206 json_object(
207 "uid",request_uid,
208 "time",first_seen,
209 "src",mvindex(src_ips,0),
210 "dest",dest,
211 "uri",mvindex(uris,0),
212 "method",mvindex(methods,0),
213 "carrier",mvjoin(carriers,","),
214 "marker",mvjoin(request_markers,",")
215 ),
216 null()
217 ),
218 bucket=if(
219 event_kind="request",
220 mvappend(tostring(bucket-1),tostring(bucket),tostring(bucket+1),tostring(bucket+2)),
221 bucket
222 )
223
224
225| mvexpand bucket
226
227
228| eventstats values(request_json) AS candidate_requests BY target bucket
229
230
231| where event_kind!="request" AND isnotnull(candidate_requests)
232
233
234| mvexpand candidate_requests
235
236
237| eval request_uid=spath(candidate_requests,"uid"),
238 request_time=tonumber(spath(candidate_requests,"time")),
239 src=spath(candidate_requests,"src"),
240 request_dest=spath(candidate_requests,"dest"),
241 uri=spath(candidate_requests,"uri"),
242 method=spath(candidate_requests,"method"),
243 carrier=spath(candidate_requests,"carrier"),
244 request_marker=spath(candidate_requests,"marker")
245
246
247| where (event_kind="jvm"
248 AND last_seen>=request_time-3
249 AND first_seen<=request_time+15)
250 OR
251 (event_kind="sysmon"
252 AND last_seen>=request_time-3
253 AND first_seen<=request_time+30)
254
255
256| stats min(request_time) AS request_time
257 min(eval(if(argument_error=1,first_seen,null()))) AS exception_time
258 max(last_seen) AS last_seen
259 max(argument_error) AS argument_error
260 max(decoder_evidence) AS decoder_evidence
261 max(shell_child) AS shell_child
262 max(child_process) AS child_process
263 max(file_created) AS file_created
264 max(java_terminated) AS java_terminated
265 max(suspicious_file) AS suspicious_file
266 values(src) AS src
267 values(request_dest) AS dest_ips
268 values(uri) AS uri
269 values(method) AS method
270 values(carrier) AS carrier
271 values(request_marker) AS request_markers
272 values(child_images) AS child_images
273 values(created_files) AS created_files
274 BY target request_uid java_pid
275
276
277| where argument_error=1 AND decoder_evidence=1
278
279
280| eval dest=mvindex(dest_ips,0),
281 exception_delay=round(exception_time-request_time,3),
282 confidence=case(
283 shell_child>0 OR suspicious_file>0,"high",
284 child_process>0 OR file_created>0 OR java_terminated>0,"medium",
285 true(),"low"
286 ),
287 asset_id=target,
288 firstTime=request_time,
289 lastTime=last_seen
290
291
292| fields - argument_error decoder_evidence shell_child child_process file_created java_terminated suspicious_file dest_ips
293
294
295| sort 0 - firstTime
296
297
298| `security_content_ctime(firstTime)`
299
300| `security_content_ctime(lastTime)`
301
302| `http_base64_activity_with_jvm_errors_filter`
Data Source
| Name | Platform | Sourcetype | Source |
|---|---|---|---|
| Sysmon for Linux EventID 11 | 'sysmon:linux' |
'Syslog:Linux-Sysmon/Operational' |
|
| Zeek HTTP Request Headers | Web | 'zeek:http_request_header:json' |
'http_request_headers.log' |
| Sysmon for Linux EventID 5 | 'sysmon:linux' |
'Syslog:Linux-Sysmon/Operational' |
|
| Zeek HTTP POST Body | Web | 'zeek:http_post_body:json' |
'http_post_body.log' |
| Sysmon for Linux EventID 1 | 'sysmon:linux' |
'Syslog:Linux-Sysmon/Operational' |
|
| Java HotSpot Exceptions | Other | 'java:hotspot:exceptions' |
'exceptions-*.log' |
| Zeek HTTP | Web | 'zeek:http' |
'http.log' |
Macros Used
| Name | Value |
|---|---|
| java_hotspot_exceptions | sourcetype="java:hotspot:exceptions" |
| http_base64_activity_with_jvm_errors_filter | search * |
http_base64_activity_with_jvm_errors_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
Configure zeek_http_uri, zeek_http_request_headers, zeek_http_post_body, and java_hotspot_exceptions for the indexes and sourcetypes in your environment. Configure sysmon_linux if you collect that optional source. Install the TA for Zeek for standard HTTP logs. To collect the optional 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. Ensure uid, uri, id.orig_h, id.resp_h, header_name, header_value, body, and truncated are extracted as applicable. The sensor must see request plaintext.
HotSpot exception diagnostics are not written to a standard file by default. Tomcat normally writes JULI logs under CATALINA_BASE/logs (and, on Unix with its startup scripts, console output to catalina.out); Spring Boot writes application logs to the console by default; and Elasticsearch application logs use /var/log/elasticsearch for Debian/RPM packages, ES_HOME/logs for tar/zip installs, or container stdout. Elasticsearch enables GC logs by default, but these are separate from the exception stream required here.
Add this JVM startup option with a writable path chosen for the deployment:
-Xlog:exceptions=debug:file=/var/log/myapp/exceptions-%p.log:utctime,pid,level,tags:filecount=8,filesize=16m
For Tomcat scripts, place it in CATALINA_OPTS via CATALINA_BASE/bin/setenv.sh or setenv.bat; for a Windows Tomcat service, configure its Java options. For Spring Boot, add it to the Java service or container launch command. For Elasticsearch, add a .options file in config/jvm.options.d or /etc/elasticsearch/jvm.options.d, according to the installation method, and preserve existing JVM logging settings. Spring Boot logging.file.name and Tomcat logging.properties control application or container logs, not HotSpot unified logging.
Forward the configured file and rotations as java:hotspot:exceptions. On the Splunk parsing tier, configure single-line event breaking and timestamps for utctime. Search-time extraction in props.conf is optional: use EXTRACT-jvm_unified (or a shared REPORT transform) for reusable jvm_pid, jvm_tags, and jvm_message fields, or leave those fields unconfigured and let this search parse the decorated _raw line with rex. The search coalesces raw and pre-extracted values, including jvm_tags, before correlating the Java PID. The Java HotSpot Exceptions data source gives the input and optional extraction pattern. Verify the raw format, host identity, file permissions, and retention before enabling the search. Exception logging can be high volume, and an exception event is not guaranteed during exploitation.
Optionally ingest Sysmon for Linux EventID 1, 5, and 11 with ParentImage, ParentProcessId, Image, ProcessId, and TargetFilename. Process creation joins on ParentProcessId; file creation and process termination join on ProcessId.
Configure Enterprise Security Assets and Identities so the Zeek destination IP and the JVM or Sysmon hostname resolve to the same dest_asset_id through get_asset(dest). Synchronize the sensor and server clocks. The search permits JVM events from 3 seconds before to 15 seconds after each request marker, and optional Sysmon events up to 30 seconds after it. Tune these windows to measured collection delays.
Known False Positives
One JVM can handle concurrent requests, so an exception may fall within 15 seconds of more than one malformed request. HotSpot logs do not carry the Zeek uid, and this search establishes time proximity rather than causation. Ordinary Java child processes and file writes can coincide with the request. Review the URI, Zeek uid, exception delay, Java PID, child image, and created path. Clock skew, PID reuse, and incorrect host/IP mapping can misassociate events. Sysmon evidence is supporting context and is not required for a result.
Associated Analytic Story
Intermediate Findings
| Message | Entity Field | Entity Type | Risk Score |
|---|---|---|---|
| HTTP Base64 marker in request [$request_uid$] from [$src$] to [$dest$] aligned with a Base64-related argument exception in Java PID [$java_pid$] at a [$exception_delay$]-second offset. Confidence: [$confidence$] | dest | system | 20 |
References
Detection Testing
| Test Type | Status | Dataset | Source | Sourcetype |
|---|---|---|---|---|
| Validation | ✅ Passing | N/A | N/A | N/A |
| Unit | ✅ Passing | Dataset | http.log |
bro:http:json |
| Integration | ✅ Passing | Dataset | http.log |
bro:http: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