Skip to main content
interlace

NestJS security linting: ESLint and oxlint on Nest 12

Lint a NestJS 12 app for missing guards, open CORS, unguarded Swagger and unsafe uploads with eslint-plugin-nestjs-security on ESLint 10 or oxlint, with the configs we ran and what each reported.

To lint a NestJS 12 app for security mistakes, install eslint-plugin-nestjs-security and enable its recommended preset in eslint.config.js, or install oxlint-plugin-nestjs-security and list it under jsPlugins in .oxlintrc.json. Both packages carry the same 11 rules under the same IDs (nestjs-security/<rule>). The rules read decorators and NestFactory calls, so they report missing @UseGuards, enableCors({ origin: '*' }), an unconditional SwaggerModule.setup() and similar defaults.

Covers ESLint 10 flat config and oxlint 1.90.0 and 1.94.0 on a NestJS 12.5.1 fixture. Last updated 2026-11-20.

What we ran

A minimal Nest 12 project (six files, written to contain one example of each rule's problem) was linted with both engines. The plugins were not taken from npm: both packages and @interlace/eslint-devkit were built from this repository's workspace (packages/) and installed from local npm pack tarballs.

ComponentVersion
Node.js24.12.0
@nestjs/common, @nestjs/core12.5.1
@nestjs/swagger12.1.2
@nestjs/throttler6.8.0
typeorminstalled for the fixture
ESLint, typescript-eslint10.15.0, 8.73.0
oxlint1.90.0, and 1.94.0 (latest at the time)
eslint-plugin-nestjs-security4.2.1 (local build)
oxlint-plugin-nestjs-security4.2.1 (local build)

Install

npm install -D eslint typescript-eslint eslint-plugin-nestjs-security
eslint.config.js
import tseslint from 'typescript-eslint';
import nestjsSecurity from 'eslint-plugin-nestjs-security';

export default [
  { files: ['src/**/*.ts'], languageOptions: { parser: tseslint.parser } },
  nestjsSecurity.configs.recommended,
];

Run npx eslint src. The recommended preset enables all 11 rules: 5 at error and 6 at warn.

Installing oxlint-plugin-nestjs-security installs eslint-plugin-nestjs-security as its dependency, because the oxlint package re-exports it. It does not install ESLint.

What loaded and what fired

Both engines loaded all 11 rules and reported the same 13 findings on the same lines.

FileLineRuleLevelESLint 10.15.0oxlint 1.90.0oxlint 1.94.0
main.ts8no-permissive-corserrorfiredfiredfired
main.ts9require-validation-pipe-whitelisterrorfiredfiredfired
main.ts12no-unguarded-swaggerwarnfiredfiredfired
main.ts13no-hybrid-app-config-losserrorfiredfiredfired
users.controller.ts6, 11, 16require-guardserrorfired (3)fired (3)fired (3)
account.controller.ts9no-missing-validation-pipewarnfiredfiredfired
account.controller.ts14no-res-bypass-serializationwarnfiredfiredfired
auth.controller.ts5require-throttlerwarnfiredfiredfired
upload.controller.ts11require-upload-size-limitwarnfiredfiredfired
upload.controller.ts14no-unsafe-multer-filenameerrorfiredfiredfired
user.entity.ts8no-exposed-private-fieldswarnfiredfiredfired

Both CLIs exit with code 1 because the fixture contains errors. The oxlint run printed nothing on stderr; the plugin loaded without a flag or a workaround. In the oxlint output the rule shows up as nestjs-security(<rule>).

The 11 rules

Access control

  • require-guards: controllers and handlers with no @UseGuards.
  • require-throttler: no ThrottlerGuard or @Throttle on routes that look sensitive, such as login and verify.
  • no-permissive-cors: enableCors accepting any origin.
  • no-unguarded-swagger: SwaggerModule.setup() that runs in every environment, which publishes the API description to anonymous callers.

Input validation

Data exposure and uploads

Limits of this run

  • One small fixture, written to trigger the rules. It shows that each rule loads and fires on both engines. It says nothing about false positives or misses on a real codebase, and it is not a benchmark.
  • Same file, same output, by construction. The oxlint package re-exports the ESLint package, so matching output is expected. The check that mattered was that oxlint's jsPlugins loader accepts it, and it did on 1.90.0 and 1.94.0.
  • A guarded controller is treated as protected from rate limiting. In the fixture, account.controller.ts has a verifyEmail route under a class-level @UseGuards, and require-throttler did not report it; auth.controller.ts, with no guard on its login route, was reported. That is intended: a route that needs credentials is not a brute-force target, and the rule page says so.
  • A public login route is not reported by require-guards. auth.controller.ts has no guard and require-guards stayed silent on it, while it reported the three routes in users.controller.ts. That is intended: login, register, refresh, callback, webhook and similar entry points are exempt, because a caller cannot present a credential to the route that issues it. require-guards lists the names and the publicRoutes option replaces them.
  • Not run: ESLint 9, Vite+, the Nest CLI scaffold, .mts/.mjs sources, and any real application.
  • Type information is not needed. The ESLint config uses the TypeScript parser only to read decorators.

The source is at github.com/ofri-peretz/eslint; issues with a reproduction are welcome there.

Building secure JavaScript with Interlace? Star the repo to get new rules and CWE coverage as we ship them — or follow the AI-code-security benchmarks behind them.