PyO3 has an Out-of-bounds Read in `nth` / `nth_back` for `PyList` and `PyTuple` iterators
High severity
GitHub Reviewed
Published
Jun 12, 2026
to the GitHub Advisory Database
•
Updated Jun 12, 2026
Description
Published to the GitHub Advisory Database
Jun 12, 2026
Reviewed
Jun 12, 2026
Last updated
Jun 12, 2026
PyO3 0.24.0 added optimized implementations of
Iterator::nthandDoubleEndedIterator::nth_backfor theBoundListIteratorandBoundTupleIteratortypes. These implementations computed the target index using uncheckedusizeaddition (index + n) before bounds-checking against the sequence length, then read the element viaget_item_unchecked.In
nthmethods, a sufficiently largen(combined with a non-zero internal index) could cause the addition to overflow and wrap around, producing a small "target index" that passed the bounds check and enabling reads at the front of thelistortupleof elements previously yielded by the iterator.In
nth_backmethods, a sufficiently largencould cause underflow in a similar fashion, however would instead allow reads of arbitrary memory past the end of thelistortuplestorage.References