Repository navigation
Fix attach-signature -nest accepting a signature of another file - #541
Open
francoisgirinon-netizen wants to merge 1 commit into
Open
francoisgirinon-netizen wants to merge 1 commit into
francoisgirinon-netizen wants to merge 1 commit into
Conversation
After attaching a signature, check_attached_data() calls verify_signed_file() without signature verification, which succeeded as soon as the digest of one signature matched the file. With -nest, the current signature always matches, so attach-signature -nest accepted a signature computed for another file, and wrote a file whose nested signature fails verification. Without signature verification, require the digest of every signature to match. Test the attach of a nested signature of another file for each format but MSI, CAT and APPX.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request Type
Related Issue
Issue number: N/A
Current Behavior
attach-signature -nestaccepts a signature computed for another file, andwrites a file whose nested signature fails verification:
After attaching,
check_attached_data()callsverify_signed_file()withoutsignature verification, which succeeds as soon as the digest of one signature
matches. With
-nest, the current signature always matches.Reproduced on
masterfor PE, CAB, PowerShell (.ps1,.psc1), MOF andJavaScript files. APPX does not support nesting, so it is not affected.
New Behavior
attach-signaturefails withSignature mismatchwhen the attached signaturedoes not match the file, and no output file is left.
Scope of Changes
osslsigncode.c: inverify_signed_file(), without signature verification,the digest of every signature must match, not just one. This path is only used
by
check_attached_data().cmake/CMakeTest.cmake: new testsattached_mismatch_<ext>attach a nestedsignature of another file and expect
Signature mismatch, for exe, ex_,ps1, psc1, mof and js.
Testing
Existing tests
New tests added
Manual testing
ctest: 430/430 passed on Windows x86-64 (MSVC 2019, OpenSSL 3.5.9), withoutLARGE_FILE_TESTS.The six new tests fail on
master(the attach succeeds), so they catch thebug.
Still accepted, as on
master: a matching nested signature (the existingattached_pem_*andattached_der_*tests, with-h sha512), attachingwithout
-nestto replace a signature, and attaching a signature that alreadycontains a nested one.
Additional Notes
-nestonto a file whose existing signature no longer matches its content(the file was modified after signing) is now refused too:
masteracceptedit and wrote a file whose primary signature fails verification. Attaching
without
-nestto such a file still works.-add-msi-dse, nesting a signature with a different digest algorithm isnow refused:
masteraccepted it, but rewriting the MsiDigitalSignatureExstream broke the primary signature.
sign -nestalready refuses this case.file is rejected earlier when the MsiDigitalSignatureEx digests differ, and
APPX does not support nesting.
License Declaration