Attack Simulation & Response

Red TeamEnd-to-end simulation using real adversary tradecraft Blue TeamThreat hunting, monitoring and incident response Purple TeamGrow your offensive and defensive teams together Ransomware Response24/7 emergency response for encrypted systems

Security Testing

Penetration TestingFinding flaws in web, network and mobile applications Enterprise Penetration TestingRegulation-aligned testing for finance and large enterprises Vulnerability ScanningContinuous scanning, prioritised with CVSS
A free scoping call tailored to your organisation.
All services Get a quote

Forensic Threat Hunting

PotreX VestigeHidden threat scanning across disk, memory and forensic traces

Threat Intelligence

PotreX ArgosDark web and leak-focused threat intelligence

Penetration Testing

PotreX BallistaEnterprise penetration testing platform with finding management
Every product can be deployed on-premises or in the cloud.
All products Request a demo
Services
Products
Blog Contact Us Sign In
Home / Blog / CVE-2022-22965
Vulnerability Analysis

Spring4Shell: From Data Binding to the Class Loader

Summary

Spring MVC automatically binds incoming request parameters onto Java objects. CVE-2022-22965 exists because that binding can reach an object's class property and, from there, its class loader.

Under specific conditions (JDK 9+, deployed as a WAR on Tomcat) an attacker can rewrite the access log configuration and have the server write content of their choosing to disk — in practice, a JSP web shell.

Advisory details

CVECVE-2022-22965 (Spring4Shell)
ComponentSpring Framework — data binding
ClassCWE-94 · Code injection via class loader manipulation
SeverityCRITICAL · CVSS 9.8
Affected versionsSpring Framework < 5.3.18 and < 5.2.20
PrerequisiteJDK 9+ · WAR deployment on Tomcat · POJO parameter binding

Root cause: an unbounded property chain

The binder supports nested paths such as address.city alongside simple fields. Left unrestricted, that path can continue as class.module.classLoader... and reach the application's runtime internals.

Spring had previously blocked class.classLoader; the module property introduced in JDK 9 opened a new way around that block. The fix closes every route to the class loader rather than blacklisting individual names.

Non-destructive check

Start with the version, read from the dependency tree.

analyst@ubuntu: ~/labs/spring –□✕
analyst@ubuntu:~/labs/spring$ unzip -p app.war 'WEB-INF/lib/spring-beans-*.jar' > /dev/null; ls WEB-INF/lib | grep -E 'spring-(beans|webmvc)'
spring-beans-5.3.17.jar
spring-webmvc-5.3.17.jar

#  below 5.3.18 — affected range

Figure 1 — Reading the Spring versions bundled in the WAR

Exposure can be confirmed without writing anything to the server: bind an existing but harmless property. A patched build rejects the request (400); an unpatched build accepts it silently (200).

analyst@ubuntu: ~/labs/spring –□✕
analyst@ubuntu:~/labs/spring$ curl -s -o /dev/null -w 'status: %{http_code}\n' 'http://app.lab.local/form?class.module.classLoader.DefaultAssertionStatus=potrex'
status: 200

#  a patched build returns 400
#  200 = binding can walk into the class loader

Figure 2 — Checking exposure without writing a file

Remediation

The primary fix is upgrading Spring Framework to 5.3.18 / 5.2.20 or later. While the upgrade is pending, a controller-level disallowed field list limits the damage.

analyst@ubuntu: ~/labs/spring –□✕
analyst@ubuntu:~/labs/spring$ mvn -q versions:use-dep-version -Dincludes=org.springframework:spring-beans -DdepVersion=5.3.18 && mvn -q package && curl -s -o /dev/null -w 'status: %{http_code}\n' 'http://app.lab.local/form?class.module.classLoader.DefaultAssertionStatus=potrex'
status: 400

#  the binder now rejects the request — patch verified

Figure 3 — The check returns 400 after the upgrade

  • Review the Tomcat access log configuration for unexpected changes.
  • Search the web root for new or modified .jsp files.
  • Add an @InitBinder rule that disallows class.* fields.

Log hunting

analyst@ubuntu: /var/log/tomcat9 –□✕
analyst@ubuntu:/var/log/tomcat9$ grep -ohE 'class\.module\.classLoader[^& ]*' localhost_access_log.*.txt | sort | uniq -c | sort -rn | head
     46 class.module.classLoader.resources.context.parent.pipeline.first.pattern
     46 class.module.classLoader.resources.context.parent.pipeline.first.suffix
      3 class.module.classLoader.DefaultAssertionStatus

#  pipeline parameters = an attempt to write a file

Figure 4 — Exploitation parameters in access logs

Conclusion

Spring4Shell is a reminder of how much authority “convenience” framework features carry by default. Data binding, deserialisation and template engines should all operate on an explicit allow list of fields.

Sources

Test it in your own environment

We test your Java and Spring applications across data binding, deserialisation and template injection chains.

Call now · 0850 551 01 01 WhatsApp · Send a message Email · info@potrex.com