iris security command checks for them from a terminal.
Patterns
eval() / exec() - evalUsage
Calls to eval() in JavaScript and TypeScript, and exec() in Python and Go. These run whatever text they are given as code. If any part of that text ever comes from a user, the user can make your program run code of their choosing.
SQL concatenation - sqlConcatenation
A database query built by gluing text together, either with + or by inserting values into a template. This is the root cause of almost every SQL injection vulnerability, where a user types database commands into a form field and the database runs them.
Only uppercase SQL keywords are matched (
SELECT, INSERT, UPDATE, DELETE, DROP), so an error message containing the word “delete” is not flagged. Parameterised queries, or a query builder that handles escaping, remove the risk entirely.Insecure RNG - insecureRandom
An ordinary random number generator used where unguessable values are needed, such as session tokens, CSRF nonces and password reset links. Ordinary generators are predictable enough that a determined attacker can guess their output.
Use
crypto.randomBytes in Node, crypto/rand in Go, or secrets in Python for anything security-sensitive.
ReDoS-risk regex - unsafeRegex
A regular expression (regex) is a text-matching pattern. One with a repeat inside a repeat, such as (a+)+ or (a|aa)+, can take an enormous number of steps on certain inputs. A short, carefully made string can keep a processor busy for minutes.
So any such regex applied to text from users lets them slow down or stop your service. This is called ReDoS, regular-expression denial of service.
Iris Code reports the pattern itself in the languages the check covers. The fix is to rewrite it without the nesting, or to use a regex engine that does not backtrack.
Hardcoded localhost URL - hardcodedLocalhost
http://localhost or http://127.0.0.1 written into code that runs in production. These addresses mean “this machine”, so on a server the call either fails or reaches whatever else happens to be listening on that port.
Test files are skipped. A
localhost URL in *.test.ts or *_test.go is usually intentional.TLS verification disabled - disabledTlsVerification
A setting that tells a secure (HTTPS) connection to accept any certificate, including expired and self-signed ones. It is usually added to work around a certificate problem during development and then ships by accident.
The certificate is what proves you are talking to the real server. Without the check, an attacker sitting between you and the server can read and change the traffic, so the connection is no safer than plain HTTP.
Debug flag enabled - debugFlagsEnabled
debug: true in a settings object in code that runs in production. Debug modes typically log more detail, relax security controls and show internal details in error messages that users can see.
Test files are skipped.
debug: true in a test setup file is intentional.Weak hashing - weakHashing
Use of MD5 or SHA-1 to hash data. A hash is a fingerprint of some data. Both of these are broken: two different inputs with the same fingerprint are cheap to produce, so neither belongs in password storage, signatures or checks that a file has not been altered.
Use SHA-256 or stronger for integrity checks, and
bcrypt or argon2 for password storage. A plain hash of any algorithm is unsuitable for passwords.
Open redirect - openRedirect
A redirect that sends the visitor to an address taken from the request without checking it. An attacker can then share a link on your own domain, which your users have reason to trust, that sends them on to a phishing site.
Iris Code reports it when a redirect call (res.redirect(...) in Express, http.Redirect(...) in Go) receives a value straight from a request parameter. Check the destination against a list of paths you control.
CLI scanning
The CLI is the set of Iris Code commands you type in a terminal.iris security is free and needs no account:
Configuration
Security smells are on by default. To switch them all off:Scoring
Each finding takes points off the file’s health score. Each pattern has its own deduction, or weight, which Pro users can change underhealthScoreWeights. The defaults are:
These are the global defaults. The
security preset raises several of them - evalUsage and sqlConcatenation to 8, disabledTlsVerification and openRedirect to 12, weakHashing to 8, debugFlagsEnabled to 4, insecureRandom to 3, and hardcodedLocalhost to 2 - see Scoring Weights for the full picture.Failing a build on them (Pro)
A gate is the check that can fail a push or build when your code goes over a limit you have set.gateMaxSecuritySmells sets the most security smells allowed across the whole workspace. The CLI, the pre-push hook and the build hook all apply it, the same way gateMaxSecrets limits secrets.
Inline diagnostics
WithenableInlineDiagnostics switched on and inlineDiagnostics.securitySmells left at true, every finding is underlined as a warning in the editor and listed in the Problems panel, naming the pattern and the risk.