-
Notifications
You must be signed in to change notification settings - Fork 1
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
Soundness issue: Input<R> can be misused to create data race to an object #33
Comments
Thanks for the help, really appreciate it. |
Could you publish a new release to |
Released~ @JOE1994 |
Hello 🦀 , we (Rust group @sslab-gatech) found a soundness issue in this crate while scanning Rust code on
crates.io
for potential vulnerabilities.Soundness Issue
Send
is unconditionally implemented forInput<R>
,so that it is possible to send
Input<R>
to other threads even whenR
is notSend
.When
Input<R>
is misused, it is possible to create a data race to a non-Sync
object.Proof of Concept
Cell
usingInput<R>
Cell
that counts the number ofread
events,making the
Cell
to contain incorrect statistics.fn main()
compares the value contained insideCell
with the exact number ofread
s that happened.CustomRead
is aRead
object that contains a nonSend
object (Rc<Cell<usize>>
)Program output
When compiled with
rustc 1.49.0-nightly (release mode)
& run onUbuntu 18.04
,outputs from 3 executions of the program was as below.
Suggested Solution
Simply adding trait bound
R: Send
to theSend
impl forInput<R>
will allow the compiler to revoke programs like the above.After the change,
Input<R>
can no longer carry non-Send objects when moving across thread boundaries.Thank you for very much for checking out this issue 👍
The text was updated successfully, but these errors were encountered: