Open cataggar opened 2 years ago
More input from other users
I dug into this a bit more, and I'm not sure how we were ever passing this before:
LLVM *never* sets the SDL bit in it's object files, therefore it is never set for Rust either.
this seems like a bug in BinSkim - it [supposed to handle compilers without /sdl support]
(https://github.com/microsoft/binskim/blob/65ce486ae4c2c0902e36ddbd3b3c491ad67c9c53/src/BinSkim.Rules/PERules/BA2026.EnableMicrosoftCompilerSdlSwitch.cs#L132-L137)
but it seems that code assumes the sdl bit is neither 0 nor 1
(as best I can tell, this means that the binary doesn't have a "feature" section in its debug directory),
which isn't true for LLVM generated binaries.
The current implementation is broken and suffers from both false negatives and false positives:
it's checking if the /sdl count in the debug directory feature list is non-zero:
so if at least one .obj was built /sdl enabled, then the entire binary passes.
I recommend changing the implementation to how BinSkim checks for spectre mitigations:
walk each obj, filter by language and check the compiler flags.
We can then make sure that each obj with C++ has the /sdl switch enabled.
This also has the added benefits of being able to indicate *which* obj/lib doesn't have the flag set,
which would help debug cases like this.
this check in BinSkim doesn’t appear to make sense with my understanding
of the value (a count of modules with the /sdl feature that were linked into the binary).
Is warning
BA2026
that makes sure a PE is compiled with SDL checks a false positive for Rust compiled binaries?