You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello 🦀 ,
we (Rust group @sslab-gatech) found a memory-safety/soundness issue in this crate while scanning Rust code on crates.io for potential vulnerabilities.
Currently, the from_ffi API is a public API.
It is possible to use it to invoke the following undefined behavior in safe Rust programs.
std::ptr::read() on unaligned pointer
read from uninitialized memory.
Example
In the following program, there is no guarantee that ptr is an aligned pointer.
When it is fed to from_ffi as input, it is possible to ptr::read() from an unaligned pointer
(which is specified as undefined behavior here).
Also, ptr points to memory outside of x, so that reading from ptr can potentially read from uninitialized memory.
(which is also specified as undefined behavior here)
The users of from_ffi API need to ensure by themselves that the pointer fed to from_ffi is an aligned pointer & points to initialized memory. The from_ffi API should be marked as unsafe API.
Thank you for checking out this issue 👍
The text was updated successfully, but these errors were encountered:
Hello 🦀 ,
we (Rust group @sslab-gatech) found a memory-safety/soundness issue in this crate while scanning Rust code on crates.io for potential vulnerabilities.
Issue Description
foreignc/foreignc/src/ffi_util.rs
Lines 73 to 85 in 325f42d
Currently, the
from_ffi
API is a public API.It is possible to use it to invoke the following undefined behavior in safe Rust programs.
std::ptr::read()
on unaligned pointerExample
In the following program, there is no guarantee that
ptr
is an aligned pointer.When it is fed to
from_ffi
as input, it is possible toptr::read()
from an unaligned pointer(which is specified as undefined behavior here).
Also,
ptr
points to memory outside ofx
, so that reading fromptr
can potentially read from uninitialized memory.(which is also specified as undefined behavior here)
Program Output
Suggested Fix
The users of
from_ffi
API need to ensure by themselves that the pointer fed tofrom_ffi
is an aligned pointer & points to initialized memory. Thefrom_ffi
API should be marked asunsafe
API.Thank you for checking out this issue 👍
The text was updated successfully, but these errors were encountered: