The secure validation of XML signatures is switched off

tx0/java:insecure-xml-signaturedefaulterrorsecurity, cwe-347

What it finds

The XML digital signature API of the JDK checks signatures in a secure mode that refuses weak algorithms and limits transforms and references. Setting the property org.jcp.xml.dsig.secureValidation to false turns that off, which lets crafted signatures pass or exhaust the validator (CWE-347), as the javax.xml.crypto documentation says.

Reported is setProperty with that property and false.

From the rule's source, insecure_xml_signature.rs.

Example from the rule's tests
import javax.xml.crypto.dsig.dom.DOMValidateContext; class Signatures {  void check(DOMValidateContext context) {    context.setProperty("org.jcp.xml.dsig.secureValidation", Boolean.FALSE);tx0 reports: without the secure mode    context.setProperty("org.jcp.xml.dsig.secureValidation", Boolean.TRUE);  }}
Highlighted lines are the ones tx0 reports, with its message under each; the other lines are left alone.

Turn it on, off or suppress it

The rule runs in every tier. To turn it off for a project, set its level in tx0.toml:

tx0.toml
[rules]
"tx0/java:insecure-xml-signature" = "off"

To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:

// tx0: ignore[tx0/java:insecure-xml-signature] reason="..."

tx0 explain tx0/java:insecure-xml-signature shows the same in the terminal. Found a false positive? Report it.