-
Notifications
You must be signed in to change notification settings - Fork 227
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
Create rule S6377: XML signatures should be verified securely #8982
Comments
Hi, @gaetan-ferry-sonarsource! The specification mentions that we need to raise when
However, according to the Microsoft documentation:
My understanding is that the call will look in the "AddressBook" store for a trusted certificate that can validate the document. The rule description does not mention that and does not explain why using these certificates is not considered a safe approach. |
Hi @costin-zaharia-sonarsource ! When a document is signed with an X.509 signature, the application might indeed check some system keystore for a matching key in order to validate the signature. That said, I think it still causes multiple issues:
For information, you can see what and how we tested in the appsec-poc repository. Regarding the rule description, we would probably need to improve it a bit. I created a hardening ticket for this. Still, I am unsure if it would work to explain all the corner cases in the RSPEC. I feel it might affect the rule readability, but we'll look into this. I hope this helps. |
Why
As part of MMF-3716, we want to close the gap between C# and other languages regarding cryptography related rules support. S6377 is one of the rules that is not currently supported by this analyzer.
What
S6377 aims to detect when XML signatures are insecurely validated. We want to add support for this behavior for both .NET core and .NET framework. Note that XML related cryptographic features are implemented as part of
system.security.cryptography.xml
a .NET platform extension.Detection logic
This rule should raise any time code validates a signature without relying on a trusted public key. In that case, the could would use the signature-embedded public key to perform the validation and would be open to forgery attacks.
We want to raise when:
System.Security.Cryptography.Xml.SignedXml.CheckSignature()
is called (without a parameter).System.Security.Cryptography.Xml.SignedXml.CheckSignatureReturningKey
is called.Example code
RSPEC
This rule's RSPEC (from this PR SonarSource/rspec#3814) contains information regarding messages and highlighting.
The text was updated successfully, but these errors were encountered: