Security context

What an agent needs to avoid regressing past fixes and find the next vuln in this repo.

alexcrichton/ssh2-rs
master @ 4eeeebd
7
Fixes
0
CVEs
HIGH
Peak severity
71.4%
Coverage
Highlights
Memory Corruption: 3 prior fixes. Scrutinize any change in this area.
src/session.rs: most-fixed (6 issues). Treat as high-risk during review.
6 high-severity fixes in this history; regressions here are high-impact.
Recurring patterns

The bug types that recur here, drawn from past fixes, not open vulnerabilities.

Use After Free: A temporary host string was dropped before its raw pointer was consumed by raw::libssh2_channel_forward_listen_ex, leading to a dangling pointer. Developers must borrow references instead of consuming ownership to prevent premature destruction of backing variables.
Memory Safety: Early shutdown of the SFTP session while active file handles still reference it caused use-after-free and double-free vulnerabilities. Resource lifetimes must be managed through strong reference tracking wrappers like Arc.
Memory Corruption: Uncontrolled unwinding of Rust panics across the FFI boundary into libssh2 C code can corrupt stack and heap memory. All callbacks invoked by C code must use catch_unwind to handle panics safely.