CVE-2021-22118

7.8 HIGH

📋 TL;DR

This vulnerability allows a locally authenticated malicious user to escalate privileges in Spring Framework WebFlux applications by manipulating temporary storage directories. Attackers can read or modify uploaded files or overwrite arbitrary files with multipart request data. Affects Spring Framework versions 5.2.x prior to 5.2.15 and 5.3.x prior to 5.3.7.

💻 Affected Systems

Products:
  • Spring Framework
  • Applications using Spring WebFlux
Versions: Spring Framework 5.2.x prior to 5.2.15, 5.3.x prior to 5.3.7
Operating Systems: All operating systems running affected Spring versions
Default Config Vulnerable: ⚠️ Yes
Notes: Only affects applications using Spring WebFlux with multipart file upload functionality. Applications using Spring MVC are not affected.

📦 What is this software?

⚠️ Risk & Real-World Impact

🔴

Worst Case

Complete system compromise through file manipulation leading to arbitrary code execution, data theft, or service disruption.

🟠

Likely Case

Unauthorized access to sensitive uploaded files, modification of application data, or denial of service through file corruption.

🟢

If Mitigated

Limited impact with proper file permissions and isolation, but still potential for data leakage within application scope.

🌐 Internet-Facing: MEDIUM - Requires local authentication, but internet-facing applications could be targeted through other initial access vectors.
🏢 Internal Only: HIGH - Local authenticated users can exploit this to escalate privileges and access/modify sensitive files.

🎯 Exploit Status

Public PoC: ⚠️ Yes
Weaponized: LIKELY
Unauthenticated Exploit: ✅ No
Complexity: LOW

Exploitation requires local authentication but is straightforward once authenticated. Public proof-of-concept code exists demonstrating the directory manipulation technique.

🛠️ Fix & Mitigation

✅ Official Fix

Patch Version: Spring Framework 5.2.15 or 5.3.7 and later

Vendor Advisory: https://tanzu.vmware.com/security/cve-2021-22118

Restart Required: Yes

Instructions:

1. Update Spring Framework dependency to version 5.2.15 or higher (for 5.2.x) or 5.3.7 or higher (for 5.3.x). 2. Update pom.xml or build.gradle with new version. 3. Rebuild and redeploy application. 4. Restart application server.

🔧 Temporary Workarounds

Disable multipart file uploads

all

If file upload functionality is not required, disable multipart support in WebFlux configuration

spring.servlet.multipart.enabled=false

Use custom temporary directory with strict permissions

linux

Configure WebFlux to use a dedicated temporary directory with restrictive permissions

spring.servlet.multipart.location=/secure/temp/dir
chmod 700 /secure/temp/dir
chown appuser:appgroup /secure/temp/dir

🧯 If You Can't Patch

  • Implement strict file system permissions on temporary directories to limit access to application user only
  • Monitor file system activity in temporary directories for unauthorized access or modification attempts

🔍 How to Verify

Check if Vulnerable:

Check Spring Framework version in pom.xml, build.gradle, or application dependencies. Verify if using WebFlux with version 5.2.0-5.2.14 or 5.3.0-5.3.6.

Check Version:

mvn dependency:tree | grep spring-core OR gradle dependencies | grep spring-core

Verify Fix Applied:

Confirm Spring Framework version is 5.2.15+ or 5.3.7+ in dependencies. Test multipart file upload functionality to ensure it works with the patched version.

📡 Detection & Monitoring

Log Indicators:

  • Unauthorized file access attempts in temporary directories
  • Multiple failed file operations in WebFlux logs
  • Suspicious directory creation/modification patterns

Network Indicators:

  • Unusual multipart request patterns to WebFlux endpoints
  • Large volume of file upload requests from single source

SIEM Query:

source="*spring*" AND ("multipart" OR "file upload") AND ("permission denied" OR "access denied" OR "directory creation")

🔗 References

📤 Share & Export