CVE-2024-22262: Spring Framework URL Parsing with Host Validation

Summary

16/04/2024
Yes i
High
8.1

CVE-2024-22262: Spring Framework URL Parsing with Host Validation. Affects org.springframework:spring-web across 3 version ranges.

< 5.3.34 >= 6.0.0, < 6.0.19 >= 6.1.0, < 6.1.6

Fixed in 5.3.34, 6.0.19 or 6.1.6, depending on the release line you run. How to fix ↓

Also tracked for

The same CVE-2024-22262 is tracked separately for each ecosystem and vendor. Its fix information is the same; the package and affected versions differ.

Free scan

Check if this vulnerability affects your application

Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.

Check my app free

No signup required · Results in about 60 seconds

Sponsored Devnack Mobile apps built by Devnack Design, build and launch iOS and Android apps with a senior product team. From idea to store release Start a project

Background

The Spring Framework is a popular open-source application framework for Java. It provides comprehensive infrastructure support for developing Java applications. The 'org.springframework:spring-web' package is a module within the Spring Framework that focuses on web-related features and functionality. It includes classes and utilities for handling HTTP requests, responses, and other web-related tasks. This package is widely used in Java web applications to build robust and scalable web services.

However, the 'org.springframework:spring-web' package is vulnerable to a URL parsing issue when using the UriComponentsBuilder class to parse externally provided URLs. If an application performs validation checks on the host of the parsed URL, it may be susceptible to an open redirect attack or a Server-Side Request Forgery (SSRF) attack if the URL is used after passing the validation checks.

Vulnerability Detail

The vulnerability arises due to improper URL parsing and insufficient host validation in the Spring Framework's 'org.springframework:spring-web' package. When an application uses the UriComponentsBuilder class to parse a URL provided externally, such as through a query parameter, and subsequently performs validation checks on the host of the parsed URL, it can be exploited in two ways:

  1. Open Redirect Attack: An attacker can manipulate the URL to redirect users to malicious websites, potentially leading to phishing attacks or the disclosure of sensitive information.

  2. Server-Side Request Forgery (SSRF) Attack: If the URL passes the validation checks and is used in subsequent operations, an attacker can abuse this to make the application perform unintended requests to internal resources or external systems, potentially leading to data leakage or unauthorized access.

This vulnerability has a CVSSv3 score of 8.1, indicating a high severity level.

How To Fix

Latest published version: 7.1.0-RC1 as of 23 Oct 2026

Upgrading to it may include breaking changes; the versions below are the minimum fixed release for this vulnerability.

If you can't move to the latest

The minimum fixed version depends on the release line you run.

  • < 5.3.34 5.3.34
  • >= 6.0.0, < 6.0.19 6.0.19
  • >= 6.1.0, < 6.1.6 6.1.6

Tip — Not sure which release line you're on? Vulert can find the fix for the version you are using. Scan free →

Workaround

If upgrading to a fixed version of the 'org.springframework:spring-web' package is not immediately feasible, a temporary workaround can be implemented. The workaround involves manually validating the URL's host using a custom implementation before passing it to UriComponentsBuilder. This ensures that only trusted hosts are accepted and reduces the risk of open redirect and SSRF attacks. Here's an example of a workaround implementation in Java:

import java.net.URI;

public class URLValidator {

    public static boolean isValidURL(String url) {
        try {
            URI uri = new URI(url);
            String host = uri.getHost();
            // Perform custom host validation logic
            // Return true if the host is trusted, false otherwise
        } catch (Exception e) {
            return false;
        }
        return true;
    }

}

Conclusion

The 'org.springframework:spring-web' package in the Spring Framework is vulnerable to a URL parsing issue that can lead to open redirect and SSRF attacks. It is crucial to update the package to the fixed versions mentioned earlier or implement the provided workaround to mitigate the risk. Regularly monitoring for vulnerabilities in your software, such as using Vulert (https://vulert.com), can help ensure the security of your applications. If you need further assistance or have any questions, please contact DevNack.com.

See every vulnerability recorded for org.springframework:spring-web →

Share this vulnerability

FAQ

This vulnerability can lead to open redirect attacks, where an attacker can manipulate the URL to redirect users to malicious websites. It can also result in Server-Side Request Forgery (SSRF) attacks, allowing an attacker to make unintended requests to internal resources or external systems.

You can use the Vulert Playground (https://vulert.com/scanner) to check if your application is affected by this vulnerability. Simply provide your pom.xml file, and Vulert will analyze it in real-time to identify any open-source vulnerabilities, including this specific issue.

At the time of this advisory, there are no known public exploits specifically targeting this vulnerability. However, it is crucial to address this issue promptly to prevent potential attacks.

Yes, a temporary workaround is available. By implementing custom host validation logic before using UriComponentsBuilder, you can reduce the risk of open redirect and SSRF attacks. Refer to the 'workaround' section for an example implementation.

You can find more information about this vulnerability, including the affected package versions and fixed versions, in the advisory on the GitHub Advisory Database: https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2024/04/GHSA-2wrp-6fg6-hmc5/GHSA-2wrp-6fg6-hmc5.json

Related vulnerabilities

Recent vulnerabilities recorded for org.springframework:spring-web.

How To Fix

Latest published version: 7.1.0-RC1 as of 23 Oct 2026

Upgrading to it may include breaking changes; the versions below are the minimum fixed release for this vulnerability.

If you can't move to the latest

The minimum fixed version depends on the release line you run.

  • < 5.3.34 5.3.34
  • >= 6.0.0, < 6.0.19 6.0.19
  • >= 6.1.0, < 6.1.6 6.1.6

Tip — Not sure which release line you're on? Vulert can find the fix for the version you are using. Scan free →

Subscribe to Vulert on Telegram
Daily digest of new CVEs, critical and high severity, affected packages and fixes — plus a weekly roundup.
Join the channel →
Help improve this record
Report an issue or send feedback