Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Verify digital signatures of downloaded EXEs and MSUs #8

Open
rickbrew opened this issue Jun 26, 2021 · 2 comments
Open

Verify digital signatures of downloaded EXEs and MSUs #8

rickbrew opened this issue Jun 26, 2021 · 2 comments
Labels
enhancement New feature or request

Comments

@rickbrew
Copy link

rickbrew commented Jun 26, 2021

Details

Verifying the digital signature of downloads serves two purposes. One, it ensures that the file has not been tampered with or corrupted. Network corruption happens! I had a friend with a bad NIC who was going crazy until we figured it out. CRC checks are good :)

Two, it ensures that the file is digitally signed by someone and that the certificate is trusted by the system. The file could still have been maliciously replaced, but at least the certificate provides a paper trail.

Here's my code that does this. You'll need to trim the Native*.cs methods, I just included them as-is from my code right now.

VerifySignaturesCode.zip

You can pass null for Authenticode::VerifySignedFile()'s IWin32Window owner parameter, which is reasonable if passing false for both showNegativeUI and showPositiveUI (which is what I do).

You'll also need to make sure KB3004394 is installed. A fresh Win7 SP1 install has an expired Microsoft Root Certificate Authority. Check crypt32.dll's version as >= 6.1.7601.18700 using the code snippet I posted on Twitter https://twitter.com/rickbrewPDN/status/1408860154792054784

@rickbrew rickbrew added the enhancement New feature or request label Jun 26, 2021
@rickbrew
Copy link
Author

rickbrew commented Jun 26, 2021

Also, KB3004394 must be the very first thing installed, after which a reboot is required before doing anything else. The new cert doesn't seem to work until then. Since it's updating crypt32.dll and others, I think the update doesn't actually include the certs -- they don't seem to exist (in certmgr.msc) until I try to inspect the digital signature of a signed file. Then they appear (certmgr doesn't have a Refresh command, just close it and relaunch). I suspect it downloads them on-demand once the update is in place? ¯_(ツ)_/¯

@rickbrew
Copy link
Author

(and yes, .msu's can be verified too, not just .exe's)

@Tyrrrz Tyrrrz changed the title Should verify digital signatures of downloaded EXEs and MSUs Jun 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
1 participant