Skip to main content
interlace
Plugin: secure-coding

eslint-plugin-secure-coding

General secure coding practices and OWASP compliance for JavaScript/TypeScript

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-secure-coding

Live from GitHub

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

Live README from GitHubfrom eslint-plugin-secure-coding/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 General secure coding practices and OWASP compliance for JavaScript/TypeScript.

  • 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-secure-coding --save-dev

Add to your eslint.config.mjs β€” one line activates 16 security rules:

import securePlugin from 'eslint-plugin-secure-coding';

export default [
  // Balanced: catches critical issues as errors, lower-confidence rules as warnings
  ...securePlugin.configs.recommended,

  // Zero-tolerance: same 16 rules, all promoted to error (good for CI gates)
  // ...securePlugin.configs['recommended-strict'],
];

Or if you use a legacy .eslintrc.json:

{
  "extends": ["plugin:secure-coding/recommended"]
}

Using recommended already? Extend your coverage with domain-specific plugins: eslint-plugin-node-security (crypto, eval, buffer) Β· eslint-plugin-jwt-security (JWT auth) Β· eslint-plugin-express-security (Express middleware)


Benchmarks vs competitors (CWE-798 ground truth)

no-hardcoded-credentials is part of the ILB-Flagship benchmark suite. On the labeled CWE-798 fixture set (Juliet-style: 2 vulnerable + 2 safe files, ground-truthed):

RulePrecisionRecallF1
secure-coding/no-hardcoded-credentials (ours)100%100%1.00
eslint-plugin-no-secrets/no-secrets100%50%0.67

The competitor's entropy-only detection catches the high-entropy API-key shape but misses the 15-character literal password assigned to password:. Our context-gated detection (structural patterns + credential-named-variable check + context-positive path) catches both for the right reasons.

On real OSS (vercel/ai), the competitor reports ~380 more findings than us. Those 380 are not catches we missed β€” they're entropy false-positives on TypeScript type literals ('experimental_onLanguageModelCallStart'), error class names ('AI_ToolCallNotFoundForApprovalError'), and documentation URLs. Sampling confirmed zero are actual credentials. The corpus number is the right one to weigh; the OSS finding-count is a noise metric.

βš™οΈ Configuration Presets

PresetDescription
recommended16 core rules β€” critical issues as error, lower-confidence as warn
recommended-strictSame 16 rules as recommended, all promoted to error β€” for CI gates
strictAll rules as error β€” maximum coverage including experimental rules
owasp-top-10OWASP Top 10 Web 2021 compliance focused
owasp-mobile-top-10OWASP Mobile Top 10 2024 compliance focused

πŸ“¦ 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-non-literal-regexpCWE-400Detects RegExp(variable), which might allow an attacker to DOS your server with a long-running regular exprβ€¦πŸŸ’
detect-object-injectionCWE-915Detects variable[key] as a left- or right-hand assignment operand (prototype pollution)🟑
detect-weak-password-validationCWE-521A07:2021Detects weak password length requirements (less than 8 characters) in validation code.🟒
no-bidi-charactersCWE-1007Disallows Unicode bidirectional control characters, which let source render differently than it compiles (Tβ€¦πŸŸ’
no-directive-injectionCWE-94Detects directive injection vulnerabilities in template systems🟒
no-electron-security-issuesCWE-16Detects Electron security vulnerabilities and insecure configurations🟒
no-fail-open-authCWE-636A10:2025Detects authentication and authorization checks whose catch block fails openπŸŸ’πŸ’Ό
no-format-string-injectionCWE-134Detects format string injection vulnerabilities🟒
no-graphql-injectionCWE-943Detects GraphQL injection vulnerabilities and DoS attacks🟒⚠️
no-hardcoded-credentialsCWE-798Detects hardcoded passwords, API keys, tokens, and other sensitive credentials in source codeπŸŸ’πŸ’Ό
no-hardcoded-session-tokensCWE-798This rule detects hardcoded JWT tokens (starting with eyJ), Bearer tokens, and session identifiers🟒
no-homoglyph-identifiersCWE-1007A08:2021Detects homoglyph identifiers and invisible characters that hide what the code actually doesπŸŸ’πŸ’Ό
no-improper-sanitizationCWE-116Detects improper sanitization of user inputπŸŸ’πŸ’Ό
no-improper-type-validationCWE-1287Detects improper type validation in user input handling🟒
no-insecure-comparisonCWE-697Detects insecure comparison operators (==, !=) that can lead to type coercion vulnerabilities🟒
no-ldap-injectionCWE-90Detects LDAP injection vulnerabilitiesπŸŸ’πŸ’Ό
no-log-injectionCWE-117A09:2021Detects request data concatenated into a log message, which lets an attacker forge log recordsπŸŸ’πŸ’Ό
no-missing-authenticationCWE-287CWE: CWE-287🟒
no-pii-in-logsCWE-359Prevent personally identifiable information (PII) β€” emails, SSNs, credit cards, phone numbers β€” from reachiβ€¦πŸŸ’πŸ’‘
no-privilege-escalationCWE-269Detects potential privilege escalation vulnerabilities where user input is used to assign roles or permissiβ€¦πŸŸ’βš οΈ
no-redos-vulnerable-regexCWE-400ESLint Rule: no-redos-vulnerable-regexπŸŸ’πŸ’Ό
no-sensitive-data-exposureCWE-532ESLint Rule: no-sensitive-data-exposure🟒⚠️
no-sql-injectionCWE-89A03:2021Detects SQL statements built from attacker-controlled input in files that import no SQL driverπŸŸ’πŸ’Ό
no-template-injectionCWE-94A03:2021Disallow dynamic strings as template arguments to server-side template engines (CWE-94)πŸŸ’πŸ’Ό
no-unchecked-loop-conditionCWE-400Detects unchecked loop conditions that could cause DoS🟒
no-unlimited-resource-allocationCWE-770Detects unlimited resource allocation that could cause DoS🟒⚠️
no-unsafe-deserializationCWE-502Detects unsafe deserialization of untrusted data🟒⚠️
no-unsafe-regex-constructionCWE-400ESLint Rule: no-unsafe-regex-construction with LLM-optimized suggestions and auto-fix capabilitiesπŸŸ’πŸ’Ό
no-weak-password-recoveryCWE-640ESLint Rule: no-weak-password-recovery with LLM-optimized suggestions and auto-fix capabilities🟒⚠️
no-xpath-injectionCWE-643Detects XPath injection vulnerabilitiesπŸŸ’πŸ’Ό
no-xxe-injectionCWE-611Detects XML External Entity (XXE) injection vulnerabilitiesπŸŸ’πŸ’Ό
require-backend-authorizationCWE-602CWE: CWE-602🟒
require-secure-defaultsCWE-1188CWE: CWE-1188🟒

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-node-securitydownloadsServer-side patterns.
eslint-plugin-openai-securitydownloadsOpenAI SDK security.
eslint-plugin-postgresql-securitydownloadsPostgreSQL security.
eslint-plugin-prisma-securitydownloadsPrisma security.
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.