The certificate or host name of a TLS server is not checked
What it finds
requests.get(url, verify=False), ssl._create_unverified_context(): without checking the server's certificate and name, anyone on the network path can pose as the server and read or change the traffic (CWE-295).
Reported are verify=False in calls of requests and httpx, the unverified context functions of ssl, cert_reqs=ssl.CERT_NONE, and assignments of ssl.CERT_NONE to verify_mode or of False to check_hostname.
From the rule's source, tls_verify_disabled.rs.
import requestsimport ssl def fetch(url, context): requests.get(url, verify=False)tx0 reports: requests.get is told not to check the server's certificate requests.post(url, verify=True) ctx = ssl._create_unverified_context()tx0 reports: ssl._create_unverified_context makes a context that checks no certificate context.check_hostname = Falsetx0 reports: setting check_hostname this way turns off a check of the TLS server context.verify_mode = ssl.CERT_NONEtx0 reports: setting verify_mode this way context.verify_mode = ssl.CERT_REQUIRED return ctx 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:
[rules]
"tx0/python:tls-verify-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/python:tls-verify-disabled] reason="..."tx0 explain tx0/python:tls-verify-disabled shows the same in the terminal. Found a false positive? Report it.