[MEDIUM] security: block redirects carrying custom headers - #1142
Open
OskarEichler wants to merge 1 commit into
Open
[MEDIUM] security: block redirects carrying custom headers#1142OskarEichler wants to merge 1 commit into
OskarEichler wants to merge 1 commit into
Conversation
|
@OskarEichler is attempting to deploy a commit to the Nearform Team on Vercel. A member of the Team first needs to authorize it. |
🦋 Changeset detectedLatest commit: ba541a1 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Security impact
Custom headers are commonly used for API keys or authorization credentials. Both native implementations previously followed HTTP redirects while retaining arbitrary custom headers:
A cross-origin redirect from a discovery, token, or registration endpoint could therefore disclose credential-bearing headers to the redirect target. This was reproduced locally with synthetic headers and 127.0.0.1 -> localhost redirects on both platform networking stacks.
Fix
Disable automatic redirects whenever a native request carries custom headers. Android marks the connection non-following before applying headers; iOS uses a session task delegate that declines redirects for header-bearing sessions. Calls without custom headers keep their existing redirect behavior.
Blocking redirects rather than trying to classify header names is intentional: arbitrary custom headers can contain credentials, and Android HttpURLConnection has no redirect hook that can reliably scrub only a cross-origin follow-up request.
This PR is limited to redirect forwarding. Sequential Android header reuse and iOS per-call session mixing are submitted separately.
Breaking / observable changes
OAuth endpoints that redirect while custom headers are configured now fail at the redirect response. Configure the final endpoint URL directly. Requests without custom headers are unchanged.
Verification
The repository has no Android or iOS native unit-test target, so the focused native changes are covered by both native compilation paths and the existing project suites. A patch changeset and documentation are included.