naruto-lgtm opened a new pull request, #1581:
URL: https://github.com/apache/poi/pull/1581

   Repro: take hello-world-signed.docx, change the text in word/document.xml, 
and in _xmlsignatures/sig1.xml wrap the existing `<Object 
Id="idPackageObject">` in another `<Object>`. `SignatureInfo.verifySignature()` 
returns true for the edited document.
   Cause: the part digests live in the ds:Manifest of that object, and 
`org.jcp.xml.dsig.validateManifests` only validates manifests that are direct 
content of the ds:Object children of ds:Signature. Because `validate` registers 
every `@Id` as an ID, `#idPackageObject` still resolves to the nested object, 
whose canonical form (and so the SignedInfo digest and RSA signature) is 
unchanged, but its manifest is never checked. Any part of a signed package can 
be changed this way (XML signature wrapping, CWE-347).
   Fix: `SignaturePart.validate` also requires every ds:Manifest in the 
signature part to be the content of a ds:Object of the ds:Signature, which is 
where Office and POI write them, and logs a warning otherwise.
   
   The check is structural rather than per reference, so it also covers a 
manifest referenced directly from SignedInfo and moved the same way. 
Office-signed samples in test-data (including XAdES and multi-signature files) 
still verify. `TestSignatureInfo.testWrappedPackageObject` fails before the 
change, and `:poi-ooxml:check` passes locally.
   


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