@@ -22,25 +22,28 @@ patched = [">= 0.1.6"]
2222
2323# ` openssl-probe `  may cause memory corruption in multi-threaded processes 
2424
25- ` openssl-probe `  offers non-` unsafe `  methods that call environment setters , which may be called
25+ ` openssl-probe `  offers non-` unsafe `  methods that call ` std::env::set_var ` , which may be called
2626in a multithreaded environment, and potentially clash with environment access on other threads.
2727
2828When these methods are called while other threads are active and accessing the environment, it
29- may cause the  other threads to access dangling pointer values  in the cases where the underlying
29+ may cause other threads to access dangling environment pointers  in the cases where the underlying
3030environment data is moved or resized in response to an additional environment variable being
3131added, or a variable's contents being enlarged.
3232
3333This is shown to occur on Linux, but it will also likely occur on any other platform where ` getenv ` 
3434and ` setenv `  are not thread-safe, though trigger conditions may vary widely.
3535
36+ Note that these function calls are completely safe and sound in purely single-threaded environments,
37+ or multi-threaded environments where it can be proven that no simultaneous read and writes to the
38+ environment occur.
39+ 
3640## Rust's ` set_env `   
3741
38- This crate, and all callers of the Rust ` set_env `  function (< https://doc.rust-lang.org/std/env/fn.set_var.html > )
39- are unsound due to some early decisions in the Rust ecosystem that provided these functions without
40- an ` unsafe `  marker. The real problem, however, lies in the POSIX standard which defines this method
42+ This crate, and all other callers of the Rust ` set_env `  function (< https://doc.rust-lang.org/std/env/fn.set_var.html > )
43+ are unsound due to the unfortunate reality of the POSIX standard which defines these enviornment access methods
4144without making any sort of thread-safety guarantees.
4245
43- In Rust's 2024 edition these environment setters are made  ` unsafe `  and the documentation was updated to note
46+ In Rust's 2024 edition ` std::env::set_var `  is marked as  ` unsafe `  and the documentation was updated to note
4447that the only safe way to use these functions is in a single-threaded context.
4548
4649## Affected Code  
@@ -52,11 +55,11 @@ any other library's function which may call this function directly or indirectly
5255do so in certain configurations < https://github.com/sfackler/rust-native-tls/blob/2424bc5efd1b8b4bcf60dbda93259a3f29db7f06/Cargo.toml > .
5356
5457The crate's author released a fix in versions ` >=0.1.6 `  which marks these functions as ` #[deprecated] `  and adds
55- new ` unsafe `  equivalents < https://github.com/alexcrichton/openssl-probe/commit/3ea7c1af24d7f03c5786872f06ff066e03b75138 > .
58+ new ` unsafe `  equivalents with safety guidance  < https://github.com/alexcrichton/openssl-probe/commit/3ea7c1af24d7f03c5786872f06ff066e03b75138 > .
5659
5760## Alternative Mitigations  
5861
59- In the case of glibc users, some thread-safety improvements may protect you from ` setenv ` /` getenv `  clashes
62+ In the case of glibc users, some future  thread-safety improvements may protect you from ` setenv ` /` getenv `  clashes
6063which were introduced in < https://github.com/bminor/glibc/commit/7a61e7f557a97ab597d6fca5e2d1f13f65685c61 > ,
6164however direct ` environ `  access in multithreaded programs will still risk dangling pointer access.
6265
0 commit comments