| ID | Technique | Tactic |
|---|---|---|
| T1190 | Exploit Public-Facing Application | Initial Access |
Detection: Java Base64 Decoder Argument Exceptions
Description
The analytic finds Java Base64 decoder references and argument exceptions on the same JVM process within one minute. JIT messages add context when present. These logs indicate decoder activity and errors, but do not prove that a native overwrite or code execution occurred.
Search
1(`java_hotspot_jit` OR `java_hotspot_exceptions`)
2(
3 "*Input byte array has wrong*"
4 OR "*IllegalArgumentException*"
5 OR "*Base64$Decoder*"
6 OR "*java/util/Base64*"
7 OR "*OSR invalidation of lower level*"
8)
9
10
11| rex field=_raw "^\[(?<jvm_event_time_raw>[^\]]+)\]\[(?<jvm_pid_raw>\d+)\]\[(?<jvm_level_raw>[^\]]+)\]\[(?<jvm_tags_raw>[^\]]+)\]\s*(?<jvm_message_raw>.*)"
12
13
14| eval process_id=coalesce(jvm_pid_raw,jvm_pid,process_id),
15 jvm_message=coalesce(jvm_message_raw,jvm_message),
16 event_time=_time
17
18
19| where isnotnull(process_id)
20
21
22| rex mode=sed field=jvm_message "s/0x[0-9A-Fa-f]{8,16}/0xXXXXXXXXXXXXXXXX/g"
23
24| rex mode=sed field=jvm_message "s/\s+bci\s+\d+\s+/ bci XXX /g"
25
26| rex mode=sed field=jvm_message "s/^\d+\s+/XXXX /g"
27
28
29| eval has_argument=if(match(jvm_message,"(?i)Input byte array has wrong
30|IllegalArgumentException"),1,0),
31 has_decoder=if(match(jvm_message,"Base64[$]Decoder
32|java/util/Base64
33|Input byte array has wrong 4-byte ending unit"),1,0)
34
35
36| eval reason=case(
37 match(jvm_message,"(?i)Input byte array has wrong"),"Tailing byte exception",
38 match(jvm_message,"(?i)OSR invalidation of lower level"),"JIT activity",
39 has_decoder==1,"Base64 decoder reference",
40 has_argument==1,"Argument exception"
41)
42
43
44| bin _time span=1m
45
46
47| stats count
48 min(event_time) AS firstTime
49 max(event_time) AS lastTime
50 max(has_argument) AS has_argument
51 max(has_decoder) AS has_decoder
52 values(sourcetype) AS sourcetype
53 dc(sourcetype) AS dc_sourcetype
54 values(source) AS source
55 dc(source) AS dc_source
56 values(reason) AS reason
57 values(jvm_message) AS jvm_message
58 BY _time host process_id
59
60
61| where has_argument==1 AND has_decoder==1
62
63
64| rename host AS dest
65
66
67| fields - has_argument has_decoder
68
69
70| `security_content_ctime(firstTime)`
71
72| `security_content_ctime(lastTime)`
73
74| `java_base64_decoder_argument_exceptions_filter`
Data Source
| Name | Platform | Sourcetype | Source |
|---|---|---|---|
| Java HotSpot Exceptions | Other | 'java:hotspot:exceptions' |
'exceptions-*.log' |
| Java HotSpot JIT | Other | 'java:hotspot:jit' |
'jit-*.log' |
Macros Used
| Name | Value |
|---|---|
| java_hotspot_jit | sourcetype="java:hotspot:jit" |
| java_base64_decoder_argument_exceptions_filter | search * |
java_base64_decoder_argument_exceptions_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 java_hotspot_exceptions and java_hotspot_jit for the indexes and sourcetypes in your environment. A stock HotSpot JVM does not create exception or JIT log files; its default unified logging sends warning and error messages to stdout. Tomcat JULI logs under CATALINA_BASE/logs, Spring Boot's default console logs, and Elasticsearch application logs are separate from these JVM diagnostics.
Add -Xlog:exceptions=debug:file=/var/log/myapp/exceptions-%p.log:utctime,pid,level,tags:filecount=8,filesize=16m to the Java startup options. To collect JIT context, also add -Xlog:jit+compilation=debug:file=/var/log/myapp/jit-%p.log:utctime,pid,level,tags:filecount=8,filesize=16m. Use a writable directory and monitor both files and rotations. Tomcat scripts accept CATALINA_OPTS in setenv.sh or setenv.bat; a Windows Tomcat service uses its Java options; Spring Boot uses the Java service or container launch command; and Elasticsearch uses jvm.options.d under its config directory or /etc/elasticsearch/jvm.options.d for Debian/RPM packages. The Java HotSpot Exceptions and Java HotSpot JIT data source descriptions give the Splunk input and field-extraction settings.
Search-time extraction in props.conf is optional. Configure EXTRACT-jvm_unified or a shared REPORT transform if you want reusable jvm_pid and jvm_message fields; otherwise this search parses the decorated _raw lines with rex and coalesces the raw fields with any pre-extracted values. Keep the same host value for all logs from one JVM and verify the raw format or extracted fields with representative events. The JIT source adds context; an exception source alone can satisfy both required terms when it contains the exact Base64 decoder message Input byte array has wrong 4-byte ending unit. Decoder references on separate continuation lines may lack the PID decorator and cannot be joined reliably with single-line event breaking. Neither log proves that the intrinsic overwrite occurred.
Known False Positives
Applications that routinely decode malformed Base64 can produce these events. The decoder and exception may come from separate requests within the same minute; review the surrounding application and network events.
Associated Analytic Story
Intermediate Findings
| Message | Entity Field | Entity Type | Risk Score |
|---|---|---|---|
| Java Base64 decoder argument exceptions observed on $dest$ in PID $process_id$. | dest | system | 20 |
References
Detection Testing
| Test Type | Status | Dataset | Source | Sourcetype |
|---|---|---|---|---|
| Validation | ✅ Passing | N/A | N/A | N/A |
| Unit | ✅ Passing | Dataset | exceptions.log |
java:hotspot:exceptions |
| Integration | ✅ Passing | Dataset | exceptions.log |
java:hotspot:exceptions |
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