Skip to content

Omit raw state values from authorization response validation errors - #8955

Merged
Konstantin (konstantin-msft) merged 4 commits into
devfrom
omit_raw_state_from_error
Nov 10, 2026
Merged

Konstantin (konstantin-msft) merged 4 commits into
devfrom
omit_raw_state_from_error

Conversation

@konstantin-msft

Copy link
Copy Markdown
Collaborator

This pull request updates the authorization response validation logic to improve security and test coverage. The main change is to ensure that when an invalid state is detected, the error thrown does not include the potentially untrusted state value, preventing possible leakage of sensitive or malformed data. The test suite has also been expanded to cover more scenarios involving malformed or mismatched state values.

Security improvements:

  • Updated validateAuthorizationResponse in Authorize.ts to no longer include the potentially untrusted serverResponse.state value when throwing an invalidState error, reducing the risk of leaking sensitive or malformed state data. [1] [2]

Testing improvements:

  • Refactored and expanded the related test in Authorize.spec.ts to use parameterized tests (it.each), covering multiple scenarios with malformed or mismatched state values, and verifying that the thrown error does not reflect the untrusted state.

Copilot AI balanced review requested due to automatic review settings October 30, 2026 17:44
@konstantin-msft
Konstantin (konstantin-msft) requested a review from a team as a code owner October 30, 2026 17:44

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.

🟢 Approval recommended

There are no active review issues for the change that keeps raw state values out of authorization validation errors.

No open issues 🎉

What changed in this PR

This PR hardens MSAL Common’s authorization response validation by keeping raw state values out of invalidState errors.

Changes:

  • Removes response state from errors raised when decoding response or cached state fails.
  • Adds parameterized tests for malformed states, checking error content and correlation IDs.
  • Adds a patch changefile for @azure/msal-common.
File Description
lib/​msal-common/​test/​protocol/​Authorize.spec.ts Expands malformed-state coverage and verifies errors omit raw state.
lib/​msal-common/​src/​protocol/​Authorize.ts Stops including response state in state-decoding errors.
change/​@azure-msal-common-state-error-hardening.json Records the security hardening as a patch release change.

Review effort: Balanced

@konstantin-msft

Copy link
Copy Markdown
Collaborator Author

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 4 pipeline(s).

@konstantin-msft

Copy link
Copy Markdown
Collaborator Author

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 4 pipeline(s).

@konstantin-msft
Konstantin (konstantin-msft) merged commit 31acc7f into dev Nov 10, 2026
85 checks passed
@konstantin-msft
Konstantin (konstantin-msft) deleted the omit_raw_state_from_error branch November 10, 2026 17:24
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.

4 participants