# GHSA-9MFM-8WR5-M838: Micronaut JDK HTTP client forwards custom sensitive headers on cross-origin redirects

- Database: GitHub
- Severity: CVSS 5.9 (Medium)
- Published: 2026-11-11
- Modified: 2026-11-11

## Affected versions

- io.micronaut:micronaut-http-client-jdk (Maven): from 4.10.24, fixed in 4.10.37
- io.micronaut:micronaut-http-client-jdk (Maven): from 5.1.0, fixed in 5.2.23

## Description

## Summary

The Micronaut JDK HTTP client (`io.micronaut:micronaut-http-client-jdk`) delegates redirect handling to `java.net.http.HttpClient.Redirect.NORMAL`, which does not consult Micronaut's `redirectCrossOriginFilteredHeaders` configuration. When an application adds custom sensitive headers (such as API keys or internal authentication tokens) to this filter list, those headers are forwarded to cross-origin redirect targets. The standard Netty HTTP client applies this filtering correctly.

## Root Cause

The JDK HTTP client implementation configures redirect behavior at construction time by passing `HttpClient.Redirect.NORMAL` to the JDK's `HttpClient.Builder`, then delegates request execution to `client.sendAsync()` without intercepting intermediate redirect responses. The JDK client processes redirects internally and Micronaut never sees intermediate redirect responses, so the configurable header filter list defined in `HttpClientConfiguration.getRedirectCrossOriginFilteredHeaders()` is never consulted.

```java
// http-client-jdk/src/main/java/io/micronaut/http/client/jdk/AbstractJdkHttpClient.java
// Line 216: Redirect policy set at construction, no per-redirect filtering
HttpClient.Redirect redirect = configuration.isFollowRedirects()
    ? HttpClient.Redirect.NORMAL : HttpClient.Redirect.NEVER;
this.client = buildClient(redirect, true);

// Line 252 (inside buildClient): JDK builder receives the redirect policy
builder.followRedirects(redirect);

// Line 486: Request execution delegates entirely to JDK; no redirect interception
return client.sendAsync(httpRequest,
    java.net.http.HttpResponse.BodyHandlers.ofByteArray());
```

By contrast, the Netty client intercepts each redirect response and applies `setRedirectHeaders()` (at `http-client/src/main/java/io/micronaut/http/client/netty/NettyHttpClient.java`, line 2139), which checks cross-origin status via `RequestKey.equals()` and strips headers listed in `redirectCrossOriginFilteredHeaders`.

## Impact

An attacker who controls or compromises a server that a Micronaut JDK HTTP client application communicates with can obtain custom sensitive request headers by returning a cross-origin redirect response. The default headers (`Authorization`, `Cookie`) are incidentally protected by JDK 17+ internal behavior, but any additional headers the developer adds to `redirectCrossOriginFilteredHeaders` (such as `X-Api-Key` or `X-Internal-Auth`) are forwarded to the attacker-controlled redirect target.

Exploitation requires three conditions: the application must use the JDK HTTP client (an opt-in alternative to the default Netty client), the application must send custom sensitive headers in outbound requests, and the attacker must control or compromise a server the application communicates with to inject a cross-origin redirect.

## Proof of Concept

```text
Dependencies: Java 17+, no external libraries
Setup: Two HTTP servers on localhost (origin A on port 18080, origin B on port 18081)
```

1. Start origin B (port 18081) to capture received headers.
2. Start origin A (port 18080) to return HTTP 302 with `Location: http://127.0.0.1:18081/echo`.
3. Send a request to origin A with custom headers using JDK HttpClient configured with `Redirect.NORMAL` (same as Micronaut's `AbstractJdkHttpClient`).
4. Observe which headers arrive at origin B after the cross-origin redirect.

```java
HttpClient client = HttpClient.newBuilder()
    .followRedirects(HttpClient.Redirect.NORMAL)
    .version(HttpClient.Version.HTTP_1_1)
    .build();

HttpRequest request = HttpRequest.newBuilder()
    .uri(URI.create("http://127.0.0.1:18080/start"))
    .header("Authorization", "Bearer secret-token")
    .header("Cookie", "session=abc123")
    .header("X-Api-Key", "***")
    .header("X-Internal-Auth", "internal-secret")
    .GET()
    .build();

HttpResponse<String> response = client.send(request,
    HttpResponse.BodyHandlers.ofString());
```

```text
Cross-origin redirect: port 18080 -> 18081

Default sensitive headers (handled by JDK):
  Authorization: stripped *** JDK (safe)
  Cookie: stripped by JDK (safe)

Custom headers (expected to be filtered by redirectCrossOriginFilteredHeaders):
  X-Api-Key: *** ***
  X-Internal-Auth: LEAKED: internal-secret
```

## Attack Chain

1. **Exposure:** A Micronaut application using the JDK HTTP client sends outbound HTTP requests with custom sensitive headers. The JDK client is an officially supported alternative to the Netty client, published on Maven Central as `io.micronaut:micronaut-http-client-jdk`.
2. **Control:** The attacker controls or compromises a server the application communicates with and returns a cross-origin HTTP 302 redirect response. The `Location` header points to an attacker-controlled cross-origin server.
3. **Path:** `HttpRequestFactory.java:80` copies all Micronaut request headers to the JDK `HttpRequest.Builder` unconditionally. The JDK `HttpClient` with `Redirect.NORMAL` follows the redirect and constructs a new request to the redirect target, carrying custom headers through.
4. **Guard:** The JDK's internal redirect handling strips `Authorization` and `Cookie` on cross-origin redirects, but has no knowledge of Micronaut's `redirectCrossOriginFilteredHeaders` configuration. Zero references to this configuration exist in the `http-client-jdk` module.
5. **Primitive:** The attacker captures custom sensitive headers (API keys, internal auth tokens, session tokens) from the redirected request at the cross-origin target.
6. **Result:** Confidentiality breach of custom sensitive headers that the developer expected Micronaut to filter on cross-origin redirects.

## Bypass Evidence

The Micronaut TCK includes `RedirectHeaderCopyTest`, which tests that sensitive headers are stripped on cross-origin redirects. The JDK client test suite (`JdkHttpMethodTests.java`, line 24) explicitly excludes this test with the comment "Needs investigation", confirming the developers are aware the JDK client does not pass the redirect header filtering test.

The advisory GHSA-q6gh-6v2r-hjv3 addresses the same class of issue in the Netty client (`io.micronaut:micronaut-http-client`). Its fix commits (e.g., `9770328999f` for Micronaut 5) modify only `NettyHttpClient.java` and `HttpClientConfiguration.java`. No changes were applied to the JDK client module. The `redirectCrossOriginFilteredHeaders` configuration setter and getter exist in the shared `HttpClientConfiguration` class, but the JDK client never reads or applies this setting.

The strongest attempt to disprove this finding was verifying whether JDK internals protect all configured headers. JDK 17+ strips `Authorization` and `Cookie` on cross-origin redirects (different authority), which protects the default filter list. However, this protection does not extend to any custom headers a developer adds to the filter list, and the JDK's stripping behavior is an internal implementation detail, not a specification guarantee.

## Affected Versions

- Ecosystem: Maven
- Package: `io.micronaut:micronaut-http-client-jdk`
- Confirmed affected ranges: `>= 4.10.24` on 4.x and `>= 5.1.0` on 5.x.
- Latest stable releases checked: 4.10.33 and 5.2.17.
- Fix status: not fixed

The `redirectCrossOriginFilteredHeaders` configuration was introduced in stable releases 4.10.24 and 5.1.0; those are the first affected releases on their respective lines. The JDK client still delegates redirects to `Redirect.NORMAL` without applying that configuration in later releases. No fix is present in the current release tags.

## Suggested Fix

The JDK client should intercept redirect responses and apply the same header filtering logic that `NettyHttpClient.setRedirectHeaders()` implements. Since the JDK `HttpClient` does not expose a redirect callback, one approach is to configure `HttpClient.Redirect.NEVER` and implement redirect following in Micronaut's own code, applying `HttpClientConfiguration.getRedirectCrossOriginFilteredHeaders()` and `getRedirectAlwaysFilteredHeaders()` before constructing each redirect request. This would also enable enforcing `HttpClientConfiguration.getMaxRedirects()`, which the JDK client currently does not respect.

Alternatively, a filter or interceptor could be registered to strip sensitive headers before each request based on whether the target differs from the original request's origin.

No interim mitigation exists within the JDK client. Applications can switch to the Netty client (`io.micronaut:micronaut-http-client`), which correctly applies the configured header filtering.

Reported by zx (GitHub: @manus-pi).

## References

- https://github.com/micronaut-projects/micronaut-core/security/advisories/GHSA-9mfm-8wr5-m838

Page: https://cve.now/GHSA-9MFM-8WR5-M838

Wrong or missing data? Send feedback: POST https://cve.now/api/v1/feedback (see https://cve.now/agents#feedback).
