rspec/rules/S6377/java/rule.adoc

43 lines
1.6 KiB
Plaintext
Raw Normal View History

include::../description.adoc[]
== Noncompliant Code Example
The Java XML Digital Signature API doesn't use a strong signature validation mode by default (except when the application runs with a security manager):
2022-02-04 17:28:24 +01:00
[source,java]
----
DOMValidateContext valContext = new DOMValidateContext(new KeyValueKeySelector(), nl.item(0)); // Noncompliant
----
== Compliant Solution
The Java XML Digital Signature API offers a secure validation mode to protect against various https://docs.oracle.com/en/java/javase/14/security/java-xml-digital-signature-api-overview-and-tutorial.html#GUID-8618C294-3BFE-45C3-9A1E-C4629E337E68[security issues]. +
Change or set the ``org.jcp.xml.dsig.secureValidation`` property to ``TRUE``.
2022-02-04 17:28:24 +01:00
[source,java]
----
DOMValidateContext valContext = new DOMValidateContext(new KeyValueKeySelector(), nl.item(0));
valContext.setProperty("org.jcp.xml.dsig.secureValidation", Boolean.TRUE);
----
== See
* https://docs.oracle.com/en/java/javase/14/security/java-xml-digital-signature-api-overview-and-tutorial.html#GUID-DB46A001-6DBD-4571-BDBC-1BBC394BF61E[Oracle Java Documentation] - XML Digital Signature API Overview and Tutorial
* https://owasp.org/www-project-top-ten/2017/A3_2017-Sensitive_Data_Exposure[OWASP Top 10 2017 Category A3] - Sensitive Data Exposure
* http://cwe.mitre.org/data/definitions/347.html[MITRE, CWE-347] - Improper Verification of Cryptographic Signature
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
include::../message.adoc[]
'''
== Comments And Links
(visible only on this page)
include::../comments-and-links.adoc[]
endif::env-github,rspecator-view[]