Skip to content

#124513 - Guard Base64Url.DecodeFromChars against non-ASCII input - #124540

Merged
tannergooding merged 6 commits into
dotnet:mainfrom
Tomius:patch-1
Feb 19, 2026
Merged

#124513 - Guard Base64Url.DecodeFromChars against non-ASCII input#124540
tannergooding merged 6 commits into
dotnet:mainfrom
Tomius:patch-1

Conversation

@Tomius

@TomiusTomius commented Feb 18, 2026

Copy link
Copy Markdown
Contributor

Base64Url.DecodeFromChars in Microsoft.Bcl.Memory has an out-of-bounds read bug: DecodeFrom uses Unsafe.Add with raw char values as indices into a 256-element DecodingMap without checking the DecodeRemaining return value first. Non-ASCII chars (value > ~2048) cause an AccessViolationException on .NET 8.

Workaround: Add System.Text.Ascii.IsValid check before decoding to reject non-ASCII input early. Base64/Base64Url only uses ASCII characters, so any non-ASCII input is inherently invalid.

Fixes#124513

dotnet#124513 - Guard Base64Url.DecodeFromChars against non-ASCII input
Base64Url.DecodeFromChars in Microsoft.Bcl.Memory has an out-of-bounds read bug: DecodeFrom uses Unsafe.Add with raw char values as indices into a 256-element DecodingMap without checking the DecodeRemaining return value first. Non-ASCII chars (value > ~2048) cause an AccessViolationException on .NET 8.
Workaround: Add System.Text.Ascii.IsValid check before decoding to reject non-ASCII input early. Base64/Base64Url only uses ASCII characters, so any non-ASCII input is inherently invalid.
See: dotnet#124513
@dotnet-policy-servicedotnet-policy-serviceBot added the community-contribution Indicates that the PR has been added by a community member label Feb 18, 2026
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @dotnet/area-system-buffers
See info in area-owners.md if you want to be subscribed.

@tannergoodingtannergooding left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM. Thanks!

@jeffhandleyjeffhandley left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM too. Thanks!

@GrabYourPitchforksGrabYourPitchforks left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM. We can investigate the BOM issue afterward.

@tannergooding
tannergooding enabled auto-merge (squash) February 19, 2026 01:44
@jeffhandley

Copy link
Copy Markdown
Member

/ba-g Unrelated networking failures on Android only

@tannergooding
tannergooding merged commit 1451f24 into dotnet:mainFeb 19, 2026
147 of 149 checks passed
@build-analysisbuild-analysisBot mentioned this pull request Feb 19, 2026
BrennanConroy added a commit to BrennanConroy/runtime that referenced this pull request Feb 27, 2026
iremyux pushed a commit to iremyux/dotnet-runtime that referenced this pull request Mar 2, 2026
…ut (dotnet#124540)
Base64Url.DecodeFromChars in Microsoft.Bcl.Memory has an out-of-bounds
read bug: DecodeFrom uses Unsafe.Add with raw char values as indices
into a 256-element DecodingMap without checking the DecodeRemaining
return value first. Non-ASCII chars (value > ~2048) cause an
AccessViolationException on .NET 8.
Workaround: Add System.Text.Ascii.IsValid check before decoding to
reject non-ASCII input early. Base64/Base64Url only uses ASCII
characters, so any non-ASCII input is inherently invalid.
Fixesdotnet#124513
---------
Co-authored-by: t.csala <t.csala@criteo.com>
dotnet-bot pushed a commit that referenced this pull request Mar 10, 2026
…24540)
Base64Url.DecodeFromChars in Microsoft.Bcl.Memory has an out-of-bounds
read bug: DecodeFrom uses Unsafe.Add with raw char values as indices
into a 256-element DecodingMap without checking the DecodeRemaining
return value first. Non-ASCII chars (value > ~2048) cause an
AccessViolationException on .NET 8.
Workaround: Add System.Text.Ascii.IsValid check before decoding to
reject non-ASCII input early. Base64/Base64Url only uses ASCII
characters, so any non-ASCII input is inherently invalid.
Fixes#124513
---------
Co-authored-by: t.csala <t.csala@criteo.com>
dotnet-bot pushed a commit that referenced this pull request Mar 10, 2026
…24540)
Base64Url.DecodeFromChars in Microsoft.Bcl.Memory has an out-of-bounds
read bug: DecodeFrom uses Unsafe.Add with raw char values as indices
into a 256-element DecodingMap without checking the DecodeRemaining
return value first. Non-ASCII chars (value > ~2048) cause an
AccessViolationException on .NET 8.
Workaround: Add System.Text.Ascii.IsValid check before decoding to
reject non-ASCII input early. Base64/Base64Url only uses ASCII
characters, so any non-ASCII input is inherently invalid.
Fixes#124513
---------
Co-authored-by: t.csala <t.csala@criteo.com>
@github-actionsgithub-actionsBot locked and limited conversation to collaborators Mar 21, 2026
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-System.Bufferscommunity-contributionIndicates that the PR has been added by a community member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Base64Url.DecodeFromChars crashes with AccessViolationException on non-ASCII char input (Microsoft.Bcl.Memory)

5 participants

@Tomius@jeffhandley@GrabYourPitchforks@tannergooding@lilinus