Bug 4938 - SignedXml reporting Malformed reference object where referenced attribute name is lowercase id, rather than Id
Summary: SignedXml reporting Malformed reference object where referenced attribute nam...
Status: RESOLVED FIXED
Alias: None
Product: Class Libraries
Classification: Mono
Component: System.Security (show other bugs)
Version: master
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2012-05-07 23:56 UTC by Andrew Patterson
Modified: 2015-09-23 14:42 UTC (History)
2 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description Andrew Patterson 2012-05-07 23:56:36 UTC
When signing an XML document there is a concept of the
Reference that indicates where and how to sign a portion
of the XML document.
The Reference object contains a URI which is often
something like

#aaabbbccc

to indicate that in the following xml

<mydocument>
  <signthis id="aaabbbccc">
    <content/>
  </signthis>
</mydocument>

we would like to sign the 'signthis' nodes

It is not clear from various XML sources how URI
fragments are meant to be treated when the underlying
DTD/schema of 'mydocument' is not available. In
this case, the current SignedXml implementation
defaults to looking for an attribute named 'Id'.

From GetIdElement() in mono / mcs / class / System.Security / System.Security.Cryptography.Xml / SignedXml.cs

---
// this works only if there's a DTD or XSD available to define the ID
XmlElement xel = document.GetElementById (idValue);
if (xel == null) {
  // search an "undefined" ID
  xel = (XmlElement) document.SelectSingleNode ("//*[@Id='" + idValue + "']");
}
---

However, in porting working code over from .NET we have a
situation where our document to be signed uses a lowercase
'id' attribute (as in the id attribute name is lowercase,
 not its content).

So I believe the fix is to add an additional search
for the lowercase id attribute where xel is still null..

if (xel == null)
  xel = (XmlElement) document.SelectSingleNode ("//*[@id='" + idValue + "']");


The current Mono behaviour is definitely different from the
current .NET implementation which will find the lowercase id
element in these situations where the DTD/XSD is missing.
Comment 1 Miguel de Icaza [MSFT] 2015-09-23 14:42:59 UTC
Fixed