TLS certificate or host name verification is turned off

tx0/php:tls-verification-disableddefaulterrorsecurity/cryptodepth fastsecurity, cwe-295

What it finds

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false) and 'verify_peer' => false: turning off certificate checks lets anyone on the network path pose as the server and read or change the traffic. cURL options, set one by one or in an array, stream context options, and the verify option of HTTP clients such as Guzzle are checked. A setting made under a condition about verification follows a switch the user sets and is left alone.

From the rule's source, tls_verification_disabled.rs.

Example from the rule's tests
<?phpfunction fetch($url){    $ch = curl_init($url);    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);tx0 reports: CURLOPT_SSL_VERIFYPEER turns off certificate verification    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);tx0 reports: CURLOPT_SSL_VERIFYHOST turns off certificate verification    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);    $context = stream_context_create(['ssl' => [        'verify_peer' => false,tx0 reports: verify_peer turns off certificate verification        'verify_peer_name' => true,    ]]);    $client = new Client(['verify' => false]);tx0 reports: verify turns off certificate verification    return [$ch, $context, $client];}
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/php:tls-verification-disabled" = "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/php:tls-verification-disabled] reason="..."

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