Skip to content

Reject rewrite HTTPS downgrades; close intermediate redirect responses#1749

Open
KushalP wants to merge 1 commit into
apple:mainfrom
KushalP:request-rewriting-fixes
Open

Reject rewrite HTTPS downgrades; close intermediate redirect responses#1749
KushalP wants to merge 1 commit into
apple:mainfrom
KushalP:request-rewriting-fixes

Conversation

@KushalP

@KushalP KushalP commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Both issues are in RequestRewritingClient.doSend. It follows redirects by hand now that the JDK client uses Redirect.NEVER.

Downgrade guard

The guard read the raw Location scheme before applying rewrites. So a rewrite from https to http slipped a cleartext request past it. Now the code rewrites first, then checks the scheme.

Connection leak

The loop dropped each intermediate 3xx response without closing it. That leaked one BodyHandlers.ofInputStream() connection per hop. Now the code closes the body before following the redirect.

Both issues are in `RequestRewritingClient.doSend`. It follows
redirects by hand now that the JDK client uses `Redirect.NEVER`.

## Downgrade guard

The guard read the raw `Location` scheme before applying rewrites. So
a rewrite from `https` to `http` slipped a cleartext request past
it. Now the code rewrites first, then checks the scheme.

## Connection leak

The loop dropped each intermediate `3xx` response without closing
it. That leaked one `BodyHandlers.ofInputStream()` connection per
hop. Now the code closes the body before following the redirect.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant