-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SignedXml cannot validate signature that contain XPath transforms #82363
Comments
Tagging subscribers to this area: @dotnet/area-system-security, @vcsjones Issue DetailsDescriptionI have a few XML documents that have been signed using various tools, but their validation fails in .NET. However, these documents are deemed valid in tools such as the European Commission Digital Signature Service (DSS). Reproduction StepsGenerate an enveloped XAdES signed XML document via DSS tool. The transform that seems to not be supported. <ds:Transform Algorithm="http://www.w3.org/2002/06/xmldsig-filter2">
<dsig-filter2:XPath xmlns:dsig-filter2="http://www.w3.org/2002/06/xmldsig-filter2" Filter="subtract">/descendant::ds:Signature</dsig-filter2:XPath>
</ds:Transform> The validation code. XmlDocument document = new() { PreserveWhitespace = true };
document.Load("test-signed-xades-baseline-b.xml");
var signedXml = new SignedXml(document);
signedXml.LoadXml((XmlElement)document.GetElementsByTagName("Signature", SignedXml.XmlDsigNamespaceUrl)[0]!);
Console.WriteLine(signedXml.CheckSignature()); Expected behaviorThe signature validation is successful. Actual behavior
Regression?No response Known WorkaroundsNo response ConfigurationNo response Other informationI have a signature produced by a Java application that uses a different XPath transform. This signature also cannot be validated. <ds:Transform Algorithm="http://www.w3.org/TR/1999/REC-xpath-19991116">
<ds:XPath>not(ancestor-or-self::ds:Signature)</ds:XPath>
</ds:Transform> Adding signedXml.SafeCanonicalizationMethods.Add("http://www.w3.org/TR/1999/REC-xpath-19991116");
|
Thanks for reporting this, @petarpetrovt. We won't be able to investigate this further during .NET 8, so I'm moving this to Future. I'm going to label this as
help wanted
|
I'm facing the same issue with the netstandard version of the "System.Security.Cryptography.Xml" dll.....with the net framework version of this dll , it works perfectly fine This exception was originally thrown at this call stack: |
The XPath transform is not safe, it is intentionally not listed in the safe transforms list; and callers who need to use it have to explicitly register it in themselves. There are notes about the carriage return issue in #99856. |
Description
I have a few XML documents that have been signed using various tools, but their validation fails in .NET. However, these documents are deemed valid in tools such as the European Commission Digital Signature Service (DSS).
Reproduction Steps
Generate an enveloped XAdES signed XML document via DSS tool.
The transform that seems to not be supported.
The validation code.
Expected behavior
The signature validation is successful.
Actual behavior
Regression?
No response
Known Workarounds
No response
Configuration
No response
Other information
I have a signature produced by a Java application that uses a different XPath transform. This signature also cannot be validated.
Adding
http://www.w3.org/TR/1999/REC-xpath-19991116
algorithm inSafeCanonicalizationMethods
property allows to bypass IsSafeTransform check but then throwsXPathException
, maybe related to this #21451 issue.The text was updated successfully, but these errors were encountered: