Spring Framework is one of the most popular Java application frameworks. scan4all includes POCs for critical Spring vulnerabilities, including the infamous Spring4Shell (CVE-2022-22965).
These vulnerabilities affect a massive number of Java applications worldwide. Organizations using Spring Framework should prioritize testing and patching.
Description:Spring4Shell is a critical RCE vulnerability in Spring Framework affecting applications running on JDK 9 and above. The vulnerability exploits Spring’s data binding mechanism to gain access to the ClassLoader, allowing attackers to write malicious JSP files and achieve remote code execution.Technical Details:
Attack Vector: HTTP parameter pollution via data binding
Requirements: JDK 9+ and Apache Tomcat as servlet container
Exploitation: Modifies Tomcat’s Access Log Valve pattern to write a webshell
Detection Method:
// Stage 1: Check if ClassLoader is accessibleGET /?class.module.classLoader[1]=1// Expected: HTTP 500 (vulnerable)GET /?class.module.classLoader=1// Expected: HTTP 200 (vulnerable)
Exploitation Stages:
1
Access ClassLoader
Exploit data binding to access the ClassLoader through class.module.classLoader
2
Modify Access Log Pattern
Change Tomcat’s access log pattern to write a JSP webshell
3
Set Output Directory
Configure the log output to webapps/ROOT directory
4
Trigger Log Write
Make a request that triggers the access log to write the webshell
5
Execute Commands
Access the webshell and execute arbitrary commands
@Controllerpublic class VulnerableController { @GetMapping("/exploit") public String vulnerable(Model model) { // Vulnerable to data binding exploitation return "view"; }}
Verification:
# Check if webshell was createdcurl "http://target/tomcatwar.jsp?pwd=j&cmd=id"# Expected output:uid=1000(tomcat) gid=1000(tomcat) groups=1000(tomcat)
Description:Spring Cloud Gateway allows remote code execution when the Gateway Actuator endpoint is enabled and exposed. Attackers can inject malicious SpEL (Spring Expression Language) expressions through the /actuator/gateway/routes endpoint.Technical Details:
# Scan a Spring applicationscan4all -h http://springapp.example.com# Scan with POC enabledscan4all -h http://springapp.example.com -poc# Test specific CVEscan4all -h http://springapp.example.com -poc CVE-2022-22965