Commit 19c0782
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>
File tree
2 files changed
+8
-2
lines changed- src/libraries
- System.Memory/tests/Base64Url
- System.Private.CoreLib/src/System/Buffers/Text/Base64Helper
2 files changed
+8
-2
lines changedLines changed: 3 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| |||
196 | 196 | | |
197 | 197 | | |
198 | 198 | | |
199 | | - | |
| 199 | + | |
| 200 | + | |
200 | 201 | | |
201 | 202 | | |
202 | 203 | | |
| |||
Lines changed: 5 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
167 | 167 | | |
168 | 168 | | |
169 | 169 | | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
170 | 175 | | |
171 | 176 | | |
172 | 177 | | |
| |||
0 commit comments