pjfanning opened a new pull request, #1609:
URL: https://github.com/apache/poi/pull/1609

   This is #1595 rebased onto trunk, with one more commit that fixes what a 
review of it found. The first two commits are the ones of #1595, unchanged 
apart from the rebase; this replaces that PR.
   
   What #1595 does: `verifySignature()` validated only the first signature 
part, and which one that is follows from the relationship ids in the document. 
A package can hold several signatures, so a crafted signature only had to sort 
after a valid one to escape validation. Every signature is now validated, every 
signature origin is followed, and a registered signature without a part makes 
the result false.
   
   What the last commit changes:
   
   - **Bounded work.** Each validation digests the signed parts again, and a 
crafted `origin.sigs.rels` can list thousands of relationships. A signature 
part is now validated once, however many relationships point at it, and a 
package with more signatures than `SignatureConfig.getMaxSignatures()` (new, 
100 by default) is rejected with an `EncryptedDocumentException`.
   - **Signing replaces every signature.** With `allowMultipleSignatures=false` 
only the `sigN.xml` parts of `/_xmlsignatures/origin.sigs` were removed. 
Signatures with another name, below another signature origin or without a part 
stayed and are validated now, so a package POI had just signed could verify as 
invalid. All of them are removed. For this, `OOXMLSignatureFacet` no longer 
signs an external relationship of the signature type: a signature relationship 
is not among what is signed, and it was only the external ones that were.
   - **Order of the signatures.** With one invalid and one unreadable 
signature, the result was false or an exception depending on which came first. 
It is false now, wherever they are listed; the exception is thrown when no 
signature is invalid.
   - **`hasUnresolvedSignatures()`** is new and public. The loop over 
`getSignatureParts()` which the docs recommend can't see a registered signature 
that has no part, so the docs now show both.
   - **`getSignatureParts()` overrides.** `verifySignature()` iterates 
`getSignatureParts()` again instead of its own iterator, so a subclass which 
filters the signatures is not bypassed.
   - **Fragments.** A signature origin relationship with a fragment 
(`origin.sigs#x`) was unresolved, while a signature relationship with one was 
accepted. The fragment is ignored for both now.
   - **`updateConfigOnValidate`.** Every valid signature updated the config, so 
it described the last signer. Only the first signature updates it, as when only 
that one was validated.
   
   Each with a test in `TestSignatureInfo`.
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   


-- 
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]

Reply via email to