Bug 135604 - Invalid multiple XAdES Digital Signature in LibreOffice 7.0
Summary: Invalid multiple XAdES Digital Signature in LibreOffice 7.0
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
7.0.0.3 release
Hardware: x86-64 (AMD64) Windows (All)
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: Digital-Signatures
  Show dependency treegraph
 
Reported: 2020-08-10 10:33 UTC by Andrii Melashchenko
Modified: 2021-11-04 15:39 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:


Attachments
Sample odt that fails validation (13.94 KB, application/vnd.oasis.opendocument.text)
2020-08-10 10:35 UTC, Andrii Melashchenko
Details
Sample p12 from DSS lib to sign ODT (2.40 KB, application/x-pkcs12)
2020-08-10 10:35 UTC, Andrii Melashchenko
Details
DSS Report with faild XAdES signatures (37.69 KB, application/pdf)
2020-08-10 10:36 UTC, Andrii Melashchenko
Details
Example file with text and no signature (17.00 KB, application/vnd.oasis.opendocument.text)
2021-10-29 12:58 UTC, Gabor Kelemen (allotropia)
Details
The previous document signed twice with two different X.509 certificates (22.56 KB, application/vnd.oasis.opendocument.text)
2021-10-29 12:59 UTC, Gabor Kelemen (allotropia)
Details
DSS report on the signed file (81.83 KB, application/pdf)
2021-10-29 13:00 UTC, Gabor Kelemen (allotropia)
Details
The example file with 3 bad signatures (23.51 KB, application/vnd.oasis.opendocument.text)
2021-10-29 13:21 UTC, Gabor Kelemen (allotropia)
Details
DSS report on the bad signed file (107.94 KB, application/pdf)
2021-10-29 13:21 UTC, Gabor Kelemen (allotropia)
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Andrii Melashchenko 2020-08-10 10:33:47 UTC
Description:
When you apply multiple (two and more) XAdES signature to the odt document - they don't comply with XdES standard (my assumption) and validation with https://ec.europa.eu/cefdigital/DSS/webapp-demo/validation fails.

Steps to Reproduce:
1.Import pfx file into MS windows certmgr.msc tool
2.Save odt document
3.Apply the first signature
4. Apply the second signature
5. Open https://ec.europa.eu/cefdigital/DSS/webapp-demo/validation
6. Upload signed document
7. Validation fails

Actual Results:
Validation failed

Expected Results:
Two signatures are passes validation and marked valid


Reproducible: Always


User Profile Reset: No



Additional Info:
Validate XAdES signatures
Comment 1 Andrii Melashchenko 2020-08-10 10:35:09 UTC
Created attachment 164102 [details]
Sample odt that fails validation
Comment 2 Andrii Melashchenko 2020-08-10 10:35:47 UTC
Created attachment 164103 [details]
Sample p12 from DSS lib to sign ODT

p12 passowrd: password
Comment 3 Andrii Melashchenko 2020-08-10 10:36:54 UTC
Created attachment 164104 [details]
DSS Report with faild XAdES signatures
Comment 4 Andrii Melashchenko 2020-08-10 16:22:54 UTC
I made request to DSS lib tech team to figure out the issue - https://ec.europa.eu/cefdigital/tracker/browse/DSS-2183
Comment 5 Andrii Melashchenko 2020-08-11 06:44:37 UTC
My assumption was proven by DSS team: their comment 

The problem is that both signatures in your file contain references to SignedProperties with the same Id "idSignedProperties". Conversely, the element with the Id "idSignedProperties" itself is present in the file two times. This is not valid XML structure and an identifier cannot be duplicated in a file. Because of this the DSS validation correctly fails with the result SIGNED_DATA_NOT_FOUND (unable to determine the referenced object).

 

By default DSS creates a unique deterministic identifier for each signed element, including SignedProperties. This allows avoiding of conflicts between references. In the attachment you can find an example of a valid double-signed ODT document created with DSS.

I hope this clarifies.

 
Best regards,

Aleksandr.
Comment 6 Andrii Melashchenko 2020-08-26 09:22:21 UTC
Can I help with comments?
Comment 7 Andrii Melashchenko 2020-10-05 06:42:20 UTC
FYI
There is possible issue with ECDSA in Microsoft Crypto libes, it's a theory now.
More details - https://ec.europa.eu/cefdigital/tracker/browse/DSS-2191?focusedCommentId=95743&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-95743
Comment 8 Andrii Melashchenko 2021-01-01 17:37:35 UTC
UP
Is there way to fund resolution of this bug?
Comment 9 Dieter 2021-01-02 12:24:45 UTC
I'm not an expert with digital signatures, but bug 105856 might be realted to the bug you reported. Might be worth to have a look at it.
Comment 10 Andrii Melashchenko 2021-10-08 13:47:23 UTC
Up
Comment 11 Gabor Kelemen (allotropia) 2021-10-29 12:58:03 UTC
Created attachment 175990 [details]
Example file with text and no signature
Comment 12 Gabor Kelemen (allotropia) 2021-10-29 12:59:54 UTC
Created attachment 175991 [details]
The previous document signed twice with two different X.509 certificates
Comment 13 Gabor Kelemen (allotropia) 2021-10-29 13:00:49 UTC
Created attachment 175992 [details]
DSS report on the signed file

Seems to work fine with current master:

Version: 7.3.0.0.alpha0+ / LibreOffice Community
Build ID: 5b0ae3b59cd2cccfb72d991657366eb2a69bff49
CPU threads: 8; OS: Linux 5.4; UI render: default; VCL: gtk3
Locale: hu-HU (hu_HU.UTF-8); UI: en-US
Calc: threaded
Comment 14 Andrii Melashchenko 2021-10-29 13:13:40 UTC
(In reply to Gabor Kelemen (allotropia) from comment #13)
> Created attachment 175992 [details]
> DSS report on the signed file
> 
> Seems to work fine with current master:
> 
> Version: 7.3.0.0.alpha0+ / LibreOffice Community
> Build ID: 5b0ae3b59cd2cccfb72d991657366eb2a69bff49
> CPU threads: 8; OS: Linux 5.4; UI render: default; VCL: gtk3
> Locale: hu-HU (hu_HU.UTF-8); UI: en-US
> Calc: threaded

Thank you!
I'll test it and let you know the result with a valid EU DSS signature, I mean signature certificate issued with QTSP
Comment 15 Gabor Kelemen (allotropia) 2021-10-29 13:21:08 UTC
Created attachment 175993 [details]
The example file with 3 bad signatures

This seems to have been fixed by:

https://git.libreoffice.org/core/+/fd5463343ab7f784070f1ab87a345eed20803d07%5E%21

author	Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>	Wed Oct 27 14:15:17 2021 +0200
committer	Tomaž Vajngerl <quikee@gmail.com>	Thu Oct 28 08:49:57 2021 +0200

xmlsec: signing the document fails the 3rd time (invalid signature)

The commit right before this produced the attached file, which fails completely the DSS check.
Comment 16 Gabor Kelemen (allotropia) 2021-10-29 13:21:35 UTC
Created attachment 175994 [details]
DSS report on the bad signed file
Comment 17 Gabor Kelemen (allotropia) 2021-10-29 13:23:00 UTC
Thanks Tomaž for fixing this!
Comment 18 Andrii Melashchenko 2021-11-04 15:39:56 UTC
It's fixed 
Thx Tomaž