You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Both sibling elements should be decrypted and GetOutput() should return the transformed document without throwing.
Actual behavior
Unhandled exception. System.NullReferenceException: Object reference not set to an instance of an object.
at System.Security.Cryptography.Xml.XmlDecryptionTransform.ReplaceEncryptedData(XmlElement encryptedDataElement, Byte[] decrypted) in XmlDecryptionTransform.cs:line 176
at System.Security.Cryptography.Xml.XmlDecryptionTransform.ProcessEncryptedDataItem(XmlElement encryptedDataElement) in XmlDecryptionTransform.cs:line 211
at System.Security.Cryptography.Xml.XmlDecryptionTransform.ProcessElementRecursively(XmlNodeList encryptedDatas) in XmlDecryptionTransform.cs:line 245
at System.Security.Cryptography.Xml.XmlDecryptionTransform.GetOutput() in XmlDecryptionTransform.cs:line 276
at Program.<Main>$(String[] args) in Program.cs:line 25
Regression?
Unknown.
Known Workarounds
N/A
Configuration
N/A
Other information
ProcessElementRecursively initially queues both sibling EncryptedData nodes. After decrypting the first node, this expression is evaluated from the replacement child:
child.SelectNodes("//enc:EncryptedData",_nsm!)
Because the XPath begins with //, it searches from the document root and finds the second sibling, even though that node is already in the queue. The second node is therefore queued twice.
The original queue entry decrypts and replaces the second node, detaching it from the document. When the duplicate entry is subsequently processed, encryptedDataElement.ParentNode is null. ReplaceEncryptedData dereferences that null parent and throws the NullReferenceException.
Description
XmlDecryptionTransform.GetOutput()throws aNullReferenceExceptionwhen the input document contains two siblingEncryptedDataelements.Reproduction Steps
Expected behavior
Both sibling elements should be decrypted and
GetOutput()should return the transformed document without throwing.Actual behavior
Regression?
Unknown.
Known Workarounds
N/A
Configuration
N/A
Other information
ProcessElementRecursivelyinitially queues both siblingEncryptedDatanodes. After decrypting the first node, this expression is evaluated from the replacement child:Because the XPath begins with
//, it searches from the document root and finds the second sibling, even though that node is already in the queue. The second node is therefore queued twice.The original queue entry decrypts and replaces the second node, detaching it from the document. When the duplicate entry is subsequently processed,
encryptedDataElement.ParentNodeis null.ReplaceEncryptedDatadereferences that null parent and throws theNullReferenceException.Note
This issue was drafted with GitHub Copilot.