Repository navigation
Omit raw state values from authorization response validation errors - #8955
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
🟢 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
Collaborator
Author
|
/azp run |
|
Azure Pipelines: Successfully started running 4 pipeline(s). |
Collaborator
Author
|
/azp run |
|
Azure Pipelines: Successfully started running 4 pipeline(s). |
Konstantin (konstantin-msft)
enabled auto-merge (squash)
November 10, 2026 15:04
Thomas Norling (tnorling)
approved these changes
Nov 10, 2026
This was referenced Nov 20, 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
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.
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:
validateAuthorizationResponseinAuthorize.tsto no longer include the potentially untrustedserverResponse.statevalue when throwing aninvalidStateerror, reducing the risk of leaking sensitive or malformed state data. [1] [2]Testing improvements:
Authorize.spec.tsto 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.