flawopen.com/Teardowns/cve-2022-22965-spring4shell
CVE-2022-22965 源代码级技术深度解析与系统加固工程指南:深入剖析漏洞触发条件、攻击利用链条与加固补丁的具体实现。
通俗原理解析: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.
Open Source SystemsCWE-SecurityDefense-in-Depth根本原因在于开源系统中未经验证的边界参数,导致状态不同步并绕过安全控制。
Attacker submits HTTP POST parameters targeting Tomcat's class loader: class.module.classLoader.resources.context.parent.pipeline.first.prefix=shell.
Attacker sets the log suffix to .jsp and pattern to an executable JSP webshell snippet.
Tomcat's AccessLogValve flushes access logs, creating webapps/ROOT/shell.jsp with executable payload code.
Attacker accesses http://victim/shell.jsp?cmd=whoami, executing arbitrary commands with web server privileges.
// 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+
}
// 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
}
prefix=shell。cmd=whoami, executing arbitrary commands with web server privileges。