Title: Heap buffer overflow in `_PyTokenizer_ensure_utf8` · Issue #144872 · python/cpython · GitHub
Open Graph Title: Heap buffer overflow in `_PyTokenizer_ensure_utf8` · Issue #144872 · python/cpython
X Title: Heap buffer overflow in `_PyTokenizer_ensure_utf8` · Issue #144872 · python/cpython
Description: Bug report Bug description: OSS-Fuzz has found a heap buffer overflow in _PyTokenizer_ensure_utf8. Link to OSS-Fuzz bug report. The root cause is that valid_utf8() in Parser/tokenizer/helpers.c checks continuation bytes in reverse order ...
Open Graph Description: Bug report Bug description: OSS-Fuzz has found a heap buffer overflow in _PyTokenizer_ensure_utf8. Link to OSS-Fuzz bug report. The root cause is that valid_utf8() in Parser/tokenizer/helpers.c che...
X Description: Bug report Bug description: OSS-Fuzz has found a heap buffer overflow in _PyTokenizer_ensure_utf8. Link to OSS-Fuzz bug report. The root cause is that valid_utf8() in Parser/tokenizer/helpers.c che...
Opengraph URL: https://github.com/python/cpython/issues/144872
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Heap buffer overflow in `_PyTokenizer_ensure_utf8`","articleBody":"# Bug report\n\n### Bug description:\n\nOSS-Fuzz has found a heap buffer overflow in `_PyTokenizer_ensure_utf8`. [Link to OSS-Fuzz bug report](https://issues.oss-fuzz.com/issues/451112368).\n\nThe root cause is that `valid_utf8()` in `Parser/tokenizer/helpers.c` checks continuation bytes in reverse order thus reader `s[expected]` before `s[1]` on these lines:\n\nhttps://github.com/python/cpython/blob/8b7b5a994602824a5e41cf2516691212fcdfa25e/Parser/tokenizer/helpers.c#L497-L499\n\nWhen a multi-byte UTF-8 sequence is truncated - such as a 3-byte lead `\\xEA` followed immediately by a null terminator - the backward loop reads past the end of the valid data before encountering the null byte that would stop it.\n\nThis is not a security-critical issue.\n\n### CPython versions tested on:\n\nCPython main branch\n\n### Operating systems tested on:\n\n_No response_\n\n\u003c!-- gh-linked-prs --\u003e\n### Linked PRs\n* gh-144807\n* gh-145287\n* gh-145441\n\u003c!-- /gh-linked-prs --\u003e\n","author":{"url":"https://github.com/AdamKorcz","@type":"Person","name":"AdamKorcz"},"datePublished":"2026-02-16T12:13:49.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/144872/cpython/issues/144872"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:4b7642e9-b810-d259-7778-2302220fe4f9 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 849A:899DA:2C962E7:3E54768:6A50D806 |
| html-safe-nonce | ce8047146b2b0ec204752a8ea6b9d4eca4037a7c97778e6b265c9eda97cb310d |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4NDlBOjg5OURBOjJDOTYyRTc6M0U1NDc2ODo2QTUwRDgwNiIsInZpc2l0b3JfaWQiOiIyMjg5ODU1NDU5MDk0NDg0OTk4IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 6c2c9906f5a2513443b3cf6319d29e3c3e04a873cf64175616a68c9976e970a1 |
| hovercard-subject-tag | issue:3947473179 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/144872/issue_layout |
| twitter:image | https://opengraph.githubassets.com/4b20e12290993756dbb9394bc0d427f96ab043d6acee2139eb9dd5af18d3d51c/python/cpython/issues/144872 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/4b20e12290993756dbb9394bc0d427f96ab043d6acee2139eb9dd5af18d3d51c/python/cpython/issues/144872 |
| og:image:alt | Bug report Bug description: OSS-Fuzz has found a heap buffer overflow in _PyTokenizer_ensure_utf8. Link to OSS-Fuzz bug report. The root cause is that valid_utf8() in Parser/tokenizer/helpers.c che... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | AdamKorcz |
| hostname | github.com |
| expected-hostname | github.com |
| None | 72b13e0e8d0319acdd27a145cfe73f4f06c791713d0ac4690e41fb68ad28cac0 |
| turbo-cache-control | no-preview |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 73ad5c4eaffed7bb3637024653eabdbca84a855e |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width