naruto-lgtm opened a new pull request, #1595: URL: https://github.com/apache/poi/pull/1595
Repro: register a copy of `_xmlsignatures/sig1.xml` from hello-world-signed.docx as a second signature of the same document and change one of its reference digests; `verifySignature()` still returns true. Cause: it validated only the first `SignaturePart` the signature origin leads to, and which one that is follows from the ids of the signature origin's relationships, i.e. from the document. Fix: validate every signature part, and require at least one. A package may legitimately carry several signatures (co-signing, signature lines), so an attacker who adds one signature of their own beside the original one chooses which signature POI checks, and the original signature over the modified parts is never looked at. That also caps what the per-signature checks in `SignaturePart.validate()` buy us, since a crafted signature only needs to sort second to escape them. Callers that want a verdict per signature already have `getSignatureParts()`. Packages written by Office and by POI's own signing path have all their signatures valid, so valid documents behave as before: every signed sample in test-data and the dual-signed packages in `testMultiSign` still verify. A later signature part that cannot be parsed now raises the same `EncryptedDocumentException` that a broken first part always did. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
