Networks rules
no-clear-text-protocols
Section titled “no-clear-text-protocols”Finds clear-text network protocols, such as http, ftp, and ws URLs to public hosts, nodemailer and ftp connections without TLS, telnet-client, and AWS CDK resources without encryption in transit.
On in the recommended and all configs.
A clear-text protocol sends data and credentials that anyone on the network path can read and change.
What to do
Section titled “What to do”Use the secure protocol, such as https, sftp, or wss, and turn on TLS for mail, FTP, and AWS resources.
Example
Section titled “Example”The literal "http://api.acme.internal/users" reports clearText. Use "https://api.acme.internal/users". "http://localhost:3000" and "https://www.example.com" pass.
no-hardcoded-ip
Section titled “no-hardcoded-ip”Finds string literals that hold an IPv4 or IPv6 address, with or without a netmask, also written in octal or hexadecimal octets. Loopback, unspecified, broadcast, and documentation addresses pass.
On in the all config.
An address written in the code ties the program to one network, and changing it needs a new release. It can also expose an internal host.
What to do
Section titled “What to do”Read the address from configuration, or use a host name that DNS resolves.
Example
Section titled “Example”The literal "10.0.12.4" reports hardcoded. Read it from configuration, such as process.env.DATABASE_HOST.
unverified-certificate
Section titled “unverified-certificate”Finds https.request, request.get, and tls.connect calls whose options set rejectUnauthorized to false.
On in the recommended and all configs.
A connection that accepts any certificate lets an attacker on the network read and change its traffic.
What to do
Section titled “What to do”Remove rejectUnauthorized: false. To trust a private certificate authority, pass its certificate in the ca option.
Example
Section titled “Example”The call https.request({ host, rejectUnauthorized: false }) reports unverified. Use https.request({ host, ca: authorityCertificate }).
unverified-hostname
Section titled “unverified-hostname”Finds https.request, request.get, and tls.connect calls that pass a checkServerIdentity function that returns nothing, undefined, null, or false on every path, so it accepts every server.
On in the recommended and all configs.
A connection that does not check the server name accepts a valid certificate of any other server, so an attacker on the network can read and change its traffic.
What to do
Section titled “What to do”Let checkServerIdentity return an error for a name that does not match, or remove the option.
Example
Section titled “Example”The call tls.connect(port, host, { checkServerIdentity: () => {} }) reports unverified. Remove the checkServerIdentity option.
weak-ssl
Section titled “weak-ssl”Finds TLS options of https.request, request.get, tls.connect, and tls.createSecureContext that allow TLS 1.1 or older: a minVersion or maxVersion of TLSv1 or TLSv1.1, an old secureProtocol, or secureOptions flags that do not turn off TLS 1.0 and 1.1.
On in the recommended and all configs.
TLS 1.0 and 1.1 have known weaknesses, so an attacker on the network can read or change the traffic.
What to do
Section titled “What to do”Set minVersion: "TLSv1.2", or use a secureProtocol of TLS 1.2 or newer.
Example
Section titled “Example”The call tls.connect({ host, minVersion: "TLSv1.1" }) reports oldVersion. Use tls.connect({ host, minVersion: "TLSv1.2" }).