|
| 1 | +```toml |
| 2 | +[advisory] |
| 3 | +id = "RUSTSEC-0000-0000" |
| 4 | +package = "process_lock" |
| 5 | +date = "2025-05-16" |
| 6 | +url = "https://github.com/tickbh/ProcessLock/issues/1" |
| 7 | +informational = "unsound" |
| 8 | +# See https://docs.rs/rustsec/latest/rustsec/advisory/enum.Category.html |
| 9 | +cvss = "CVSS:3.1/AV:L/AC:H/PR:N/UI:N/S:U/C:N/I:N/A:L" |
| 10 | +keywords = ["data race"] |
| 11 | +aliases = ["CVE-2025-48751"] |
| 12 | + |
| 13 | + |
| 14 | +[affected.functions] |
| 15 | +"process_lock::ProcessLock::unlock" = [">= 0.1.0"] |
| 16 | +``` |
| 17 | + |
| 18 | +# Unsound issue in unlock |
| 19 | + |
| 20 | +Our static analyzer find a potential unsound issue |
| 21 | +(data races) in ProcessLock, where the unlock fuction |
| 22 | +needs to be marked as unsafe explicitly, otherwise |
| 23 | +safe Rust can have data races when user unlock |
| 24 | +unexpectedly, you can check lock-api for details. |
| 25 | + |
| 26 | +## PoC |
| 27 | + |
| 28 | +A potentail PoC code is like: |
| 29 | + |
| 30 | +```rust |
| 31 | +#[deny(unsafe_code)] |
| 32 | +use std::sync::Arc; |
| 33 | +use process_lock::*; |
| 34 | +use std::thread; |
| 35 | +use std::time::Duration; |
| 36 | + |
| 37 | + |
| 38 | +fn main() { |
| 39 | + let mut s1 = Arc::new(ProcessLock::new("test".parse().unwrap(), None).unwrap()); |
| 40 | + let mut s2 = s1.clone(); |
| 41 | + let h = std::thread::spawn(move || { |
| 42 | + if let Ok(mut guard) = s2.lock() { |
| 43 | + thread::sleep(Duration::from_secs(1)); |
| 44 | + // data race 1 |
| 45 | + } |
| 46 | + }); |
| 47 | + thread::sleep(Duration::from_secs(1)); |
| 48 | + if let Ok(_) = s1.unlock(){ |
| 49 | + if let Ok(guard2) = s1.lock(){ |
| 50 | + println!("data races"); |
| 51 | + // data race 2 |
| 52 | + } |
| 53 | + } |
| 54 | + h.join().unwrap(); |
| 55 | +} |
| 56 | +``` |
0 commit comments