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.
| Component | Version |
|---|---|
| Node.js | 24.12.0 |
@nestjs/common, @nestjs/core | 12.5.1 |
@nestjs/swagger | 12.1.2 |
@nestjs/throttler | 6.8.0 |
typeorm | installed for the fixture |
ESLint, typescript-eslint | 10.15.0, 8.73.0 |
| oxlint | 1.90.0, and 1.94.0 (latest at the time) |
eslint-plugin-nestjs-security | 4.2.1 (local build) |
oxlint-plugin-nestjs-security | 4.2.1 (local build) |
Install
npm install -D eslint typescript-eslint eslint-plugin-nestjs-securityimport 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.
| File | Line | Rule | Level | ESLint 10.15.0 | oxlint 1.90.0 | oxlint 1.94.0 |
|---|---|---|---|---|---|---|
main.ts | 8 | no-permissive-cors | error | fired | fired | fired |
main.ts | 9 | require-validation-pipe-whitelist | error | fired | fired | fired |
main.ts | 12 | no-unguarded-swagger | warn | fired | fired | fired |
main.ts | 13 | no-hybrid-app-config-loss | error | fired | fired | fired |
users.controller.ts | 6, 11, 16 | require-guards | error | fired (3) | fired (3) | fired (3) |
account.controller.ts | 9 | no-missing-validation-pipe | warn | fired | fired | fired |
account.controller.ts | 14 | no-res-bypass-serialization | warn | fired | fired | fired |
auth.controller.ts | 5 | require-throttler | warn | fired | fired | fired |
upload.controller.ts | 11 | require-upload-size-limit | warn | fired | fired | fired |
upload.controller.ts | 14 | no-unsafe-multer-filename | error | fired | fired | fired |
user.entity.ts | 8 | no-exposed-private-fields | warn | fired | fired | fired |
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: noThrottlerGuardor@Throttleon routes that look sensitive, such as login and verify.no-permissive-cors:enableCorsaccepting any origin.no-unguarded-swagger:SwaggerModule.setup()that runs in every environment, which publishes the API description to anonymous callers.
Input validation
no-missing-validation-pipe: a@Body()that nothing validates.require-validation-pipe-whitelist:new ValidationPipe()withoutwhitelist: true.no-hybrid-app-config-loss:connectMicroservice()withoutinheritAppConfig, so global pipes and guards do not apply.
Data exposure and uploads
no-exposed-private-fields: password and secret fields on entities or DTOs.no-res-bypass-serialization:@Res()handlers that write objects pastClassSerializerInterceptor.no-unsafe-multer-filename: storing an upload under the client's filename.require-upload-size-limit: multer interceptors with nolimits.fileSize.
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
jsPluginsloader 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.tshas averifyEmailroute under a class-level@UseGuards, andrequire-throttlerdid not report it;auth.controller.ts, with no guard on itsloginroute, was reported. That is intended: a route that needs credentials is not a brute-force target, and the rule page says so. - A public
loginroute is not reported byrequire-guards.auth.controller.tshas no guard andrequire-guardsstayed silent on it, while it reported the three routes inusers.controller.ts. That is intended:login,register,refresh,callback,webhookand similar entry points are exempt, because a caller cannot present a credential to the route that issues it.require-guardslists the names and thepublicRoutesoption replaces them. - Not run: ESLint 9, Vite+, the Nest CLI scaffold,
.mts/.mjssources, and any real application. - Type information is not needed. The ESLint config uses the TypeScript parser only to read decorators.
Related
eslint-plugin-nestjs-securitylists every rule with its CWE and OWASP mapping.- Why oxlint explains the alias packages and what they install.
- Security plugins in one flat config shows how to combine several security plugins without duplicate reports.
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.
eslint-plugin-security alternative: measured on NodeGoat, DVNA and Juice Shop
eslint-plugin-security 4.2.1 vs our plugins on 72 documented flaws in NodeGoat, DVNA and Juice Shop, with Wilson intervals, where it wins and every caveat.
Upgrade to ESLint 10 with eslint-plugin-import
eslint-plugin-import has no ESLint 10 release (peer ^9), so installs fail with ERESOLVE. Swap it in one line with eslint-plugin-import-next, or use import-x.