-
Notifications
You must be signed in to change notification settings - Fork 433
Fix IDX10816 decompression failure for large JWE payloads in DeflateCompressionProvider #3286
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Conversation
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
Co-authored-by: pmaytak <[email protected]>
Co-authored-by: pmaytak <[email protected]>
Co-authored-by: pmaytak <[email protected]>
Copilot finished work on behalf of
pmaytak
August 4, 2025 20:59
pmaytak
reviewed
Aug 5, 2025
src/Microsoft.IdentityModel.Tokens/DeflateCompressionProvider.cs
Outdated
Show resolved
Hide resolved
pmaytak
reviewed
Aug 5, 2025
src/Microsoft.IdentityModel.Tokens/DeflateCompressionProvider.cs
Outdated
Show resolved
Hide resolved
… condition Co-authored-by: pmaytak <[email protected]>
Co-authored-by: pmaytak <[email protected]>
Copilot finished work on behalf of
pmaytak
August 5, 2025 20:00
pmaytak
reviewed
Aug 5, 2025
Co-authored-by: pmaytak <[email protected]>
Copilot finished work on behalf of
pmaytak
August 5, 2025 20:14
pmaytak
reviewed
Aug 5, 2025
pmaytak
reviewed
Aug 5, 2025
test/Microsoft.IdentityModel.Tokens.Tests/DeflateCompressionProviderTests.cs
Show resolved
Hide resolved
This was referenced Sep 8, 2025
This was referenced Sep 15, 2025
Open
This was referenced Sep 25, 2025
This was referenced Oct 3, 2025
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.
Problem
The
DeflateCompressionProvider.Decompress
method was incorrectly throwingIDX10816
errors for large but valid JWE payloads during deflation. This occurred becauseStreamReader.Read()
is not guaranteed to return the maximum number of characters requested, even when more data is available.The original code performed a single read operation:
When decompressing large payloads, the single
Read()
call would often return fewer characters than the available data, causingreader.Peek()
to detect remaining data and incorrectly conclude the payload exceeded the size limit.Solution
Modified the decompression logic to read from the stream in a loop until all data is consumed or the maximum size is reached:
Testing
Added comprehensive unit tests in
DeflateCompressionProviderTests.cs
:The fix ensures that:
Fixes #2516.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.