Certificate verification of a TLS connection is turned off

tx0/ts:tls-verification-disabledrecommendedwarningsecurity, cwe-295

What it finds

A TLS client that does not verify the server's certificate talks to whoever answers, including an attacker in the middle, while the connection still looks encrypted.

Reported are the option rejectUnauthorized: false, which Node's tls and https modules and the libraries built on them accept, and an assignment of "0" or 0 to process.env.NODE_TLS_REJECT_UNAUTHORIZED, which turns verification off for the whole process.

From the rule's source, tls_verification_disabled.rs.

Example from the rule's tests
import https from "https";export function connect() {  process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";tx0 reports: turns off certificate verification  const agent = new https.Agent({ rejectUnauthorized: false });tx0 reports: accepts any certificate  const safe = new https.Agent({ rejectUnauthorized: true });  process.env.NODE_TLS_REJECT_UNAUTHORIZED = "1";  return [agent, safe];}
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 from the recommended tier up. To turn it on in a lower tier, give it a level in tx0.toml:

tx0.toml
[rules]
"tx0/ts:tls-verification-disabled" = "warning"

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/ts:tls-verification-disabled] reason="..."

tx0 explain tx0/ts:tls-verification-disabled shows the same in the terminal. Found a false positive? Report it.