SlideShare a Scribd company logo
From Java 17 to 21
A Showcase of JDK Security
Enhancements
Java Champion Alumni, Certified Architect
Senior Developer Advocate at Oracle
Passionate about solving complex scenarios
involving Java and Kubernetes.
ammbra1508 ammbra1508.mastondon.social
6-Month Release Cadence
Image by EdenMoon from Pixabay
What Significant Changes
Occurred in JDK Security after
Java 17?
JDK Security Impact
☕ Over time, most algorithms weaken and can be exploited more easily.
☕ Lifetime of a JDK release can outlast the viable lifetime of many cryptographic algorithms.
☕ The Java Platform continuously gets enhancements to its tooling, supported cryptographic
algorithms and protocols.
☕ All changes are done for you to build and deploy applications that use modern and strong
algorithms and protocols.
Java Security Overview
Java Security Components (1)
Java Language and Runtime Security
Cryptography (JCA/JCE) PKI
SASL XML Signature
GSSAPI/Kerberos
Authn/Authz (JAAS)
keytool jarsigner kinit, klist, ktab Tools
APIs and
Libraries
TLS/DTLS (JSSE) Signed JARs
Java Security Components (2)
Java Language and Runtime Security
Cryptography (JCA/JCE) PKI
SASL XML Signature
GSSAPI/Kerberos
Authn/Authz (JAAS)
keytool jarsigner kinit, klist, ktab Tools
APIs and
Libraries
TLS/DTLS (JSSE) Signed JARs
Image by Myriams-Fotos from Pixabay
Modern Cryptographic Algorithms
Larger Key Sizes to Improve Resilience
Algorithm Specification Before JDK 19 In JDK 20 & 21
AES Cipher FIPS Pub 197 128 bit
256 bit (if allowed by
policy)
ECDH NIST SP 800-56A Curve P-256 Curve P-384
ECDSA Signature FIPS Pub 186-4 Curve P-256 Curve P-384
SHA MessageDigest FIPS Pub 180-4 SHA-256 SHA-384
DH KevExchange IETF RFC 3526 2048-bit 3072-bit
RSA/RSAPSS
Signature
NIST SP 800-56B
rev 1
2048-bit 3072-bit
Image by TheDigitalArtist from Pixabay
A Potential Threat of Quantum
Computers?
First Post-Quantum Cryptography
Algorithms in OpenJDK
☕ Leighton-Micali Signature system (LMS) is a stateful hash-based signature (HBS) scheme.
☕ The Hierarchical Signature System (HSS) is the multi-tree variant of LMS.
☕ HSS/LMS is one of the two quantum resistant signature algorithms standardized by NIST.
☕ As use cases, HSS/LMS is suitable for software or firmware signing .
☕ HMS/LMS key and signature generation should be performed on hardware.
HSS/LMS Signature Verification
Implementation ㉑
HSS/LMS is the multi-tree
variant of the
Leighton-Micali (LMS)
system
New KeyFactory and
Signature verification
implementation of HSS/LMS
Only Signature verification
is supported *
* signature generation should be performed in hardware only
Read a HSS/LMS Public Key from its
Serialized Format
// Verification provider may be different,
// so convert encoded public key into a type it supports
var ALG = "HSS/LMS";
var instance = KeyFactory.getInstance(ALG);
var keySpec = new X509EncodedKeySpec(encodedPublicKey);
var generatedPublicKey = instance.generatePublic(keySpec);
Verify the Validity of a Signature that
Uses HSS/LMS Algorithm
// Verification provider may be different,
// so convert encoded public key into a type it supports
var ALG = "HSS/LMS";
var msg = "hello, world".getBytes(StandardCharsets.UTF_8);
var instance = KeyFactory.getInstance(ALG);
var keySpec = new X509EncodedKeySpec(encodedPublicKey);
var generatedPublicKey = instance.generatePublic(keySpec);
var signature = Signature.getInstance(ALG);
signature.initVerify(generatedPublicKey);
signature.update(msg);
System.out.println(signature.verify(sig));
Restricted Weak Algorithms
SHA-1 JARs are Disabled by Default ⑱
$ jarsigner -verify -verbose old.jar
57 Wed Jul 12 14:25:08 EDT 2023 META-INF/MANIFEST.MF
249 Wed Jul 12 14:25:08 EDT 2023 META-INF/SIGNER.SF
2005 Wed Jul 12 14:25:08 EDT 2023 META-INF/SIGNER.RSA
m ? 1 Wed Jul 12 14:24:16 EDT 2023 A
s = signature was verified
m = entry is listed in manifest
k = at least one certificate was found in keystore
? = unsigned entry
- Signed by "CN=signer"
Digest algorithm: SHA-1 (disabled)
Signature algorithm: SHA256withRSA, 2048-bit key
WARNING: The jar will be treated as unsigned, because it is signed with a weak algorithm that is now disabled by the
security property:
jdk.jar.disabledAlgorithms=MD2, MD5, RSA keySize < 1024, DSA keySize < 1024, SHA1 denyAfter 2019-01-01
Change introduced in JDK 18, backported to CPU 22_10
Disabled Weak TLS Algorithms
☕ 3DES cipher suites have been removed from the default enabled TLS cipher suites. ⑲
☕ TLS_ECDH cipher suites are disabled because they do not preserve forward-secrecy. ⑳
☕ The DTLS 1.0 protocol has various weaknesses and is no longer recommended. ⑳
Restriction Rules for Weak Algorithms
☕ In krb5.conf for Kerberos since that's the standard way among Kerberos vendors.
☕ As security properties in the $JDK_HOME/conf/security/java.security file for:
☕ JAR verification
☕ CertPath and
☕ TLS
Removed Weak Kerberos Encryption
Types
#krb5.conf
[libdefaults]
allow_weak_crypto = false
permitted_enctypes =
es256-cts-hmac-sha1-96
aes128-cts-hmac-sha1-96
des3-cbc-sha1 …
☕ DES,3DES and RC4 have been removed
from the default list of Kerberos encryption
types. ⑱
⛔ If allow_weak_crypto = true, any of the
weak encryption types could then be used!
☕ You can selectively enable weak algorithms in
Kerberos, by specifically adding the weak
algorithm(s) name to permitted_enctypes in
krb5.conf.
Image by EdenMoon from Pixabay
Re-enabling Any Weak Encryption
Type is NOT Recommended and
You Do That at Your Own Risk!
JDK Security Configuration Aftermath
jdk.tls.disabledAlgorithms=SSLv3, TLSv1, TLSv1.1, DTLSv1.0, RC4, DES, MD5withRSA, DH
keySize < 1024, EC keySize < 224, 3DES_EDE_CBC, anon, NULL, ECDH
jdk.tls.legacyAlgorithms=NULL, anon, RC4, DES, 3DES_EDE_CBC
jdk.certpath.disabledAlgorithms=MD2, MD5, SHA1 jdkCA & usage TLSServer,RSA keySize
< 1024, DSA keySize < 1024, EC keySize < 224, SHA1 usage SignedJAR & denyAfter
2019-01-01
jdk.security.legacyAlgorithms=…
jdk.jar.disabledAlgorithms=...
The Security Manager Influence
☕ Originally designed as a sandbox for running potentially untrusted applets.
☕ Later enhanced to support a fine-grained permission model.
☕ Was not widely used and JDK 17 deprecated for removal the Security Manager (JEP 411).
☕ Several APIs related to the Security Manager were deprecated for removal.
☕ Since JDK 18 the java.security.manager system property has disallow default value.
Security API Enhancements
Replacement of JAAS APIs ⑱
☕ Some JAAS APIs depend on Security Manager related API.
☕ JEP 411 outlined plans to provide replacement JAAS APIs.
🆕 Subject::callAs() is a replacement for JAAS Subject::doAs() API.
🆕 Subject::current() is a replacement for JAAS Subject::getSubject()API.
Replacement of JAAS APIs (example)
Subject s1 = new Subject();
// before
Subject.doAs(s1,
(PrivilegedExceptionAction<Void>)() -> {
AccessControlContext acc = AccessController.getContext();
Subject s2 = Subject.getSubject(acc);
return null;
});
// after
Subject.callAs(s1, () -> {
Subject s2 = Subject.current();
return null;
});
Improved KeyStore Attributes Access ⑱
// before
KeyStore ks = KeyStore.getInstance(KeyStore.getDefaultType());
KeyStore.Entry entry = ks.getEntry(alias, new
KeyStore.PasswordProtection(keyPassword));
Set<KeyStore.Entry.Attribute> attributes = entry.getAttributes();
// after
KeyStore ks = KeyStore.getInstance(KeyStore.getDefaultType());
Set<KeyStore.Entry.Attribute> attributes = ks.getAttributes(alias);
APIs to Customize TLS and DTLS
Signature Schemes ⑲
SSLParameters sslParams = new SSLParameters();
sslParams.setEndpointIdentificationAlgorithm("HTTPS");
String[] sigSchemes = {"rsa_pkcs1_sha512", "rsa_pkcs1_sha384"};
sslParams.setSignatureSchemes(sigSchemes);
New javax.net.ssl.SSLParameters::setSignatureSchemes
APIs to Customize TLS and DTLS Named
Groups ⑳
SSLParameters params = new SSLParameters();
params.setNamedGroups(new String[] { "x25519", "secp256r1" });
New javax.net.ssl.SSLParameters::setNamedGroups
Image by TheDigitalArtist from Pixabay
A Potential Threat of Quantum
Computers?
Key Encapsulation Mechanism (KEM)
☕ Also a scheme with public and private keys.
☕ The sender has receiver’s public key.
☕ KEM uses properties of the public key to derive a related symmetric key.
☕ The two parties can securely negotiate a shared secret.
☕ The shared secret can then be used in secure communication with a symmetric cipher.
Encapsulation Decapsulation
key encapsulation message
Public key Private key
Sender Encrypt Decrypt Receiver
plaintext plaintext
cyperthext
Receiver
Sender
Key Encapsulation Mechanism API ㉑
☕ Key pair generation function
This function is already covered by the KeyPairGenerator API.
☕ Key encapsulation
Encapsulate(public_key) -> key_encapsulation_message, shared_secret
☕ Key decapsulation
Decapsulate(private_key, key_encapsulation_message) -> shared_secret
Support for the EdDSA Signature
Algorithm in XML Signatures ㉑
☕ XML Signatures can now be signed or verified with the EdDSA algorithm.
🆕 Standard SignatureMethod URIs
🆕 SignatureMethod.ED25519
🆕 SignatureMethod.ED448
Also backported to JDK 8u,11u, 17u
Toggle XML Signature Secure Validation Mode㉑
☕ Secure processing mode is enabled by default.
☕ Stricter constraints for validating XML signatures are defined by a new security property.
🆕 jdk.xml.dsig.secureValidationPolicy security property
☕ If org.jcp.xml.dsig.secureValidation=true, validation of XML signatures is subject to stricter
constraints as defined by jdk.xml.dsig.secureValidationPolicy.
Also backported to JDK 8u,11u, 17u
Fine Tune Usage of XPath here()Function ㉑
<!-- select node-sets for use in XPath
transforms..-->
<XPath xmlns:dsig="&dsig;">
count(ancestor-or-self::dsig:Signature |
here()/ancestor::dsig:Signature[1]) >
count(ancestor-or-self::dsig:Signature)</XPat
h>
☕ here() is not a standard XPath function
🆕 jdk.xml.dsig.hereFunctionSupported
☕ The security property has default value true.
Also backported to JDK 8u,11u, 17u
OS Specific Integrations
Listing Certificates on Windows
try {
KeyStore ks = KeyStore.getInstance("Windows-MY");
ks.load(null, null) ;
Enumeration<String> en = ks.aliases() ;
while (en.hasMoreElements()) {
String aliasKey = en.nextElement().toString() ;
X509Certificate cert = (X509Certificate) ks.getCertificate(aliasKey);
System.out.println(" Certificate subjectDN : " + cert.getSubjectDN());
System.out.println(" Certificate issuerDN : " + cert.getIssuerDN());
}
} catch (Exception e) {
throw new RuntimeException("Exception while reading certificates", e);
}
New Windows KeyStore Types ⑲
try {
KeyStore ks = KeyStore.getInstance("Windows-MY-CURRENTUSER");
ks.load(null, null) ;
Enumeration<String> en = ks.aliases() ;
while (en.hasMoreElements()) {
String aliasKey = en.nextElement().toString() ;
X509Certificate cert = (X509Certificate) ks.getCertificate(aliasKey);
System.out.println(" Certificate subjectDN : " + cert.getSubjectDN());
System.out.println(" Certificate issuerDN : " + cert.getIssuerDN());
}
} catch (Exception e) {
throw new RuntimeException("Exception while reading certificates", e);
}
MacOS KeychainStore Can Show Only
Trusted Certificates ㉑
KeyStore keyStore = KeyStore.getInstance("KeychainStore", "Apple");
keyStore.load(null, null);
keyStore.aliases().asIterator().forEachRemaining(System.out::println);
System.out.println("size:" + keyStore.size());
// before JDK 21 prints user domain certificates
// JDK 21+, prints proper trust certificates in user and/or admin domain
Change backported to JDK 11, 17
Updates to the JDK cacerts File
☕ No longer uses obsolete proprietary JKS format
☕ Uses password-less PKCS12 format
☕ Public certificates no longer encrypted
☕ No longer need to specify/change a default password (“changeit”)
Tools Updates
Keytool Improvements (1)
☕ Uses larger default key sizes in -genkeypair if -keysize option is not specified
$ keytool -genkeypair -keyalg RSA -keystore keystore
...
Generating 3.072 bit RSA key pair and self-signed certificate
(SHA384withRSA) with a validity of 90 days
Keytool Improvements (2)
☕ Uses larger default key sizes in -genkeypair if -keysize option is not specified.
☕ -genseckey and -importpass options warn when using weak password-based encryption
algorithms. ㉑
$ keytool -genseckey -alias secret -keypass changeit -keyalg RC4 
-keysize 128 -keystore example.p12 -storepass changeit 
-storetype PKCS12 -v
Generated 128-bit ARCFOUR secret key [Storing example.p12]
Warning: The generated secret key uses the ARCFOUR algorithm which is
considered a security risk.
Jarsigner Improvements
☕ Strengthens the default digest and signature algorithms when signing.
☕ SHA-1 JARs are disabled by default (except those timestamped prior to 2019-01-01).
☕ Specify the class path of an alternate keystore implementation via –providerPath. ⑲
$ jarsigner -keystore keystore -storetype CUSTOMKS 
-providerPath /path/to/test.myks 
-providerClass my.custom.AnotherProvider 
signed.jar mykey
Recording Initial Security Properties With
JDK Flight Recorder
🆕 jdk.InitialSecurityProperty cryptographic event
☕ Enabled by default in default.jfc and profile.jfc.
☕ Captures info on initial security properties when loaded via java.security.Security class.
Disabling Initial Security Properties Event
$ jfr configure jdk.InitialSecurityProperty#enabled=false
# or on launch
$ java -XX:StartFlightRecording:settings=none,
+jdk.InitialSecurityProperty#enabled=false
Recording Details About Security Provider
Instance Requests
🆕 jdk.SecurityProviderService cryptographic event
☕ Disabled by default in default.jfc and profile.jfc.
☕ Records info on java.security.Provider.getService(…) calls.
Enabling Security Provider Instance
Requests Event
$ jfr configure jdk.SecurityProviderService#enabled=true
# or on launch
$ java -XX:StartFlightRecording:settings=none,
+jdk.SecurityProviderService#enabled=true
Image by geralt from Pixabay
Java Crypto Roadmap
(https://java.com/cryptoroadmap)
☕ Informs the public about upcoming security changes to update releases.
☕ Each change improves security in some way:
☕ Restrict or disable a weak algorithm,
☕ A default can be changed to a stronger setting,
☕ Support for a stronger algorithm can be added,
☕ Or improve tools to help you diagnose security issues.
☕ Yet, a change may have some compatibility risk:
☕ Advance notice (usually 3-6 months), except in case of a severe vulnerability.
☕ Testing instructions, if applicable.
Stay Tuned for More
Inside.java
Dev.java youtube.com/java
Useful Links
☕ JEP 411 about deprecation of the Security Manager for removal https://openjdk.org/jeps/411
☕ Sean Mullan’s blog on JDK security changes: https://seanjmullan.org/blog/
☕ Java Security Standard Algorithm Names https://docs.oracle.com/en/java/javase/21/docs/specs/security/standard-names.html
☕ Java Security Guide https://docs.oracle.com/en/java/javase/21/security/java-security-overview1.html
☕ Java CryptoRoadmap https://www.java.com/en/jre-jdk-cryptoroadmap.html
☕ Java 21 Tool Enhancements: Better Across the Board #RoadTo21 https://www.youtube.com/embed/nFJBVuaIsRg
☕ Java 21 Security Updates #RoadTo21 https://www.youtube.com/embed/kSjdZZsHM04

More Related Content

PDF
Java 21 and Beyond- A Roadmap of Innovations
PPT
Sql injection
PDF
A Glance At The Java Performance Toolbox
PPT
Introduction to Eclipse IDE
PPTX
Zero Credential Development with Managed Identities for Azure resources
PDF
AWS IAM Tutorial | Identity And Access Management (IAM) | AWS Training Videos...
PDF
Apache Jackrabbit Oak - Scale your content repository to the cloud
PPTX
Java 21 and Beyond- A Roadmap of Innovations
Sql injection
A Glance At The Java Performance Toolbox
Introduction to Eclipse IDE
Zero Credential Development with Managed Identities for Azure resources
AWS IAM Tutorial | Identity And Access Management (IAM) | AWS Training Videos...
Apache Jackrabbit Oak - Scale your content repository to the cloud

What's hot (20)

PPTX
Monitor Cloud Resources using Alerts & Insights
PPTX
PDF
Secure coding presentation Oct 3 2020
PDF
SQL Injection: complete walkthrough (not only) for PHP developers
PDF
Testing with Spring: An Introduction
PPT
Source Code management System
PPTX
React workshop presentation
PDF
AWS Systems Manager
PPTX
Coding conventions
PDF
Azure Security Overview
PPTX
seminar report on Sql injection
PPTX
Coding standards for java
PPTX
Azure container instances
PDF
CNIT 129S: 11: Attacking Application Logic
PPTX
Web Application Performance
PPTX
Managing Updates with System Center Configuration Manager 2012
PDF
core-profile_jakartaOne2022.pdf
PPTX
Ruby on Rails Penetration Testing
PPT
Cloud Computing Integration Introduction
PPSX
Broken Authentication & authorization
Monitor Cloud Resources using Alerts & Insights
Secure coding presentation Oct 3 2020
SQL Injection: complete walkthrough (not only) for PHP developers
Testing with Spring: An Introduction
Source Code management System
React workshop presentation
AWS Systems Manager
Coding conventions
Azure Security Overview
seminar report on Sql injection
Coding standards for java
Azure container instances
CNIT 129S: 11: Attacking Application Logic
Web Application Performance
Managing Updates with System Center Configuration Manager 2012
core-profile_jakartaOne2022.pdf
Ruby on Rails Penetration Testing
Cloud Computing Integration Introduction
Broken Authentication & authorization
Ad

Similar to From Java 17 to 21- A Showcase of JDK Security Enhancements (20)

PDF
Gartner Security & Risk Management Summit 2018
PDF
DPDK IPSec Security Gateway Application
PDF
Protect data at rest with negligible impact on NVMe disk performance metrics ...
PDF
DEF CON 23 - Sean - metcalf - red vs blue ad attack and defense
PDF
[CB20] Vulnerabilities of Machine Learning Infrastructure by Sergey Gordeychik
PDF
PDF
Securing Cassandra for Compliance
PDF
Hardening cassandra q2_2016
PDF
Hashicorp Vault: Open Source Secrets Management at #OPEN18
PDF
Deployment guide c07_554713
PPT
lamacchia-palladium
PPT
SSL Implementation - IBM MQ - Secure Communications
PPTX
DPDK IPSec performance benchmark ~ Georgii Tkachuk
PDF
MongoDB .local Bengaluru 2019: New Encryption Capabilities in MongoDB 4.2: A ...
PDF
Securing Millions of Devices
PPTX
How to Secure Your Scylla Deployment: Authorization, Encryption, LDAP Authent...
PPTX
Q Con New York 2015 Presentation - Conjur
PDF
Gartner Security & Risk Management Summit 2018
DPDK IPSec Security Gateway Application
Protect data at rest with negligible impact on NVMe disk performance metrics ...
DEF CON 23 - Sean - metcalf - red vs blue ad attack and defense
[CB20] Vulnerabilities of Machine Learning Infrastructure by Sergey Gordeychik
Securing Cassandra for Compliance
Hardening cassandra q2_2016
Hashicorp Vault: Open Source Secrets Management at #OPEN18
Deployment guide c07_554713
lamacchia-palladium
SSL Implementation - IBM MQ - Secure Communications
DPDK IPSec performance benchmark ~ Georgii Tkachuk
MongoDB .local Bengaluru 2019: New Encryption Capabilities in MongoDB 4.2: A ...
Securing Millions of Devices
How to Secure Your Scylla Deployment: Authorization, Encryption, LDAP Authent...
Q Con New York 2015 Presentation - Conjur
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
Monitoring Java Application Security with JDK Tools and JFR Events
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
Monitoring Java Application Security with JDK Tools and JFR Events
PDF
Java 23 and Beyond - A Roadmap Of Innovations
PDF
Enhancing Productivity and Insight A Tour of JDK Tools Progress Beyond Java 17
PDF
Monitoring Java Application Security with JDK Tools and JFR Events
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
Monitoring Java Application Security with JDK Tools and JFR Events.pdf
PDF
Enhancing Productivity and Insight A Tour of JDK Tools Progress Beyond Java 17
PDF
Java 21 Language Features and Beyond
PDF
A Glance At The Java Performance Toolbox.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
Monitoring Java Application Security with JDK Tools and JFR Events
Enhancing Productivity and Insight A Tour of JDK Tools Progress Beyond Java 17
From native code gems to Java treasures with jextract
Monitoring Java Application Security with JDK Tools and JFR Events
Java 23 and Beyond - A Roadmap Of Innovations
Enhancing Productivity and Insight A Tour of JDK Tools Progress Beyond Java 17
Monitoring Java Application Security with JDK Tools and JFR Events
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
Monitoring Java Application Security with JDK Tools and JFR Events.pdf
Enhancing Productivity and Insight A Tour of JDK Tools Progress Beyond Java 17
Java 21 Language Features and Beyond
A Glance At The Java Performance Toolbox.pdf

Recently uploaded (20)

PDF
Encapsulation theory and applications.pdf
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
Machine learning based COVID-19 study performance prediction
PDF
Review of recent advances in non-invasive hemoglobin estimation
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Approach and Philosophy of On baking technology
PDF
Encapsulation_ Review paper, used for researhc scholars
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
NewMind AI Monthly Chronicles - July 2025
PDF
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Network Security Unit 5.pdf for BCA BBA.
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
KodekX | Application Modernization Development
PDF
Modernizing your data center with Dell and AMD
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Encapsulation theory and applications.pdf
Dropbox Q2 2025 Financial Results & Investor Presentation
Machine learning based COVID-19 study performance prediction
Review of recent advances in non-invasive hemoglobin estimation
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
20250228 LYD VKU AI Blended-Learning.pptx
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
MYSQL Presentation for SQL database connectivity
Approach and Philosophy of On baking technology
Encapsulation_ Review paper, used for researhc scholars
“AI and Expert System Decision Support & Business Intelligence Systems”
NewMind AI Monthly Chronicles - July 2025
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Building Integrated photovoltaic BIPV_UPV.pdf
Network Security Unit 5.pdf for BCA BBA.
Understanding_Digital_Forensics_Presentation.pptx
KodekX | Application Modernization Development
Modernizing your data center with Dell and AMD
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf

From Java 17 to 21- A Showcase of JDK Security Enhancements

  • 1. From Java 17 to 21 A Showcase of JDK Security Enhancements
  • 2. Java Champion Alumni, Certified Architect Senior Developer Advocate at Oracle Passionate about solving complex scenarios involving Java and Kubernetes. ammbra1508 ammbra1508.mastondon.social
  • 4. Image by EdenMoon from Pixabay What Significant Changes Occurred in JDK Security after Java 17?
  • 5. JDK Security Impact ☕ Over time, most algorithms weaken and can be exploited more easily. ☕ Lifetime of a JDK release can outlast the viable lifetime of many cryptographic algorithms. ☕ The Java Platform continuously gets enhancements to its tooling, supported cryptographic algorithms and protocols. ☕ All changes are done for you to build and deploy applications that use modern and strong algorithms and protocols.
  • 7. Java Security Components (1) Java Language and Runtime Security Cryptography (JCA/JCE) PKI SASL XML Signature GSSAPI/Kerberos Authn/Authz (JAAS) keytool jarsigner kinit, klist, ktab Tools APIs and Libraries TLS/DTLS (JSSE) Signed JARs
  • 8. Java Security Components (2) Java Language and Runtime Security Cryptography (JCA/JCE) PKI SASL XML Signature GSSAPI/Kerberos Authn/Authz (JAAS) keytool jarsigner kinit, klist, ktab Tools APIs and Libraries TLS/DTLS (JSSE) Signed JARs
  • 9. Image by Myriams-Fotos from Pixabay
  • 11. Larger Key Sizes to Improve Resilience Algorithm Specification Before JDK 19 In JDK 20 & 21 AES Cipher FIPS Pub 197 128 bit 256 bit (if allowed by policy) ECDH NIST SP 800-56A Curve P-256 Curve P-384 ECDSA Signature FIPS Pub 186-4 Curve P-256 Curve P-384 SHA MessageDigest FIPS Pub 180-4 SHA-256 SHA-384 DH KevExchange IETF RFC 3526 2048-bit 3072-bit RSA/RSAPSS Signature NIST SP 800-56B rev 1 2048-bit 3072-bit
  • 12. Image by TheDigitalArtist from Pixabay A Potential Threat of Quantum Computers?
  • 13. First Post-Quantum Cryptography Algorithms in OpenJDK ☕ Leighton-Micali Signature system (LMS) is a stateful hash-based signature (HBS) scheme. ☕ The Hierarchical Signature System (HSS) is the multi-tree variant of LMS. ☕ HSS/LMS is one of the two quantum resistant signature algorithms standardized by NIST. ☕ As use cases, HSS/LMS is suitable for software or firmware signing . ☕ HMS/LMS key and signature generation should be performed on hardware.
  • 14. HSS/LMS Signature Verification Implementation ㉑ HSS/LMS is the multi-tree variant of the Leighton-Micali (LMS) system New KeyFactory and Signature verification implementation of HSS/LMS Only Signature verification is supported * * signature generation should be performed in hardware only
  • 15. Read a HSS/LMS Public Key from its Serialized Format // Verification provider may be different, // so convert encoded public key into a type it supports var ALG = "HSS/LMS"; var instance = KeyFactory.getInstance(ALG); var keySpec = new X509EncodedKeySpec(encodedPublicKey); var generatedPublicKey = instance.generatePublic(keySpec);
  • 16. Verify the Validity of a Signature that Uses HSS/LMS Algorithm // Verification provider may be different, // so convert encoded public key into a type it supports var ALG = "HSS/LMS"; var msg = "hello, world".getBytes(StandardCharsets.UTF_8); var instance = KeyFactory.getInstance(ALG); var keySpec = new X509EncodedKeySpec(encodedPublicKey); var generatedPublicKey = instance.generatePublic(keySpec); var signature = Signature.getInstance(ALG); signature.initVerify(generatedPublicKey); signature.update(msg); System.out.println(signature.verify(sig));
  • 18. SHA-1 JARs are Disabled by Default ⑱ $ jarsigner -verify -verbose old.jar 57 Wed Jul 12 14:25:08 EDT 2023 META-INF/MANIFEST.MF 249 Wed Jul 12 14:25:08 EDT 2023 META-INF/SIGNER.SF 2005 Wed Jul 12 14:25:08 EDT 2023 META-INF/SIGNER.RSA m ? 1 Wed Jul 12 14:24:16 EDT 2023 A s = signature was verified m = entry is listed in manifest k = at least one certificate was found in keystore ? = unsigned entry - Signed by "CN=signer" Digest algorithm: SHA-1 (disabled) Signature algorithm: SHA256withRSA, 2048-bit key WARNING: The jar will be treated as unsigned, because it is signed with a weak algorithm that is now disabled by the security property: jdk.jar.disabledAlgorithms=MD2, MD5, RSA keySize < 1024, DSA keySize < 1024, SHA1 denyAfter 2019-01-01 Change introduced in JDK 18, backported to CPU 22_10
  • 19. Disabled Weak TLS Algorithms ☕ 3DES cipher suites have been removed from the default enabled TLS cipher suites. ⑲ ☕ TLS_ECDH cipher suites are disabled because they do not preserve forward-secrecy. ⑳ ☕ The DTLS 1.0 protocol has various weaknesses and is no longer recommended. ⑳
  • 20. Restriction Rules for Weak Algorithms ☕ In krb5.conf for Kerberos since that's the standard way among Kerberos vendors. ☕ As security properties in the $JDK_HOME/conf/security/java.security file for: ☕ JAR verification ☕ CertPath and ☕ TLS
  • 21. Removed Weak Kerberos Encryption Types #krb5.conf [libdefaults] allow_weak_crypto = false permitted_enctypes = es256-cts-hmac-sha1-96 aes128-cts-hmac-sha1-96 des3-cbc-sha1 … ☕ DES,3DES and RC4 have been removed from the default list of Kerberos encryption types. ⑱ ⛔ If allow_weak_crypto = true, any of the weak encryption types could then be used! ☕ You can selectively enable weak algorithms in Kerberos, by specifically adding the weak algorithm(s) name to permitted_enctypes in krb5.conf.
  • 22. Image by EdenMoon from Pixabay Re-enabling Any Weak Encryption Type is NOT Recommended and You Do That at Your Own Risk!
  • 23. JDK Security Configuration Aftermath jdk.tls.disabledAlgorithms=SSLv3, TLSv1, TLSv1.1, DTLSv1.0, RC4, DES, MD5withRSA, DH keySize < 1024, EC keySize < 224, 3DES_EDE_CBC, anon, NULL, ECDH jdk.tls.legacyAlgorithms=NULL, anon, RC4, DES, 3DES_EDE_CBC jdk.certpath.disabledAlgorithms=MD2, MD5, SHA1 jdkCA & usage TLSServer,RSA keySize < 1024, DSA keySize < 1024, EC keySize < 224, SHA1 usage SignedJAR & denyAfter 2019-01-01 jdk.security.legacyAlgorithms=… jdk.jar.disabledAlgorithms=...
  • 24. The Security Manager Influence ☕ Originally designed as a sandbox for running potentially untrusted applets. ☕ Later enhanced to support a fine-grained permission model. ☕ Was not widely used and JDK 17 deprecated for removal the Security Manager (JEP 411). ☕ Several APIs related to the Security Manager were deprecated for removal. ☕ Since JDK 18 the java.security.manager system property has disallow default value.
  • 26. Replacement of JAAS APIs ⑱ ☕ Some JAAS APIs depend on Security Manager related API. ☕ JEP 411 outlined plans to provide replacement JAAS APIs. 🆕 Subject::callAs() is a replacement for JAAS Subject::doAs() API. 🆕 Subject::current() is a replacement for JAAS Subject::getSubject()API.
  • 27. Replacement of JAAS APIs (example) Subject s1 = new Subject(); // before Subject.doAs(s1, (PrivilegedExceptionAction<Void>)() -> { AccessControlContext acc = AccessController.getContext(); Subject s2 = Subject.getSubject(acc); return null; }); // after Subject.callAs(s1, () -> { Subject s2 = Subject.current(); return null; });
  • 28. Improved KeyStore Attributes Access ⑱ // before KeyStore ks = KeyStore.getInstance(KeyStore.getDefaultType()); KeyStore.Entry entry = ks.getEntry(alias, new KeyStore.PasswordProtection(keyPassword)); Set<KeyStore.Entry.Attribute> attributes = entry.getAttributes(); // after KeyStore ks = KeyStore.getInstance(KeyStore.getDefaultType()); Set<KeyStore.Entry.Attribute> attributes = ks.getAttributes(alias);
  • 29. APIs to Customize TLS and DTLS Signature Schemes ⑲ SSLParameters sslParams = new SSLParameters(); sslParams.setEndpointIdentificationAlgorithm("HTTPS"); String[] sigSchemes = {"rsa_pkcs1_sha512", "rsa_pkcs1_sha384"}; sslParams.setSignatureSchemes(sigSchemes); New javax.net.ssl.SSLParameters::setSignatureSchemes
  • 30. APIs to Customize TLS and DTLS Named Groups ⑳ SSLParameters params = new SSLParameters(); params.setNamedGroups(new String[] { "x25519", "secp256r1" }); New javax.net.ssl.SSLParameters::setNamedGroups
  • 31. Image by TheDigitalArtist from Pixabay A Potential Threat of Quantum Computers?
  • 32. Key Encapsulation Mechanism (KEM) ☕ Also a scheme with public and private keys. ☕ The sender has receiver’s public key. ☕ KEM uses properties of the public key to derive a related symmetric key. ☕ The two parties can securely negotiate a shared secret. ☕ The shared secret can then be used in secure communication with a symmetric cipher.
  • 33. Encapsulation Decapsulation key encapsulation message Public key Private key Sender Encrypt Decrypt Receiver plaintext plaintext cyperthext Receiver Sender
  • 34. Key Encapsulation Mechanism API ㉑ ☕ Key pair generation function This function is already covered by the KeyPairGenerator API. ☕ Key encapsulation Encapsulate(public_key) -> key_encapsulation_message, shared_secret ☕ Key decapsulation Decapsulate(private_key, key_encapsulation_message) -> shared_secret
  • 35. Support for the EdDSA Signature Algorithm in XML Signatures ㉑ ☕ XML Signatures can now be signed or verified with the EdDSA algorithm. 🆕 Standard SignatureMethod URIs 🆕 SignatureMethod.ED25519 🆕 SignatureMethod.ED448 Also backported to JDK 8u,11u, 17u
  • 36. Toggle XML Signature Secure Validation Mode㉑ ☕ Secure processing mode is enabled by default. ☕ Stricter constraints for validating XML signatures are defined by a new security property. 🆕 jdk.xml.dsig.secureValidationPolicy security property ☕ If org.jcp.xml.dsig.secureValidation=true, validation of XML signatures is subject to stricter constraints as defined by jdk.xml.dsig.secureValidationPolicy. Also backported to JDK 8u,11u, 17u
  • 37. Fine Tune Usage of XPath here()Function ㉑ <!-- select node-sets for use in XPath transforms..--> <XPath xmlns:dsig="&dsig;"> count(ancestor-or-self::dsig:Signature | here()/ancestor::dsig:Signature[1]) > count(ancestor-or-self::dsig:Signature)</XPat h> ☕ here() is not a standard XPath function 🆕 jdk.xml.dsig.hereFunctionSupported ☕ The security property has default value true. Also backported to JDK 8u,11u, 17u
  • 39. Listing Certificates on Windows try { KeyStore ks = KeyStore.getInstance("Windows-MY"); ks.load(null, null) ; Enumeration<String> en = ks.aliases() ; while (en.hasMoreElements()) { String aliasKey = en.nextElement().toString() ; X509Certificate cert = (X509Certificate) ks.getCertificate(aliasKey); System.out.println(" Certificate subjectDN : " + cert.getSubjectDN()); System.out.println(" Certificate issuerDN : " + cert.getIssuerDN()); } } catch (Exception e) { throw new RuntimeException("Exception while reading certificates", e); }
  • 40. New Windows KeyStore Types ⑲ try { KeyStore ks = KeyStore.getInstance("Windows-MY-CURRENTUSER"); ks.load(null, null) ; Enumeration<String> en = ks.aliases() ; while (en.hasMoreElements()) { String aliasKey = en.nextElement().toString() ; X509Certificate cert = (X509Certificate) ks.getCertificate(aliasKey); System.out.println(" Certificate subjectDN : " + cert.getSubjectDN()); System.out.println(" Certificate issuerDN : " + cert.getIssuerDN()); } } catch (Exception e) { throw new RuntimeException("Exception while reading certificates", e); }
  • 41. MacOS KeychainStore Can Show Only Trusted Certificates ㉑ KeyStore keyStore = KeyStore.getInstance("KeychainStore", "Apple"); keyStore.load(null, null); keyStore.aliases().asIterator().forEachRemaining(System.out::println); System.out.println("size:" + keyStore.size()); // before JDK 21 prints user domain certificates // JDK 21+, prints proper trust certificates in user and/or admin domain Change backported to JDK 11, 17
  • 42. Updates to the JDK cacerts File ☕ No longer uses obsolete proprietary JKS format ☕ Uses password-less PKCS12 format ☕ Public certificates no longer encrypted ☕ No longer need to specify/change a default password (“changeit”)
  • 44. Keytool Improvements (1) ☕ Uses larger default key sizes in -genkeypair if -keysize option is not specified $ keytool -genkeypair -keyalg RSA -keystore keystore ... Generating 3.072 bit RSA key pair and self-signed certificate (SHA384withRSA) with a validity of 90 days
  • 45. Keytool Improvements (2) ☕ Uses larger default key sizes in -genkeypair if -keysize option is not specified. ☕ -genseckey and -importpass options warn when using weak password-based encryption algorithms. ㉑ $ keytool -genseckey -alias secret -keypass changeit -keyalg RC4 -keysize 128 -keystore example.p12 -storepass changeit -storetype PKCS12 -v Generated 128-bit ARCFOUR secret key [Storing example.p12] Warning: The generated secret key uses the ARCFOUR algorithm which is considered a security risk.
  • 46. Jarsigner Improvements ☕ Strengthens the default digest and signature algorithms when signing. ☕ SHA-1 JARs are disabled by default (except those timestamped prior to 2019-01-01). ☕ Specify the class path of an alternate keystore implementation via –providerPath. ⑲ $ jarsigner -keystore keystore -storetype CUSTOMKS -providerPath /path/to/test.myks -providerClass my.custom.AnotherProvider signed.jar mykey
  • 47. Recording Initial Security Properties With JDK Flight Recorder 🆕 jdk.InitialSecurityProperty cryptographic event ☕ Enabled by default in default.jfc and profile.jfc. ☕ Captures info on initial security properties when loaded via java.security.Security class.
  • 48. Disabling Initial Security Properties Event $ jfr configure jdk.InitialSecurityProperty#enabled=false # or on launch $ java -XX:StartFlightRecording:settings=none, +jdk.InitialSecurityProperty#enabled=false
  • 49. Recording Details About Security Provider Instance Requests 🆕 jdk.SecurityProviderService cryptographic event ☕ Disabled by default in default.jfc and profile.jfc. ☕ Records info on java.security.Provider.getService(…) calls.
  • 50. Enabling Security Provider Instance Requests Event $ jfr configure jdk.SecurityProviderService#enabled=true # or on launch $ java -XX:StartFlightRecording:settings=none, +jdk.SecurityProviderService#enabled=true
  • 51. Image by geralt from Pixabay
  • 52. Java Crypto Roadmap (https://java.com/cryptoroadmap) ☕ Informs the public about upcoming security changes to update releases. ☕ Each change improves security in some way: ☕ Restrict or disable a weak algorithm, ☕ A default can be changed to a stronger setting, ☕ Support for a stronger algorithm can be added, ☕ Or improve tools to help you diagnose security issues. ☕ Yet, a change may have some compatibility risk: ☕ Advance notice (usually 3-6 months), except in case of a severe vulnerability. ☕ Testing instructions, if applicable.
  • 53. Stay Tuned for More Inside.java Dev.java youtube.com/java
  • 54. Useful Links ☕ JEP 411 about deprecation of the Security Manager for removal https://openjdk.org/jeps/411 ☕ Sean Mullan’s blog on JDK security changes: https://seanjmullan.org/blog/ ☕ Java Security Standard Algorithm Names https://docs.oracle.com/en/java/javase/21/docs/specs/security/standard-names.html ☕ Java Security Guide https://docs.oracle.com/en/java/javase/21/security/java-security-overview1.html ☕ Java CryptoRoadmap https://www.java.com/en/jre-jdk-cryptoroadmap.html ☕ Java 21 Tool Enhancements: Better Across the Board #RoadTo21 https://www.youtube.com/embed/nFJBVuaIsRg ☕ Java 21 Security Updates #RoadTo21 https://www.youtube.com/embed/kSjdZZsHM04