CVE-2023-34036
This Vulnerability has been fixed in the Never-Ending Support (NES) version offered by HeroDevs.
Overview
Reactive web applications that use Spring HATEOAS to produce hypermedia-based responses might be exposed to malicious forwarded headers if they are not behind a trusted proxy that ensures correctness of such headers, or if they don't have anything else in place to handle (and possibly discard) forwarded headers either in WebFlux or at the level of the underlying HTTP server.
For the application to be affected, it needs to satisfy the following requirements:
- It needs to use the reactive web stack (Spring WebFlux) and Spring HATEOAS to create links in hypermedia-based responses.
- The application infrastructure does not guard against clients submitting (X-)Forwarded… headers.
Details
Module Info
- Product: spring-hateoas
- Affected packages:
spring-hateoas - Affected versions: 1.3.7
- GitHub repository: https://github.com/spring-projects/spring-hateoas/
- Published packages: https://central.sonatype.com/artifact/org.springframework.hateoas/spring-hateoas
- Package manager: Maven
- Fixed In: NES for Spring v1.3.8
Vulnerability Info
Reactive web applications that use Spring HATEOAS to produce hypermedia-based responses might be exposed to malicious forwarded headers if they are not behind a trusted proxy that ensures correctness of such headers, or if they don't have anything else in place to handle (and possibly discard) forwarded headers either in WebFlux or at the level of the underlying HTTP server.
For the application to be affected, it needs to satisfy the following requirements:
- It needs to use the reactive web stack (Spring WebFlux) and Spring HATEOAS to create links in hypermedia-based responses.
- The application infrastructure does not guard against clients submitting (X-)Forwarded… headers.
Mitigation
- Upgrade Spring HATEOAS to versions 1.5.5, 2.0.5, 2.1.1 (or newer) to ensure that Forwarded headers are no longer processed by default in reactive applications.
- Configure a Trusted Proxy to strip or override incoming X-Forwarded-* and Forwarded headers from untrusted clients before they reach the application.
- Manually disable Forwarded Header support at the server level (e.g., Netty or Tomcat) if hypermedia links do not require preservation of the client's original protocol or host.
Steps To Reproduce
- Deploy a Spring WebFlux application using an affected version of Spring HATEOAS (e.g., < 1.5.5 or 2.0.x < 2.0.5).
- Expose a Reactive Hypermedia endpoint that generates links (e.g., using WebFluxLinkBuilder) and ensure no "Forwarded Header Filter" is manually configured to strip untrusted input.
- Submit an HTTP request to the endpoint including a malicious header, such as Forwarded: host=malicious.com;proto=https or X-Forwarded-Host: malicious.com.
- Observe the response body, specifically the _links or links section, to see if the generated URLs point to the attacker-controlled domain (malicious.com) instead of the actual server host.