retep998 / winapi-rs

Rust bindings to Windows API
https://crates.io/crates/winapi
Apache License 2.0
1.84k stars 391 forks source link

How would we go about verifing this library? #734

Open dpc opened 5 years ago

dpc commented 5 years ago

As a part of effort of cargo crev, I wanted to review winapi-i686-pc-windows-gnu, and it turned out it's a 52MB of binary libraries. I realize that they are probably good reason for this, but how should I go about making sure there are no rootkits, viruses etc. in there?

retep998 commented 5 years ago

You can build them yourself from the .def files. I'm not sure how good MinGW is at reproducible builds, but if you want to work on making them reproducible, have at it.

Ideally though, we'd just have https://github.com/rust-lang/rfcs/pull/2627 and I wouldn't need those import libraries.

MaulingMonkey commented 5 years ago

I poked at this some (under the mistaken impression binaries were used in *-msvc builds too) and discovered the .a files might have incorrect ordinals in the 0.3 branch based on the differences in .idata$6 described bellow. Not sure how problematic that is.

What follows is mostly a description of how to generate and diff the binaries reasonably. I have not done an exhaustive check against all binaries - could be automated more, but I haven't. I also haven't checked that e.g. I list everything important using objdump (I probably haven't), making mingw output reproducable builds would probably be a saner approach anyways.

Stuff used:

Archive Differences

Archive\1.txt Differences

Example:

dkxcbt.o    __C__Users_Peter_Code_winapi_rs_x86_64_lib_libwinapi_xinput_a_iname
dkxcbh.o    _head_C__Users_Peter_Code_winapi_rs_x86_64_lib_libwinapi_xinput_a
dkxcbs00007.o    XInputSetState
dkxcbs00007.o    __imp_XInputSetState
dkxcbs00006.o    XInputGetState
dkxcbs00006.o    __imp_XInputGetState
dkxcbs00005.o    XInputGetKeystroke
dkxcbs00005.o    __imp_XInputGetKeystroke
dkxcbs00004.o    XInputGetCapabilities
dkxcbs00004.o    __imp_XInputGetCapabilities
dkxcbs00003.o    XInputGetBatteryInformation
dkxcbs00003.o    __imp_XInputGetBatteryInformation
dkxcbs00002.o    XInputGetAudioDeviceIds
dkxcbs00002.o    __imp_XInputGetAudioDeviceIds
dkxcbs00001.o    XInputEnable
dkxcbs00001.o    __imp_XInputEnable
dkxcbs00000.o    DllMain
dkxcbs00000.o    __imp_DllMain

Archive\*.o Differences

MaulingMonkey commented 5 years ago

Yep, .idata$6 is supposed to contain ordinals: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=blob;f=binutils/dlltool.c;hb=HEAD#l228