flawopen.com/Teardowns/CVE-2022-22965 Spring4Shell

CVE-2022-22965: Spring4Shell ClassLoader Binding RCE

Critical 9.8 CWE-94 Patch Teardown
ELI5 — The Delivery Box with Master Override

Imagine ordering a customized sandwich online: bread=wheat, cheese=cheddar. But the ordering form lets you type 'kitchen.oven.temperature=5000' and the restaurant's computer blindly adjusts the restaurant's actual kitchen machinery! In Spring4Shell, an attacker used standard HTTP parameters to navigate into the internal Java classloader, telling the web server to create a new log file called 'shell.jsp' and write executable hacker commands into it.

Target: Spring Framework running on JDK 9+ and Apache Tomcat
Vector: HTTP POST parameters targeting class.module.classLoader
Impact: Arbitrary remote code execution via webshell drop
Remediation: Disallowing access to ClassLoader and ProtectionDomain in property binding

The Mechanism & Root Cause

Spring MVC automatically binds HTTP parameters to Java Beans. While Spring previously blocked class.classLoader, JDK 9 introduced Java Modules. Attackers bypassed the check by traversing class.module.classLoader, reaching Tomcat's AccessLogValve and changing its file prefix to shell.jsp and writing JSP code directly into web directories.

CachedIntrospectionResults.java (Vulnerable Spring Framework)Vulnerable
// VULNERABLE: Only blocked 'classLoader' directly, missing 'module'
if (Class.class == beanClass && ("classLoader".equals(pd.getName()) || 
    "protectionDomain".equals(pd.getName()))) {
    continue; // Bypassed via class.module.classLoader on Java 9+
}
CachedIntrospectionResults.java (Patched Spring Framework)Hardened
// FIXED: Strictly restrict all Class property access except 'name'
if (Class.class == beanClass && (!"name".equals(pd.getName()))) {
    continue; // Disallows classLoader, module, and all reflection entry points
}

The Attack & Exploit Sequence

Defensive Engineering & Prevention Rules

Explore related security topics and post-mortems: Complete Security Directory →