Servers rules
max-request-size
Section titled “max-request-size”Finds request size limits above 8 MB for file uploads with formidable and multer, and above 2 MB for other requests with body-parser, also when the limit stays at a larger default or is missing.
On in the recommended and all configs.
A server that accepts very large requests lets a client fill its memory or disk and stop it from serving other users.
What to do
Section titled “What to do”Set a limit that fits the largest request the route needs: maxFileSize for formidable, limits.fileSize for multer, and limit for body-parser.
Example
Section titled “Example”The call multer({ dest: "uploads/" }) reports unlimited. Use multer({ dest: "uploads/", limits: { fileSize: 4_000_000 } }).
no-any-origin-policy
Section titled “no-any-origin-policy”Finds CORS policies that let any site read the responses: an Access-Control-Allow-Origin of *, the cors middleware with no origin or an origin of * or true, and a handler that copies the request Origin unchecked.
On in the recommended and all configs.
A permissive CORS policy lets any site read the responses that a signed-in user receives.
What to do
Section titled “What to do”Allow only the origins that need access: set origin to a list of trusted sites, and compare a request origin with that list before you send it back.
Example
Section titled “Example”The call app.use(cors()) reports permissive. Use app.use(cors({ origin: ["https://app.example.com"] })).
no-insecure-cookies
Section titled “no-insecure-cookies”Reports explicitly disabled secure and HttpOnly cookie flags in session, CSRF, and cookie APIs.
On in the recommended and all configs.
Secure cookies stay on encrypted connections, and HttpOnly keeps browser scripts from reading them.
What to do
Section titled “What to do”Set secure and httpOnly to true. For csurf, configure cookie options explicitly instead of cookie: true.
Example
Section titled “Example”session({ cookie: { secure: true, httpOnly: true } }) keeps both cookie protections enabled.
no-powered-by-header
Section titled “no-powered-by-header”Requires an Express application to disable its X-Powered-By header.
On in the recommended and all configs.
The default response header tells clients which server framework handles their requests.
What to do
Section titled “What to do”Call app.disable(‘x-powered-by’) after creating the application, or install middleware that removes the header.
Example
Section titled “Example”const app = express(); app.disable('x-powered-by'); disables the framework header.
no-production-debug
Section titled “no-production-debug”Finds use calls that add the errorhandler middleware outside an if statement, so that it runs in every environment.
On in the recommended and all configs.
The errorhandler middleware sends stack traces and other details of the server to the client, which helps attackers.
What to do
Section titled “What to do”Add the middleware only in development, inside a check such as if (process.env.NODE_ENV === "development").
Example
Section titled “Example”The call app.use(errorhandler()) at the top level of a module reports debugMiddleware. Wrap it in if (process.env.NODE_ENV === "development") { app.use(errorhandler()); }.
no-unchecked-request-data
Section titled “no-unchecked-request-data”Follows a field of req or request, such as req.query, through the variables of one function, and reports it where it reaches a redirect, an HTML response, a view name, a file path, an outbound request, SQL text, a regular expression, a shell, or a property name.
On in the recommended and all configs.
Request data comes from the client, so in these places it opens a redirect, reflected XSS, a path traversal, a request forgery, SQL injection, a slow regular expression, command injection, or prototype pollution.
What to do
Section titled “What to do”Check the value against a fixed list, escape it for the place it goes, or pass it as a parameter, such as a query parameter in SQL.
Example
Section titled “Example”const file = req.query.file; fs.readFile(path.join(root, file), done); reports path. Look the file up by a key, or keep only path.basename(file).
no-unsafe-file-uploads
Section titled “no-unsafe-file-uploads”Finds formidable forms without an uploadDir or with keepExtensions: true, and multer.diskStorage storages without a destination.
On in the recommended and all configs.
An uploaded file that lands in a shared folder, or that keeps an extension such as .html or .js, can be served or run by the server.
What to do
Section titled “What to do”Set an upload folder that the server never serves, and give stored files a name and extension that the server chooses.
Example
Section titled “Example”The call formidable({ keepExtensions: true }) reports extensionAndFolder. Use formidable({ uploadDir: "/var/uploads" }).
no-unsafe-security-headers
Section titled “no-unsafe-security-headers”Reports disabled Helmet security headers and unsafe referrer or HSTS settings in Express middleware.
On in the recommended and all configs.
These headers restrict browser access, prevent MIME guessing, and require encrypted connections.
What to do
Section titled “What to do”Keep the Helmet defaults. Use a restrictive referrer policy and HSTS for at least six months with subdomains included.
Example
Section titled “Example”app.use(helmet()); keeps the default security headers enabled.
no-unvalidated-json-body
Section titled “no-unvalidated-json-body”Reports await req.json() and await request.json() whose result no schema parses with parse or safeParse. No config turns it on; gspot turns it on for the Supabase edge functions.
No config turns it on; turn it on in your ESLint config.
A request body comes from the client, so any field can be missing or of the wrong type. Code that trusts it can write bad data or fail in ways that leak details.
What to do
Section titled “What to do”Parse the body with a schema, such as a Zod schema, before the code reads it.
Example
Section titled “Example”const body = await req.json(); with no schema reports unvalidated. Write const body = Order.parse(await req.json());.
require-csrf-middleware
Section titled “require-csrf-middleware”In a file that imports csurf, finds post, put, delete, and patch routes that run without the csurf middleware, and an ignoreMethods option that skips a method other than GET, HEAD, and OPTIONS.
On in the recommended and all configs.
A route that changes data without a CSRF check lets another site send that change in the name of a signed-in user.
What to do
Section titled “What to do”Add the csurf middleware with app.use before the routes, or pass it to each route that changes data. Keep only safe methods in ignoreMethods.
Example
Section titled “Example”After const csrf = csurf();, the route app.post("/transfer", transfer) reports unprotectedRoute. Use app.post("/transfer", csrf, transfer).
require-session-regeneration
Section titled “require-session-regeneration”Finds route callbacks that come after passport.authenticate in the same route and never call regenerate, unless the authentication passes session: false.
On in the recommended and all configs.
A session that keeps its identifier after login lets an attacker who planted that identifier take over the signed-in session.
What to do
Section titled “What to do”Call req.session.regenerate in the callback that runs after authentication, and copy the data you keep into the new session.
Example
Section titled “Example”The route app.post("/login", passport.authenticate("local"), function (req, res) { res.redirect("/"); }) reports keptSession. Call req.session.regenerate(...) in the callback.
static-before-session
Section titled “static-before-session”Finds app.use(express.static(…)) calls that come after the express-session or cookie-session middleware on the same Express app.
On in the recommended and all configs.
Static files then pass through the session middleware, which sets session cookies on responses that caches and other users can receive.
What to do
Section titled “What to do”Add the static middleware before the session middleware.
Example
Section titled “Example”The calls app.use(session(options)); app.use(express.static("public")); report staticAfterSession on the second call. Swap the two calls.