Repository navigation
Conversation
…in request command ### Summary of Changes Addresses the **Section 4.7 (High)** security finding in `wallet-cli` by preventing credential replay across origins during HTTP redirects. --- ### Vulnerability Analysis - In `src/commands/request.ts`, `redirectRequest` previously replayed the entire original request payload and headers—including `Authorization`, `Cookie`, and payment tokens—to whatever destination an upstream `Location` header specified. - A responding server could issue a cross-origin redirect (HTTP 301, 302, 303, 307, or 308) pointing to an untrusted domain, thereby leaking bearer tokens, session cookies, and payment authorization credentials to third parties. --- ### Key Remediations 1. **Cross-Origin Header Stripping (`src/commands/request.ts`):** - Enforced removal of `authorization`, `cookie`, `cookie2`, `payment-authorization`, and `proxy-authorization` when `nextUrl.origin !== currentUrl.origin`. - Preserved credentials on same-origin redirects to maintain standard API navigation compatibility. - Maintained existing RFC 7231 method rewriting semantics (converting POST/PUT to GET for 301, 302, and 303 redirects). 2. **Regression Testing (`test/request.test.ts`):** - Added test `"does not forward credentials to a different origin"` asserting that credentials evaluate as `credentials-stripped` when following cross-origin redirects. - Added test `"keeps credentials on same-origin redirects"` verifying that credentials remain attached for local path redirects. --- ### Verification - `pnpm typecheck`: Clean compilation with zero diagnostics. - `vitest run test/request.test.ts`: Both redirect credential tests pass reliably.
This branch has not been deployed
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.
Summary of Changes
Addresses the Section 4.7 (High) security finding in
wallet-cliby preventing credential replay across origins during HTTP redirects.Vulnerability Analysis
src/commands/request.ts,redirectRequestpreviously replayed the entire original request payload and headers—includingAuthorization,Cookie, and payment tokens—to whatever destination an upstreamLocationheader specified.Key Remediations
Cross-Origin Header Stripping (
src/commands/request.ts):authorization,cookie,cookie2,payment-authorization, andproxy-authorizationwhennextUrl.origin !== currentUrl.origin.Regression Testing (
test/request.test.ts):"does not forward credentials to a different origin"asserting that credentials evaluate ascredentials-strippedwhen following cross-origin redirects."keeps credentials on same-origin redirects"verifying that credentials remain attached for local path redirects.Verification
pnpm typecheck: Clean compilation with zero diagnostics.vitest run test/request.test.ts: Both redirect credential tests pass reliably.