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, thank you for your contribution in this project, I am scanning the unsoundness problem in rust project.
I notice the following code:
pub fn get_pe_metadata (module_ptr: *const u8) -> Result<PeMetadata,String>
{
let mut pe_metadata= PeMetadata::default();
unsafe {
let e_lfanew = *((module_ptr as usize + 0x3C) as *const u32);
pe_metadata.pe = *((module_ptr as usize + e_lfanew as usize) as *const u32);
.............................................
Considering that this function is in lib.rs, and get_pe_metadata is also a pub function. I assume that users can directly call this function. This potential situation could result in *((module_ptr as usize + 0x3C) as *const u32) being operating on a null pointer, I guess it might trigger undefined behavior (UB). For safety reasons, I felt it necessary to report this issue. If you have performed checks elsewhere that ensure this is safe, please don’t take offense at my raising this issue.
I suggest Several possible fixes:
If there is no external usage for get_pe_metadata, it should not marked as pub.
get_pe_metadata method should add additional check for null pointer.
mark get_pe_metadata method as unsafe and proper doc to let users know that they should provide valid Pointers.
The text was updated successfully, but these errors were encountered:
From the point of view of rust safety, you are completely right. That public function could be called from any new code developed on top of mine and potentially lead to a null pointer.
However, this is a closed proof of concept and I do not plan to expand it further or refactor it at all. Feel free to fork the project and fix it at will!
Hello, thank you for your contribution in this project, I am scanning the unsoundness problem in rust project.
I notice the following code:
Considering that this function is in lib.rs, and
get_pe_metadata
is also a pub function. I assume that users can directly call this function. This potential situation could result in*((module_ptr as usize + 0x3C) as *const u32)
being operating on a null pointer, I guess it might trigger undefined behavior (UB). For safety reasons, I felt it necessary to report this issue. If you have performed checks elsewhere that ensure this is safe, please don’t take offense at my raising this issue.I suggest Several possible fixes:
get_pe_metadata
, it should not marked aspub
.get_pe_metadata
method should add additional check for null pointer.get_pe_metadata
method as unsafe and proper doc to let users know that they should provide valid Pointers.The text was updated successfully, but these errors were encountered: