This sheet is past its review date. Deadlines or advice may have changed since 5 Nov 2026.
Java: which APIs and framework defaults turn into vulnerabilities?
Before your next release, move to JDK 25 or 21 and Spring Boot 4.15, stop deserializing outside data into classes it names, and require Find Security Bugs or CodeQL in CI. Judge everything else by whether outside data can pick a class, become SQL, an expression or a command, reach an XML parser, a path or a URL, or slip past an authorization rule.
If you only do five things
Keep input out of queries, expressions and commands.
Use parameters for SQL and JPQL, never parse SpEL or OGNL from input, and give
ProcessBuilderan argument list. SQL, OS command and code injection rank 2nd, 9th and 10th in the CWE Top 2525.
Review a Java pull request
Where does outside data enter?
Find the controllers, listeners, uploads and batch jobs it touches. Each should bind a record made for that request, as Spring advises11, not an entity: Spring4Shell was code execution through data binding24.
Who may call it, on which record?
Ask why for each new
permitAll(), each matcher placed after a broader one8 and eachcsrfchange. Missing authorization ranks 4th in the CWE Top 2525: check who owns the record.Can data choose a class or code?
Search for
ObjectInputStream,XMLDecoder,enableDefaultTyping,activateDefaultTyping,Id.CLASS,Class.forName,parseExpressionandlookup(.Does it reach SQL, a process, XML, a path or a URL?
Check
createQueryand@Querystrings built with+,ProcessBuilder, XML parser factories,resolve(and HTTP clients given URLs from input.What does it expose?
Check
exposure.include, newSecurityFilterChainbeans, which replace Boot's actuator rules9, error details and logged secrets.
Java traps and what to use instead
ObjectInputStream.readObject()andXMLDecoder. The stream picks the classes, and gadgets on the classpath turn that into code execution12; OWASP listsXMLDecoderas unsafe for untrusted input26. If you must read Java serialization, setjdk.serialFilterto an allowlist ending in!*, withmaxbytesandmaxdepthlimits13.activateDefaultTyping()and@JsonTypeInfo(use = Id.CLASS). The JSON then names the class, and Jackson calls the validator you pass critical for security21. UseId.NAMEwith listed subtypes28. XStream with a relaxed allowlist, SnakeYAML before 2.0 withoutSafeConstructorand fastjson without safe mode share the problem26.DocumentBuilderFactory.newInstance()defaults. JDK parsers fetch external DTDs and entities unless you set secure processing explicitly14, and GeoServer's XXE (CVE-2025-58360) is exploited24. Setjdk.xml.dtd.support=denyon JDK 22 and later, ordisallow-doctype-declfor DOM and SAX andSUPPORT_DTDfalse for StAX14."WHERE id = " + idin JDBC, JPQL or a native@Query. Hibernate queries are injectable when you concatenate27. Bind?or:nameparameters, and map sort columns and directions from a fixed list: parameters can't stand for column names27.- SpEL, OGNL,
Class.forName()or JNDIlookup()fed from input. Spring saysStandardEvaluationContextmust never evaluate untrusted SpEL andSimpleEvaluationContextis only best-effort10. Spring Cloud Function (SpEL), Confluence (OGNL) and PaperCut (reflection) flaws are exploited24; Log4Shell ran LDAP code named in a log message22. Keep input in variables; map names from a fixed list. Runtime.exec(String)andsh -c.exec(String)splits on whitespace and is deprecated since JDK 1816. GiveProcessBuildera fixed program and one element per argument, put--before input that may start with a dash, and never hand input tosh -corcmd /c.base.resolve(name). An absolutenamereplacesbase, andnormalize()ignores symlinks15. RequirestartsWith(base)on the normalized path, which compares whole name elements, and ontoRealPath()where links matter15. CheckZipEntrynames too.URL.openStream()and HTTP clients given URLs from input. URL connections also openfile:URLs28; server-side request forgery ranks 22nd in the CWE Top 2525. Allowlist hosts, check resolved addresses and refuse redirects, the JDKHttpClientdefault17. Boot's clients follow them unlessspring.http.clients.redirectsisdont-follow1918.
Tools that catch it
- Find Security Bugs. Add
findsecbugs-pluginto SpotBugs and fixOBJECT_DESERIALIZATION,XXE_DOCUMENT,SQL_INJECTION_JPAandSPEL_INJECTIONfirst28. - Error Prone flags
BanJNDIas an error by default; turn on the experimentalBanSerializableReadandBanClassLoaderchecks29. - CodeQL's
java/unsafe-deserialization,java/xxeandjava/jndi-injectionqueries cover these traps30. - Dependency-Check fails builds only once you set
failBuildOnCVSS31. The supply-chain sheet covers the rest.
What you can skip
- The Security Manager. JDK 24 disabled it for good, and servers rarely used it20. Isolate untrusted code in a process or container.
- Hunting gadget classes. OWASP expects more to be found26. Stop deserializing outside data instead.
- Find Security Bugs' inventory patterns.
SPRING_ENDPOINTandSERVLET_PARAMETERflag every controller and parameter read28. Exclude them. - Escaping input for SQL, shells or SpEL yourself. Bind parameters, drop the shell and stop evaluating input instead.
What changed in 2026
- Oracle JDK 21 updates are no longer no-fee. Releases since 20 October use the OTN license; Oracle JDK 25 updates stay no-fee through September 20281. Temurin supports 21 until at least December 20292.
- Compromised eMudhra CA keys need another JDK update. Install a runtime that fixes JDK-8395690 (CVE-2026-114820) in every image, even if you updated in October; on Debian and Ubuntu, also rebuild the Java keystore4.
- Spring Boot 4.0.0 to 4.0.5 could open every endpoint in some apps on Boot's default web security (CVE-2026-40976, critical). 4.0.6 fixes it6.
- Free Spring fixes now skip Spring Security 6.5. August's critical fix for its embedded LDAP server (CVE-2026-59270) shipped free only for 7.0 and 7.17.
- Spring Boot 4.1 added SSRF protection. An
InetAddressFilterbean limits the addresses its HTTP clients may call, except through a proxy18.
What this looks like for your code
New project
- Start on JDK 25 and Spring Boot 4.1, with
.anyRequest().denyAll()as the last rule. - Set
jdk.serialFilter=!*andjdk.xml.dtd.support=denyif nothing needs serialization or DTDs. - Bind every request to a record and keep entities out of controllers.
Existing codebase
High-assurance or regulated
- Make CodeQL's
security-extendedsuite and Find Security Bugs required checks. - Run with an allowlist
jdk.serialFilterand the strict JAXP template as the JAXP configuration file14. - Stay on Spring and JDK lines with free fixes, or pay for support on the ones you keep.