Junglewise Threat Intelligence

PyO3 out-of-bounds read in list and tuple iterators

Severity: high · CVSS 8.7 · Published 2026-06-12

Technologies: Pyo3. Vendors: crates.io.

Executive brief

PyO3, a library used to bridge Rust and Python, contains a memory safety flaw in how it handles list and tuple iterators. An attacker could potentially exploit this to read sensitive information from a program's memory that should otherwise be inaccessible. This could lead to the exposure of private data or internal system details, depending on how the affected software processes user-supplied data.

Technical details

An out-of-bounds read vulnerability exists in PyO3's optimized implementations of `Iterator::nth` and `DoubleEndedIterator::nth_back` for `BoundListIterator` and `BoundTupleIterator`. The root cause is the use of unchecked `usize` arithmetic (`index + n`) to calculate target indices before performing bounds checks. In `nth`, a large value of `n` can cause an integer overflow/wrap-around, allowing reads of previously yielded elements. In `nth_back`, a large `n` can cause an underflow, enabling arbitrary memory reads past the end of the list or tuple storage. This can be exploited if an attacker can control the integer argument passed to these iterator methods. The issue is fixed in version 0.29.0 by switching to checked arithmetic.

Affected products

  • PyO3 pyo3 >= 0.24.0, < 0.29.0

Timeline

  • 2026-06-01: other: Fix PR submitted to GitHub
  • 2026-06-02: patched: Fix merged into main branch
  • 2026-06-11: advisory: RustSec advisory issued
  • 2026-06-12: disclosed: GitHub Advisory published

References

Related threats