Skip to main content
interlace
Plugin: node-security

eslint-plugin-node-security

Node.js security rules for fs, child_process, vm, and crypto modules

AI-Optimized Security

Every rule includes CWE, OWASP, and CVSS metadata for AI assistants to provide precise, context-aware fixes.

Install

npm install -D eslint-plugin-node-security

Live from GitHub

This content is fetched directly from README.md on GitHub and cached for 1 hour.

Live README from GitHubfrom eslint-plugin-node-security/README.md, cached for 1 hour.Edit on GitHub

⭐ If this plugin caught a real bug for you, star the repo β€” it's the signal that keeps these rules maintained.

Description

This plugin provides Security rules for Node.js core modules (fs, child_process, crypto, etc).

  • Why β€” a linter nobody reads protects nothing. We would rather miss a finding than spend your attention on one that was never real.
  • How β€” evidence, not names. A rule fires on what the code does, resolved through the AST and ESLint's own scope analysis.
  • What β€” every finding carries its fix, in prose for a human and as structured JSON for an agent. Security rules add a CWE mapping and, where assigned, a CVSS score.

That trade costs recall, and we measure it: methodology Β· results Β· a false positive is a bug.

Getting Started

npm install eslint-plugin-node-security --save-dev

βš™οΈ Configuration Presets

PresetDescription
recommendedBalanced security for most Node.js projects
strictMaximum security enforcement (all rules as errors)
fs-securityFocus on file system vulnerabilities (CWE-22, CWE-73)
cryptoCryptographic security rules only

πŸ’‘ What You Get

  • 31 security rules covering Node.js core module vulnerabilities
  • Command Injection Detection for child_process.exec, spawn, and execFile
  • Path Traversal Prevention for fs module operations
  • TOCTOU Race Condition Detection for file system operations
  • Cryptographic Security for weak algorithms and key management
  • LLM-optimized messages with CWE references and fix guidance

πŸ“¦ Compatibility

PackageVersion
ESLint^8.40.0 || ^9.0.0 || ^10.0.0
Node.js>=18.0.0

See the ESLint Version Support Policy β€” current ecosystem share data, the 20% gate, and the forward-looking exception that covers v10.

Rules

Legend

IconDescription
πŸ’ΌRecommended: Included in the recommended preset.
⚠️Warns: Set to warn in recommended preset.
πŸ”§Auto-fixable: Automatically fixable by the --fix CLI option.
πŸ’‘Suggestions: Providing code suggestions in IDE.
🚫Deprecated: This rule is deprecated.
🟒Type-unaware: AST-only, runs in oxlint JS-plugin tier.
🟑Type-aware (refining): pure-AST primary path; types refine precision.
🟠Type-aware (graceful): requires TS program; silent without it.
RuleCWEOWASPCVSSDescriptionπŸ§ πŸ’Όβš οΈπŸ”§πŸ’‘πŸš«
detect-child-processCWE-78Detects instances of childprocess & non-literal exec() calls that may allow command injectionπŸŸ’πŸ’Ό
detect-eval-with-expressionCWE-95A03:2021Detects eval(variable) which can allow an attacker to run arbitrary code inside your processπŸŸ’πŸ’Ό
detect-non-literal-fs-filenameCWE-22Detects variable in filename argument of fs calls, which might allow an attacker to access anything on yourβ€¦πŸŸ’βš οΈ
detect-suspicious-dependenciesCWE-506This rule detects package imports that look like typosquatting attempts on popular npm packages🟒⚠️
lock-fileCWE-829CWE: CWE-829🟒
no-arbitrary-file-accessCWE-22A01:2021Prevents file system access with unsanitized user input to protect against path traversal attacks.πŸŸ’πŸ’Ό
no-buffer-overreadCWE-126Detects buffer access beyond bounds🟒⚠️
no-cryptojsCWE-1104A06:2021Disallow deprecated crypto-js library (use native crypto instead)πŸŸ’πŸ’Ό
no-cryptojs-weak-randomCWE-338A02:2021Disallow crypto-js WordArray.random() (CVE-2020-36732)🟒
no-data-in-temp-storageCWE-312Temporary directories (/tmp, /var/tmp, temp/) are often world-readable or persist longer than expectedπŸŸ’πŸ’Ό
no-deprecated-bufferCWE-676Disallow the deprecated new Buffer() constructor and Buffer() factory call.πŸŸ’πŸ’ΌπŸ’‘
no-deprecated-cipher-methodCWE-327A02:2021Disallow deprecated crypto.createCipher/createDecipher methods🟒
no-dynamic-algorithm-selectionCWE-327A02:2021Disallow dynamic algorithm names in Node.js crypto functions (CWE-327)πŸŸ’πŸ’Ό
no-dynamic-command-stringCWE-77A03:2021Detects dynamically assembled command strings handed to a shell flag (bash -c) or to a command-runner thatβ€¦πŸŸ’πŸ’Ό
no-dynamic-dependency-loadingCWE-1104This rule detects dynamically constructed paths in require() and import() statements🟒
no-dynamic-requireForbid require() calls with non-literal arguments🟒
no-ecb-modeCWE-327A02:2021Disallow ECB encryption mode (use GCM or CBC instead)πŸŸ’πŸ’Ό
no-env-injectionCWE-99A03:2021Detects writes to process.env under a key the caller controls, which can overwrite PATH, NODE_OPTIONS or LDβ€¦πŸŸ’πŸ’Ό
no-insecure-http-parserCWE-444A03:2021Disallow insecureHTTPParser true on Node HTTP servers and clientsπŸŸ’πŸ’Ό
no-insecure-key-derivationCWE-916A02:2021Disallow PBKDF2 with insufficient iterations (< 100,000)🟒
no-insecure-rsa-paddingCWE-327A02:2021Disallow RSA PKCS#1 v1.5 padding (CVE-2023-46809 Marvin Attack)🟒
no-math-random-cryptoCWE-338A02:2021Disallow Math.random() for cryptographic purposes (tokens, keys, secrets, salts, IVs)πŸŸ’πŸ’Ό
no-self-signed-certsCWE-295A07:2021Disallow rejectUnauthorized false in TLS optionsπŸŸ’πŸ’Ό
no-sha1-hashCWE-327A02:2021Disallow sha1() from crypto-hash package (use sha256 or sha512)🟒
no-shell-injectionCWE-78A03:2021Disallow string concatenation or template expressions in shell command arguments (CWE-78)πŸŸ’πŸ’Ό
no-ssrfCWE-918A10:2021Detect HTTP requests with user-controlled URLs (server-side request forgery).πŸŸ’βš οΈπŸ’‘
no-static-ivCWE-329A02:2021Disallow static or hardcoded initialization vectors (IVs)πŸŸ’πŸ’Ό
no-timing-unsafe-compareCWE-208A02:2021Disallow timing-unsafe comparison of secrets🟒⚠️
no-toctou-vulnerabilityCWE-367A01:2021Detects Time-of-Check-Time-of-Use (TOCTOU) race condition vulnerabilities in file system operations.πŸŸ’πŸ’Ό
no-unbounded-decompressionCWE-409A05:2021Require a maxOutputLength ceiling on zlib one-shot decompressionπŸŸ’πŸ’Ό
no-unsafe-buffer-allocCWE-908A01:2021Disallow Buffer.allocUnsafe() and Buffer.allocUnsafeSlow(), which return uninitialized memory.πŸŸ’βš οΈπŸ’‘
no-unsafe-dynamic-requireCWE-494Disallows dynamic require() calls with non-literal arguments that could lead to security vulnerabilitiesπŸŸ’πŸ’Ό
no-weak-cipher-algorithmCWE-327A02:2021Disallow weak cipher algorithms (DES, 3DES, RC4, Blowfish, RC2, IDEA)πŸŸ’πŸ’Ό
no-weak-dh-parametersCWE-326A02:2021Disallow Diffie-Hellman and ECDH parameters below a safe strengthπŸŸ’πŸ’Ό
no-weak-hash-algorithmCWE-327A02:2021Disallow weak hash algorithms (MD5, MD4, SHA-1, RIPEMD)πŸŸ’πŸ’Ό
no-zip-slipCWE-22Detects zip slip/archive extraction vulnerabilitiesπŸŸ’πŸ’Ό
prefer-native-cryptoCWE-1104A06:2021Prefer native crypto over third-party libraries🟒
require-aead-tag-verificationCWE-327A02:2021Require AEAD decryption to verify the authentication tag (setAuthTag + final)πŸŸ’πŸ’Ό
require-dependency-integrityCWE-494CWE: CWE-494πŸŸ’πŸ’Ό
require-secure-credential-storageCWE-312This rule detects a credential written to localStorage, sessionStorage, AsyncStorage or process.env withoutβ€¦πŸŸ’
require-secure-deletionCWE-459CWE: CWE-459🟒
require-storage-encryptionCWE-312CWE: CWE-312🟒
require-stream-error-handlerCWE-248A04:2021Require an error listener on streams passed to pipe, which does not forward errorsπŸŸ’πŸ’Ό

Part of the Interlace ESLint ecosystem β€” AI-native rules with LLM-optimized error messages:

Security

PluginDownloadsDescription
eslint-plugin-anthropic-securitydownloadsAnthropic SDK security.
eslint-plugin-browser-securitydownloadsXSS, DOM security.
eslint-plugin-drizzle-securitydownloadsDrizzle security.
eslint-plugin-express-securitydownloadsExpress middleware hardening.
eslint-plugin-gemini-securitydownloadsGoogle Gemini SDK security.
eslint-plugin-jwt-securitydownloadsToken security.
eslint-plugin-knex-securitydownloadsKnex security.
eslint-plugin-lambda-securitydownloadsAWS Lambda hardening.
eslint-plugin-mcp-sdk-securitydownloadsMCP SDK security.
eslint-plugin-mongodb-securitydownloadsMongoDB injection.
eslint-plugin-mysql-securitydownloadsMySQL security.
eslint-plugin-nestjs-securitydownloadsNestJS framework hardening.
eslint-plugin-openai-securitydownloadsOpenAI SDK security.
eslint-plugin-postgresql-securitydownloadsPostgreSQL security.
eslint-plugin-prisma-securitydownloadsPrisma security.
eslint-plugin-secure-codingdownloadsInjection prevention.
eslint-plugin-sequelize-securitydownloadsSequelize ORM security.
eslint-plugin-sqlite-securitydownloadsSQLite security.
eslint-plugin-supabase-securitydownloadsSupabase security.
eslint-plugin-typeorm-securitydownloadsTypeORM security.
eslint-plugin-vercel-ai-securitydownloadsAI SDK security.

Code quality

PluginDownloadsDescription
eslint-plugin-conventionsdownloadsTeam-specific habits and styles.
eslint-plugin-import-nextdownloadsFast cycle + import-graph analysis.
eslint-plugin-maintainabilitydownloadsCognitive load and clean-code patterns.
eslint-plugin-modernizationdownloadsESNext migration + syntax evolution.
eslint-plugin-modularitydownloadsStructural integrity and DDD patterns.
eslint-plugin-operabilitydownloadsProduction readiness and resource health.
eslint-plugin-react-a11ydownloadsReact accessibility / WCAG.
eslint-plugin-react-featuresdownloadsReact best practices and optimization.
eslint-plugin-reliabilitydownloadsRuntime stability and error safety.

⭐ Support & follow

If this plugin caught a real bug for you, star the repo β€” stars are the signal that keeps the Interlace ESLint ecosystem maintained β€” and follow the writeups on Dev.to for the benchmarks and security research behind these rules.

GitHub stars

πŸ“„ License

MIT Β© Ofri Peretz

View README.md on GitHub β†’

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.