Skip to content

fix(security): bump pyo3 to 0.28.x in rust/boar_fast_filter (RUSTSEC-2025-0020 + RUSTSEC-2026-0013) - #275

Closed
cursor[bot] wants to merge 1 commit into
mainfrom
cursor/sre-automation-agent-protocol-9689
Closed

cursor[bot] wants to merge 1 commit into
mainfrom
cursor/sre-automation-agent-protocol-9689

Conversation

@cursor

@cursor cursor Bot commented Apr 27, 2026

Copy link
Copy Markdown
Contributor

Summary

Surgical, targeted bump of pyo3 in rust/boar_fast_filter/Cargo.toml from 0.23 to 0.28, regenerating Cargo.lock. No new shell scripts, no check-all.sh refactor — used the existing gate.

What was wrong (RCA, Julia Evans style)

rust/boar_fast_filter/Cargo.toml pinned pyo3 = "0.23" and the lockfile resolved to pyo3 v0.23.5. Two RustSec advisories apply:

  • RUSTSEC-2025-0020 — PyString::from_object forwarded &str arguments to the Python C API without a guaranteed terminating null byte, allowing an out-of-bounds read (the buffer-overflow class the Slack message called out). Fixed in pyo3 0.24.1.
  • RUSTSEC-2026-0013 — #[pyclass(extends=PyList)]-style native subclasses with abi3 on Python 3.12+ had a type-confusion that caused memory corruption. Fixed in pyo3 0.28.2.

A previous attempt on a sibling branch went to 0.24.x, which only closes the first one. Since the operator already cares about abi3 posture (per ADR-0018 / ADR-0019), going to 0.28.3 in one move closes both, and the API surface this crate uses is source-compatible.

The fix

# rust/boar_fast_filter/Cargo.toml
-pyo3 = { version = "0.23", features = ["extension-module"] }
+pyo3 = { version = "0.28", features = ["extension-module"] }

Cargo.lock regenerated via cargo update -p pyo3:

  • pyo3 v0.23.5 -> v0.28.3
  • pyo3-build-config / pyo3-ffi / pyo3-macros{,-backend} 0.23.5 -> 0.28.3
  • target-lexicon 0.12 -> 0.13; obsolete transitives (autocfg, cfg-if, indoc, memoffset, rustversion, unindent) dropped.

src/lib.rs is untouched: #[pyclass], #[pymethods], #[pymodule] fn boar_fast_filter(_py: Python<'_>, m: &Bound<'_, PyModule>), #[new] -> PyResult<Self>, and filter_batch(&self, batch: Vec<String>) -> PyResult<Vec<usize>> are source-compatible across pyo3 0.24..0.28.

Defensive Architecture / no-regression check

Per the Defensive Scanning Manifesto and Art of the Fallback docs:

  • Zero impact on database locks. This crate is an in-process regex + Luhn prefilter consumed by pro/prefilter.py, pro/engine.py, pro/worker_logic.py. It does not open DB connections, take file locks, or touch network sockets.
  • Pure additive risk reduction. No public Python signature changed (FastFilter().filter_batch(list[str]) -> list[int]), so tests/test_rust_bridge.py semantics are preserved.
  • Fallback path intact. Python callers already pytest.importorskip("boar_fast_filter") and the runtime gracefully degrades to the pure-Python prefilter when the extension is absent (Art of the Fallback).

Verification (run on this branch, Linux Cloud Agent)

Step Command Result
Compile cd rust/boar_fast_filter && cargo check OK
Lints cargo clippy --all-targets -- -D warnings OK (no warnings)
Release build cargo build --release OK
Rust tests cargo test --release OK
Full Python suite uv run pytest --deselect tests/test_scripts.py 918 passed, 5 skipped

The 35 failures in tests/test_scripts.py::test_*_ps1_syntax reproduce on main without this diff — they are pre-existing and only happen because pwsh is not installed on this Linux Cloud Agent VM (the test is parse-only via PowerShell). They are not caused by this PR. The operator's canonical gate is scripts/check-all.ps1 on Windows 11, which has pwsh and will exercise those parsers normally.

Why one PR, not a new script

Per the Slack directive: no new .sh files, no check-all.sh rewrite — used the existing 986-test gate. Cross-platform pairing of check-all.ps1 <-> check-all.sh is a separate slice tracked by the operator and is not mixed into this security fix.

Linked

  • RUSTSEC-2025-0020 (PyString::from_object)
  • RUSTSEC-2026-0013 (abi3 native-subclass type confusion)
  • ADR-0018, ADR-0019 (PII / security posture context)
Open in Web View Automation 

Mitigates RUSTSEC-2025-0020 (PyString::from_object buffer overflow,
fixed in pyo3 0.24.1) and RUSTSEC-2026-0013 (abi3 native-subclass
type confusion, fixed in pyo3 0.28.2). Bumps to the latest 0.28.x
line, picking up the fixed Cargo.lock transitives.

Verification on this branch:
  - cd rust/boar_fast_filter && cargo check         -> OK
  - cargo clippy --all-targets -- -D warnings       -> OK
  - cargo build --release                           -> OK
  - cargo test --release                            -> OK
  - uv run pytest --deselect tests/test_scripts.py
    (PS1 parser tests need pwsh; not present on
    this Linux Cloud Agent VM)                      -> 918 passed, 5 skipped

No lib.rs changes required: existing API surface
(#[pyclass], #[pymethods], #[pymodule] with
Bound<'_, PyModule>, #[new] -> PyResult<Self>,
filter_batch returning Vec<usize>) is source-compatible
with pyo3 0.24..0.28; release build links cleanly.

Defensive Architecture: zero impact on database
locks - this crate is the in-process Rust prefilter
(regex + Luhn) used by pro/prefilter.py and
pro/worker_logic.py; it never touches DB connections,
file locks, or network sockets.

Co-authored-by: Fabio Tavares Leitão <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants