FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Clear session authorization headers on redirect retries by jshigetomi · Pull Request #28398 · PowerShell/PowerShell · GitHub

Repository navigation

Clear session authorization headers on redirect retries - #28398

Open
Justin Chung (jshigetomi) wants to merge 1 commit into
PowerShell:masterfrom
jshigetomi:239bp
Open

Justin Chung (jshigetomi) wants to merge 1 commit into
PowerShell:masterfrom
jshigetomi:239bp

Conversation

Justin Chung (jshigetomi) commented Nov 11, 2026 •
edited
Loading

Copy link
Copy Markdown
Collaborator

PR Summary

PR Context

PR Checklist

  • PR has a meaningful title
  • Summarized changes
  • Existing files retain their copyright headers
  • This PR is ready to merge
  • Breaking changes
    • None
  • User-facing changes
    • Not Applicable
  • Testing - New and feature
    • N/A or can only be tested interactively

Justin Chung (jshigetomi) requested a review from a team as a code owner November 11, 2026 19:12
Copilot AI balanced review requested due to automatic review settings November 11, 2026 19:12

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

Justin Chung (jshigetomi) added the CL-General Indicates that a PR should be marked as a general cmdlet change in the Change Log label Nov 11, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

🟡 Changes recommended

Redirect handling permanently removes Authorization from a caller-supplied web session, breaking later requests that reuse it, and regression coverage for redirected retries is missing.

2 open issues What changed in this PR

This PR hardens redirect retries in the shared web cmdlet implementation by preventing reuse of session-level authorization unless explicitly preserved.

Changes:

  • Removes Authorization from both session headers and redirected requests when -PreserveAuthorizationOnRedirect is disabled.
  • Runs this cleanup even when the redirected request already lacks the header.
File Description
src/​Microsoft.PowerShell.Commands.Utility/​commands/​utility/​WebCmdlet/​Common/​WebRequestPSCmdlet.Common.cs Extends redirect authorization cleanup to session headers used when rebuilding requests for retries.

Review effort: Balanced

if (isRedirect && !PreserveAuthorizationOnRedirect && request.Headers.Contains(HttpKnownHeaderNames.Authorization))
if (isRedirect && !PreserveAuthorizationOnRedirect)
{
WebSession?.Headers?.Remove(HttpKnownHeaderNames.Authorization);
if (isRedirect && !PreserveAuthorizationOnRedirect && request.Headers.Contains(HttpKnownHeaderNames.Authorization))
if (isRedirect && !PreserveAuthorizationOnRedirect)
{
WebSession?.Headers?.Remove(HttpKnownHeaderNames.Authorization);
Justin Chung (jshigetomi) changed the title Protect redirected requests by clearing session authorization headers Clear session authorization headers on redirect retries Nov 11, 2026
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

Labels

CL-General Indicates that a PR should be marked as a general cmdlet change in the Change Log

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants


Back | FazBrowse Home | New Git URL