Skip to content

scanner-rs OOB read #2262

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
May 7, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 5 additions & 27 deletions crates/scanner/RUSTSEC-0000-0000.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,37 +6,15 @@ date = "2025-03-27"
informational = "unsound"
categories = ["memory-corruption"]
keywords = ["out-of-bounds read"]
url = "https://github.com/pombredanne/scanner-rs/pull/1"

[affected.functions]
"scanner::Match::get" = ["<= 0.1.0"]
"scanner::Match::ptr" = ["<= 0.1.0"]

[versions]
patched = []
unaffected = []
```

# Possible public unsound API
```rust
/// Represents a pattern match.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub struct Match<'a> {
/// Haystack the match was found in.
pub haystack: &'a [u8],
/// Offset in the haystack the match was found.
pub at: u32,
/// Stored offsets as specified in the pattern.
pub store: [u32; MAX_STORE],
}

impl<'a> Match<'a> {
/// Get the pointer to the location that was matched.
#[inline]
pub fn ptr(&self) -> *const u8 {
unsafe { self.haystack.as_ptr().offset(self.at as isize) }
}
/// Get a pointer from the store array.
#[inline]
pub fn get<T>(&self, idx: usize) -> *const T {
unsafe { self.haystack.as_ptr().offset(self.store[idx] as isize) as *const T }
}
}
```

This crate allow users to create out of bound issue by using merely safe api (Ex. `Match.get`).