Uh oh!
There was an error while loading. Please reload this page.
bpo-35214: Fix OOB memory access in unicode escape parser - #10506
Conversation
Discovered using clang's MemorySanitizer when it ran test_fstring's test_misformed_unicode_character_name. An f-string ending in `\N` would access one byte beyond the end of the string while looking for a potential `}`.
gpshead
commented
Nov 13, 2018
actually my news entry and description may not be correct. this may not be specific to f-strings but to any unicode string escape parsing? |
gpshead
commented
Nov 13, 2018
Confirmed, this is in the unicode parser, not f-string related. that just happened to be the unittest that triggered it. |
gpshead
commented
Nov 13, 2018
In terms of severity, this was only ever a single byte read. The code path it entered if that byte happened to be a } did check the bounds and would result in the desired error message (which is why this went unnoticed for so long). With most memory allocations it is unlikely that this byte would be on an unmapped page and crash the program, though I suspect it would be possible to trigger that by using a large enough string to generate such a specific allocation. At most that is a crash of an interpreter from an errant memory read. Denial of service at best if someone is handing user data to the unicode escape parser. |
miss-islington
commented
Nov 13, 2018
Thanks @gpshead for the PR 🌮🎉.. I'm working now to backport this PR to: 2.7, 3.6, 3.7. |
bedevere-bot
commented
Nov 13, 2018
GH-10522 is a backport of this pull request to the 3.7 branch. |
bedevere-bot
commented
Nov 13, 2018
GH-10523 is a backport of this pull request to the 3.6 branch. |
miss-islington
commented
Nov 13, 2018
Sorry, @gpshead, I could not cleanly backport this to |
Discovered using clang's MemorySanitizer when it ran python3's test_fstring test_misformed_unicode_character_name. An msan build will fail by simply executing: ./python -c 'u"\N"' (cherry picked from commit 746b2d3) Co-authored-by: Gregory P. Smith <greg@krypto.org>
…0506) (GH-10522) Discovered using clang's MemorySanitizer when it ran python3's test_fstring test_misformed_unicode_character_name. An msan build will fail by simply executing: ./python -c 'u"\N"' (cherry picked from commit 746b2d3) Co-authored-by: Gregory P. Smith <greg@krypto.org> https://bugs.python.org/issue35214
bedevere-bot
commented
Nov 14, 2018
GH-10538 is a backport of this pull request to the 2.7 branch. |
Discovered using clang's MemorySanitizer when it ran
test_fstring'stest_misformed_unicode_character_name.An f-string ending in
\Nwould access one byte beyond the end ofthe string while looking for a potential
}.https://bugs.python.org/issue35214