Skip to content

Commit 3c0dced

Browse files
committed
Add advisory for temporary
1 parent 9738835 commit 3c0dced

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

crates/temporary/RUSTSEC-0000-0000.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
```toml
2+
[advisory]
3+
id = "RUSTSEC-0000-0000"
4+
package = "temporary"
5+
date = "2022-02-16"
6+
categories = ["memory-exposure"]
7+
keywords = ["uninitialized-memory"]
8+
9+
[versions]
10+
patched = []
11+
unaffected = ["< 0.3.0"]
12+
```
13+
14+
# Use of uninitialized memory as a RNG seed in temporary
15+
16+
The following function is used as a way to get entropy from the system, which does operations on and exposes uninit memory, which is UB.
17+
18+
```rust
19+
fn random_seed(_: &Path, _: &str) -> [u64; 2] {
20+
use std::mem::uninitialized as rand;
21+
unsafe { [rand::<u64>() ^ 0x12345678, rand::<u64>() ^ 0x87654321] }
22+
}
23+
```
24+
25+
In addition, in release mode, the file names returned are completely predictable, as this test shows, which must be run in release.
26+
27+
```rust
28+
fn main() {
29+
assert_eq!(
30+
temporary::Directory::new("foo").unwrap().into_path(),
31+
std::path::Path::new("/tmp/foo.aaaaaaaaaaaa")
32+
);
33+
}
34+
```
35+
36+
[tempfile](https://crates.io/crates/tempfile) is the suggested replacement crate.

0 commit comments

Comments
 (0)