SlideShare a Scribd company logo
Monitoring Java Application Security
with JDK Tools & JFR Events
#jfall
Hello! I am Ana
JDK Flight Recorder(JFR) Events
When running a Java application, JFR can collect events that occur in the JVM.
JFR Events express the state of the application and underlying JVM.
For profiling, store event data in a .jfr file.
Timestamp Duration ThreadID
Stack
Trace ID
Event Specific Payload
JFR Event Components
Event
ID
JFR Security Events
Name Goal Backporte d
To
Enabl ed By
De fault*
jdk.SecurityPropertyModification Records calls to Security.setProperty(String
key, String value).
Oracle JDK 11.0.5
and 8u231
No
jdk.TLSHandshake Keeps track of TLS handshake activity. Oracle JDK 11.0.5
and 8u231
No
jdk.X509Certificate Records details of X.509 Certificates. Oracle JDK 11.0.5
and 8u231
No
jdk.X509Validation Records details of X.509 certificates
negotiated in successful X.509 validation.
Oracle JDK 11.0.5
and 8u231
No
jdk.InitialSecurityProperty For insights on initial JDK security
properties.
Oracle JDK 17.0.7
and 11.0.20
Yes
jdk.SecurityProviderService Records service provider method
invocations.
JDK 17.0.8, 11.0.22
and 8u391
No
* In default.jfc and profile.jfc shipped within a JDK
Local Demo Setup Overview
Running TicTacToe locally
Monitor with JDK tools
Spring Boot application
with JDK 23
Keystore
Truststore
Client Certificate #local.ext file
authorityKeyIdentifier=keyid,issuer
basicConstraints=CA:FALSE
subjectAltName = @alt_names
[alt_names]
DNS.1 = localhost
DNS.2 = springboot
IP.1 = 127.0.0.1
The jfr scrub Command
• Filter data from the specified recording file.
jfr scrub [filters] [recording-file] [output-file]
• Supply which events to include.
jfr scrub --include-events jdk.FileRead,jdk.FileWrite
• Include a category and exclude events.
jfr scrub --include-categories GC* --exclude-events jdk.GCLocker
• Remove all events by category: jfr scrub --exclude-categories GC*
[JFR scrub recording data— JDK-8281175]
Continuous Monitoring in the Cloud
Active Monitoring Out of Process
String host = "com.example"; int port = 1099;
String url = "service:jmx:rmi:///jndi/rmi://" + host + ":" + port + "/jmxrmi";
JMXServiceURL u = new JMXServiceURL(url);
JMXConnector c = JMXConnectorFactory.connect(new JMXServiceURL(url));
MBeanServerConnection connection = c.getMBeanServerConnection();
try (var stream = new RemoteRecordingStream(connection)) {
stream.enabled("jdk.X509Certificate").withStackTrace();
stream.onEvent("jdk.X509Certificate", System.out::println),
stream.start();
}
Passive Monitoring Out of Process
CompositeMeterRegistry metricsRegistry = Metrics.globalRegistry;
Path path = Path.of("/repository/2024_09_16_09_48_31_6185");
try (var es = EventStream.openRepository(path)) {
es.enabled("jdk.X509Certificate").withStackTrace();
es.onEvent("jdk.X509Validation", recordedEvent -> {
Gauge.builder("jdk.X509Validation", recordedEvent,
e -> e.getLong("validationCounter"))
.description("X509 Certificate Validation Gauge")
.register(metricsRegistry);
});
es.start();
}
Stream JFR Events Actively, Within Process
CompositeMeterRegistry metricsRegistry = Metrics.globalRegistry;
try (var es = new RecordingStream()) {
es.onEvent("jdk.X509Validation", recordedEvent -> {
Gauge.builder("jdk.X509Validation", recordedEvent,
e -> e.getLong("validationCounter"))
.description("X509 Certificate Validation Gauge")
.register(metricsRegistry);
});
es.start();
} catch (IOException e) {
throw new RuntimeException("Couldn't process event", e);
}
Stream JFR Events Passively, Within Process
CompositeMeterRegistry metricsRegistry = Metrics.globalRegistry;
try (var es = EventStream.openRepository()) {
es.onEvent("jdk.X509Validation", recordedEvent -> {
Gauge.builder("jdk.X509Validation", recordedEvent,
e -> e.getLong("validationCounter"))
.description("X509 Certificate Validation Gauge")
.register(metricsRegistry);
});
es.start();
} catch (IOException e) {
throw new RuntimeException("Couldn't process event", e);
}
Evolving the Demo Setup
Oracle Cloud
Run podman compose with TicTacToe in Oracle Cloud Instance
Monitor with JDK tools
Spring Boot application
with JDK 23 Keystore
Player
Monitoring tool
(Prometheus) Configuration
Volume
Volume
Java Management Service
Let’s play and Observe!
Stay Tuned For More!
Inside.java
Dev.java youtube.com/java
Useful links
• Monitoring Java Application Security with JDK tools and JFR Events: https://dev.java/learn/security/monitor/
• Stack Walker ep 2 on JFR https://inside.java/2023/05/14/stackwalker-02/
• Introduction to JDK Mission Control: https://youtu.be/7-RKyp05m8M
• JMC9 – What’s new?: https://youtu.be/KzWwGSRxIi4
• Continuous monitoring with JDK Flight Recorder: https://www.infoq.com/presentations/monitoring-jdk-jfr/
• Code used during demo: https://github.com/ammbra/tictactoe
• OCI Instance installation: https://inside.java/2024/07/16/build-oci-instance-with-java-concepts/
• Compose files in OCI: https://docs.oracle.com/en/learn/podman-compose/index.html#confirm-podman-compose-is-working
• More articles on Java Management Service: https://inside.java/tag/cloud
• Gunnar Morling’s article on custom JFR events: https://www.morling.dev/blog/rest-api-monitoring-with-custom-jdk-flight-
recorder-events/

More Related Content

PDF
Monitoring Java Application Security with JDK Tools and JFR Events
PDF
Monitoring Java Application Security with JDK Tools and JFR Events
PDF
ログ出力を改めて考える - JDK Flight Recorder の活用
PDF
Monitoring Java Application Security with JDK Tools and JFR Events.pdf
PDF
ASML_FlightRecorderMeetsJava.pdf
PDF
JMC/JFR: Kotlin spezial
PDF
DevDays: Profiling With Java Flight Recorder
PDF
Live Streaming & Server Sent Events
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
ログ出力を改めて考える - JDK Flight Recorder の活用
Monitoring Java Application Security with JDK Tools and JFR Events.pdf
ASML_FlightRecorderMeetsJava.pdf
JMC/JFR: Kotlin spezial
DevDays: Profiling With Java Flight Recorder
Live Streaming & Server Sent Events

Similar to Monitoring Java Application Security with JDK Tools and JFR Events (20)

PPTX
13 networking, mobile services, and authentication
PDF
Azure Durable Functions (2019-03-30)
PPTX
Angular js security
PDF
Azure Durable Functions (2019-04-27)
PDF
使ってみよう!JDK Flight Recorder
PDF
Speed up your Web applications with HTML5 WebSockets
PDF
Faster & Greater Messaging System HornetQ zzz
PDF
JDD 2016 - Michał Balinski, Oleksandr Goldobin - Practical Non Blocking Micro...
PPTX
Resiliency & Security_Ballerina Day CMB 2018
PPT
SSL/TLS implementation using JSSE
PPT
Intoduction to Play Framework
PPTX
Taking Jenkins Pipeline to the Extreme
PPTX
Solving anything in VCL
KEY
Going real time with Socket.io
PDF
Manage all the things, small and big, with open source LwM2M implementations ...
PPT
my accadanic project ppt
PPT
Java RMI
PPT
WebLogic Developer Webcast 5: Troubleshooting and Testing with WebLogic, Soap...
PDF
Durable functions 2.0 (2019-10-10)
PDF
maxbox starter72 multilanguage coding
13 networking, mobile services, and authentication
Azure Durable Functions (2019-03-30)
Angular js security
Azure Durable Functions (2019-04-27)
使ってみよう!JDK Flight Recorder
Speed up your Web applications with HTML5 WebSockets
Faster & Greater Messaging System HornetQ zzz
JDD 2016 - Michał Balinski, Oleksandr Goldobin - Practical Non Blocking Micro...
Resiliency & Security_Ballerina Day CMB 2018
SSL/TLS implementation using JSSE
Intoduction to Play Framework
Taking Jenkins Pipeline to the Extreme
Solving anything in VCL
Going real time with Socket.io
Manage all the things, small and big, with open source LwM2M implementations ...
my accadanic project ppt
Java RMI
WebLogic Developer Webcast 5: Troubleshooting and Testing with WebLogic, Soap...
Durable functions 2.0 (2019-10-10)
maxbox starter72 multilanguage coding
Ad

More from Ana-Maria Mihalceanu (20)

PDF
Empower Inclusion Through Accessible Java Applications
PDF
Java 25 and Beyond - A Roadmap of Innovations
PDF
Sécuriser les Applications Java Contre les Menaces Quantiques
PDF
Des joyaux de code natif aux trésors Java avec jextract
PDF
From native code gems to Java treasures with jextract
PDF
Exciting Features and Enhancements in Java 23 and 24
PDF
Enhancing Productivity and Insight A Tour of JDK Tools Progress Beyond Java 17
PDF
From native code gems to Java treasures with jextract
PDF
Java 23 and Beyond - A Roadmap Of Innovations
PDF
Enhancing Productivity and Insight A Tour of JDK Tools Progress Beyond Java 17
PDF
Java 22 and Beyond- A Roadmap of Innovations
PDF
Surveillance de la sécurité des applications Java avec les outils du JDK e...
PDF
A Glance At The Java Performance Toolbox
PDF
Enhancing Productivity and Insight A Tour of JDK Tools Progress Beyond Java 17
PDF
Java 21 Language Features and Beyond
PDF
From Java 17 to 21- A Showcase of JDK Security Enhancements
PDF
Java 21 and Beyond- A Roadmap of Innovations
PDF
A Glance At The Java Performance Toolbox
PDF
A Glance At The Java Performance Toolbox.pdf
PDF
A Glance At The Java Performance Toolbox-TIA.pdf
Empower Inclusion Through Accessible Java Applications
Java 25 and Beyond - A Roadmap of Innovations
Sécuriser les Applications Java Contre les Menaces Quantiques
Des joyaux de code natif aux trésors Java avec jextract
From native code gems to Java treasures with jextract
Exciting Features and Enhancements in Java 23 and 24
Enhancing Productivity and Insight A Tour of JDK Tools Progress Beyond Java 17
From native code gems to Java treasures with jextract
Java 23 and Beyond - A Roadmap Of Innovations
Enhancing Productivity and Insight A Tour of JDK Tools Progress Beyond Java 17
Java 22 and Beyond- A Roadmap of Innovations
Surveillance de la sécurité des applications Java avec les outils du JDK e...
A Glance At The Java Performance Toolbox
Enhancing Productivity and Insight A Tour of JDK Tools Progress Beyond Java 17
Java 21 Language Features and Beyond
From Java 17 to 21- A Showcase of JDK Security Enhancements
Java 21 and Beyond- A Roadmap of Innovations
A Glance At The Java Performance Toolbox
A Glance At The Java Performance Toolbox.pdf
A Glance At The Java Performance Toolbox-TIA.pdf
Ad

Recently uploaded (20)

PDF
KodekX | Application Modernization Development
PPTX
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Machine learning based COVID-19 study performance prediction
PDF
Empathic Computing: Creating Shared Understanding
PDF
Review of recent advances in non-invasive hemoglobin estimation
PPTX
Cloud computing and distributed systems.
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PPT
Teaching material agriculture food technology
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Modernizing your data center with Dell and AMD
PPTX
Big Data Technologies - Introduction.pptx
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
KodekX | Application Modernization Development
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
Building Integrated photovoltaic BIPV_UPV.pdf
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Machine learning based COVID-19 study performance prediction
Empathic Computing: Creating Shared Understanding
Review of recent advances in non-invasive hemoglobin estimation
Cloud computing and distributed systems.
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
NewMind AI Weekly Chronicles - August'25 Week I
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Advanced methodologies resolving dimensionality complications for autism neur...
Teaching material agriculture food technology
Unlocking AI with Model Context Protocol (MCP)
Modernizing your data center with Dell and AMD
Big Data Technologies - Introduction.pptx
Per capita expenditure prediction using model stacking based on satellite ima...
Agricultural_Statistics_at_a_Glance_2022_0.pdf
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx

Monitoring Java Application Security with JDK Tools and JFR Events

  • 1. Monitoring Java Application Security with JDK Tools & JFR Events #jfall
  • 3. JDK Flight Recorder(JFR) Events When running a Java application, JFR can collect events that occur in the JVM. JFR Events express the state of the application and underlying JVM. For profiling, store event data in a .jfr file. Timestamp Duration ThreadID Stack Trace ID Event Specific Payload JFR Event Components Event ID
  • 4. JFR Security Events Name Goal Backporte d To Enabl ed By De fault* jdk.SecurityPropertyModification Records calls to Security.setProperty(String key, String value). Oracle JDK 11.0.5 and 8u231 No jdk.TLSHandshake Keeps track of TLS handshake activity. Oracle JDK 11.0.5 and 8u231 No jdk.X509Certificate Records details of X.509 Certificates. Oracle JDK 11.0.5 and 8u231 No jdk.X509Validation Records details of X.509 certificates negotiated in successful X.509 validation. Oracle JDK 11.0.5 and 8u231 No jdk.InitialSecurityProperty For insights on initial JDK security properties. Oracle JDK 17.0.7 and 11.0.20 Yes jdk.SecurityProviderService Records service provider method invocations. JDK 17.0.8, 11.0.22 and 8u391 No * In default.jfc and profile.jfc shipped within a JDK
  • 5. Local Demo Setup Overview Running TicTacToe locally Monitor with JDK tools Spring Boot application with JDK 23 Keystore Truststore Client Certificate #local.ext file authorityKeyIdentifier=keyid,issuer basicConstraints=CA:FALSE subjectAltName = @alt_names [alt_names] DNS.1 = localhost DNS.2 = springboot IP.1 = 127.0.0.1
  • 6. The jfr scrub Command • Filter data from the specified recording file. jfr scrub [filters] [recording-file] [output-file] • Supply which events to include. jfr scrub --include-events jdk.FileRead,jdk.FileWrite • Include a category and exclude events. jfr scrub --include-categories GC* --exclude-events jdk.GCLocker • Remove all events by category: jfr scrub --exclude-categories GC* [JFR scrub recording data— JDK-8281175]
  • 8. Active Monitoring Out of Process String host = "com.example"; int port = 1099; String url = "service:jmx:rmi:///jndi/rmi://" + host + ":" + port + "/jmxrmi"; JMXServiceURL u = new JMXServiceURL(url); JMXConnector c = JMXConnectorFactory.connect(new JMXServiceURL(url)); MBeanServerConnection connection = c.getMBeanServerConnection(); try (var stream = new RemoteRecordingStream(connection)) { stream.enabled("jdk.X509Certificate").withStackTrace(); stream.onEvent("jdk.X509Certificate", System.out::println), stream.start(); }
  • 9. Passive Monitoring Out of Process CompositeMeterRegistry metricsRegistry = Metrics.globalRegistry; Path path = Path.of("/repository/2024_09_16_09_48_31_6185"); try (var es = EventStream.openRepository(path)) { es.enabled("jdk.X509Certificate").withStackTrace(); es.onEvent("jdk.X509Validation", recordedEvent -> { Gauge.builder("jdk.X509Validation", recordedEvent, e -> e.getLong("validationCounter")) .description("X509 Certificate Validation Gauge") .register(metricsRegistry); }); es.start(); }
  • 10. Stream JFR Events Actively, Within Process CompositeMeterRegistry metricsRegistry = Metrics.globalRegistry; try (var es = new RecordingStream()) { es.onEvent("jdk.X509Validation", recordedEvent -> { Gauge.builder("jdk.X509Validation", recordedEvent, e -> e.getLong("validationCounter")) .description("X509 Certificate Validation Gauge") .register(metricsRegistry); }); es.start(); } catch (IOException e) { throw new RuntimeException("Couldn't process event", e); }
  • 11. Stream JFR Events Passively, Within Process CompositeMeterRegistry metricsRegistry = Metrics.globalRegistry; try (var es = EventStream.openRepository()) { es.onEvent("jdk.X509Validation", recordedEvent -> { Gauge.builder("jdk.X509Validation", recordedEvent, e -> e.getLong("validationCounter")) .description("X509 Certificate Validation Gauge") .register(metricsRegistry); }); es.start(); } catch (IOException e) { throw new RuntimeException("Couldn't process event", e); }
  • 12. Evolving the Demo Setup Oracle Cloud Run podman compose with TicTacToe in Oracle Cloud Instance Monitor with JDK tools Spring Boot application with JDK 23 Keystore Player Monitoring tool (Prometheus) Configuration Volume Volume Java Management Service
  • 13. Let’s play and Observe!
  • 14. Stay Tuned For More! Inside.java Dev.java youtube.com/java
  • 15. Useful links • Monitoring Java Application Security with JDK tools and JFR Events: https://dev.java/learn/security/monitor/ • Stack Walker ep 2 on JFR https://inside.java/2023/05/14/stackwalker-02/ • Introduction to JDK Mission Control: https://youtu.be/7-RKyp05m8M • JMC9 – What’s new?: https://youtu.be/KzWwGSRxIi4 • Continuous monitoring with JDK Flight Recorder: https://www.infoq.com/presentations/monitoring-jdk-jfr/ • Code used during demo: https://github.com/ammbra/tictactoe • OCI Instance installation: https://inside.java/2024/07/16/build-oci-instance-with-java-concepts/ • Compose files in OCI: https://docs.oracle.com/en/learn/podman-compose/index.html#confirm-podman-compose-is-working • More articles on Java Management Service: https://inside.java/tag/cloud • Gunnar Morling’s article on custom JFR events: https://www.morling.dev/blog/rest-api-monitoring-with-custom-jdk-flight- recorder-events/