Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upEnable HeapEnableTerminationOnCorruption for all Windows Rust programs #56054
Comments
csmoe
added
the
O-windows
label
Nov 19, 2018
jonas-schievink
added
C-enhancement
A-security
labels
Jan 27, 2019
This comment has been minimized.
This comment has been minimized.
|
I took a stab at implementing this, by adding On 64-bit it is already always enabled. On 32-bit it also is when the subsystem major version is 6 or higher. Which is the default, and I am not sure this can be changed to something lower for Rust binaries. We only support the subsystems Tested with this snippid: extern crate libc;
fn main() {
unsafe {
let ptr = libc::malloc(80);
libc::free(ptr);
libc::free(ptr);
}
}with as result
Seems like there is nothing to be done here? |
This comment has been minimized.
This comment has been minimized.
|
Awesome! In that case, I'll close this issue then. Thanks for investigating. |
cpeterso commentedNov 19, 2018
•
edited
To help protect against heap exploits and bugs in unsafe or third-party code, the Rust compiler should emit code to enable Windows'
HeapEnableTerminationOnCorruptionfeature for all Windows Rust programs.With
HeapEnableTerminationOnCorruptionenabled, if the Windows heap manager detects an error in any system heap used by the process, it terminates the process. After a process enables this feature, it cannot be disabled. This feature should not cause any compatibility problems for correct programs.See MSDN for
HeapSetInformationandHeapEnableTerminationOnCorruption:https://docs.microsoft.com/en-us/windows/desktop/api/heapapi/nf-heapapi-heapsetinformation
Here is how Firefox enables
HeapEnableTerminationOnCorruptionfor its processes:https://searchfox.org/mozilla-central/rev/5117a4c4e29fcf80a627fecf899a62f117368abf/security/sandbox/chromium/sandbox/win/src/process_mitigations.cc#60-67
https://searchfox.org/mozilla-central/rev/5117a4c4e29fcf80a627fecf899a62f117368abf/toolkit/xre/nsAppRunner.cpp#3912-3917