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

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

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.

Technologies: pyo3 (crates.io). Vendors: crates.io.

Quick answers

Is This vulnerability exploited in the wild?
No. Junglewise Threat Intelligence has no report of This vulnerability being exploited in the wild.
How severe is This vulnerability?
High severity, with a CVSS score of 8.7, published 12 June 2026.
Which products and versions are affected?
pyo3 (crates.io) < 0.29.0.
Is there a fix for This vulnerability?
A patch was published on 2026-06-02: Fix merged into main branch Junglewise finds every place you run it, drafts the upgrade and applies it once you approve.
How is This vulnerability attacked?
It is attacked over the network, in a software library.
Am I affected?
Check whether you run pyo3 (crates.io) at an affected version. Junglewise does that check for you around the clock: connect your code, cloud and domains, and it matches new vulnerabilities like this one against what you actually run and tells you when one reaches you.

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

This page as Markdown. Free to reuse under CC BY 4.0 with a link back.