JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 50
  • Score
    100M100P100Q78088F
  • License MIT

Security-focused ESLint plugin for AWS Lambda and Middy applications. Detects insecure API Gateway responses, missing security headers, CORS misconfigurations, input validation issues, and more.

Package Exports

  • eslint-plugin-lambda-security
  • eslint-plugin-lambda-security/types

Readme

ESLint Interlace Logo

Security best practices for AWS Lambda functions (IAM, timeouts, environment).

NPM Version NPM Downloads Package License Codecov Since Dec 2025

Description

This plugin secures your AWS Lambda functions by enforcing best practices related to IAM permissions, timeout configurations, and environment variable management. It proactively detects vulnerabilities such as over-permissive policies and insecure logging practices, helping you adhere to the Principle of Least Privilege. Implementing these checks ensures that your serverless architecture remains resilient and compliant with strict security standards.

Philosophy

Interlace fosters strength through integration. Instead of stacking isolated rules, we interlace security directly into your workflow to create a resilient fabric of code. We believe tools should guide rather than gatekeep, providing educational feedback that strengthens the developer with every interaction.

Getting Started

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

๐Ÿ’ก What you get

  • Serverless-focused coverage: 5 rules targeting Lambda-specific vulnerabilities (credentials, CORS, secrets, logging).
  • LLM-optimized & MCP-ready: Structured 2-line messages with CWE + OWASP + CVSS + concrete fixes so humans and AI auto-fixers stay aligned.
  • Standards aligned: OWASP Serverless Top 10, CWE tagging, CVSS scoring in every finding for compliance mapping.
  • Tiered presets: recommended, strict for fast policy rollout.
  • Framework-aware: Detects Middy middleware, API Gateway response patterns, AWS SDK v3 clients.
  • Low false positive rate: Context-aware detection with production heuristics.

Every security rule produces a structured 2-line error message:

src/handlers/api.ts
  18:5   error  ๐Ÿ”’ CWE-798 OWASP:SAS-2 CVSS:9.8 | Hardcoded AWS credentials detected | CRITICAL [SOC2,PCI-DSS]
                    Fix: Use credential provider chain or Lambda execution role | https://owasp.org/...

Each message includes:

  • ๐Ÿ”’ CWE reference - vulnerability classification
  • ๐Ÿ“‹ OWASP category - Serverless Top 10 mapping
  • ๐Ÿ“Š CVSS score - severity rating (0.0-10.0)
  • ๐Ÿข Compliance tags - affected frameworks (SOC2, PCI-DSS, HIPAA)
  • โœ… Fix instruction - exact code to write
  • ๐Ÿ“š Documentation link - learn more

โš™๏ธ Configuration Presets

Preset Description
recommended Balanced security for Lambda projects (critical as error, others warn)
strict Maximum security enforcement (all rules as errors)

๐Ÿ“š Supported Libraries

Library npm Downloads Detection
aws-lambda npm downloads IAM, Logging, Timeouts
@aws-sdk/client-lambda npm downloads Credential Safety
middy npm downloads Middleware Security

โš™๏ธ Configuration Options

All rules accept these common options:

{
  rules: {
    'lambda-security/no-hardcoded-credentials-sdk': ['error', {
      allowInTests: true // Default: true - skip test files
    }],
    'lambda-security/no-secrets-in-env': ['error', {
      allowInTests: true,
      additionalPatterns: ['CUSTOM_SECRET_*'] // Additional patterns to detect
    }]
  }
}

๐Ÿข Enterprise Integration Example

// eslint.config.js
import lambdaSecurity from 'eslint-plugin-lambda-security';

export default [
  // Baseline for all Lambda functions
  lambdaSecurity.configs.recommended,

  // Strict mode for payment/auth handlers
  {
    files: ['functions/payments/**', 'functions/auth/**'],
    ...lambdaSecurity.configs.strict,
  },
];

Rules

Legend

Icon Description
๐Ÿ’ผ Recommended: Included in the recommended preset.
โš ๏ธ Warns: Set towarn in recommended preset.
๐Ÿ”ง Auto-fixable: Automatically fixable by the --fix CLI option.
๐Ÿ’ก Suggestions: Providing code suggestions in IDE.
๐Ÿšซ Deprecated: This rule is deprecated.
Rule CWE OWASP CVSS Description ๐Ÿ’ผ โš ๏ธ ๐Ÿ”ง ๐Ÿ’ก ๐Ÿšซ
no-hardcoded-credentials-sdk CWE-798 SAS-02 9.8 no-hardcoded-credentials-sdk ๐Ÿ’ผ
no-permissive-cors-response CWE-942 SAS-04 9.1 no-permissive-cors-response ๐Ÿ’ผ ๐Ÿ”ง
no-permissive-cors-middy CWE-942 SAS-04 9.1 no-permissive-cors-middy ๐Ÿ’ผ
no-secrets-in-env CWE-522 SAS-03 9.8 no-secrets-in-env ๐Ÿ’ผ
no-env-logging CWE-532 SAS-03 7.5 no-env-logging ๐Ÿ’ผ โš ๏ธ
no-error-swallowing CWE-391 SAS-06 7.5 no-error-swallowing ๐Ÿ’ผ โš ๏ธ
require-timeout-handling CWE-703 SAS-07 7.5 require-timeout-handling ๐Ÿ’ผ โš ๏ธ
no-unbounded-batch-processing CWE-400 SAS-07 7.5 no-unbounded-batch-processing ๐Ÿ’ผ โš ๏ธ
no-unvalidated-event-body CWE-20 SAS-01 7.5 no-unvalidated-event-body ๐Ÿ’ผ โš ๏ธ
no-missing-authorization-check CWE-862 SAS-05 7.5 no-missing-authorization-check ๐Ÿ’ผ โš ๏ธ
no-exposed-error-details CWE-209 SAS-09 7.5 no-exposed-error-details ๐Ÿ’ผ โš ๏ธ
no-user-controlled-requests CWE-918 SAS-08 9.8 no-user-controlled-requests ๐Ÿ’ผ
no-overly-permissive-iam-policy CWE-732 SAS-05 9.8 no-overly-permissive-iam-policy ๐Ÿ’ผ

AI-Optimized Messages

This plugin is optimized for ESLint's Model Context Protocol (MCP), enabling AI assistants like Cursor, GitHub Copilot, and Claude to:

  • Understand the exact vulnerability type via CWE references
  • Apply the correct fix using structured guidance
  • Provide educational context to developers
src/handlers/api.ts
  18:5   error  ๐Ÿ”’ CWE-798 OWASP:SAS-2 CVSS:9.8 | Hardcoded AWS credentials detected | CRITICAL [SOC2,PCI-DSS]
                    Fix: Use credential provider chain or Lambda execution role | https://owasp.org/...
// .cursor/mcp.json
{
  "mcpServers": {
    "eslint": {
      "command": "npx",
      "args": ["@eslint/mcp@latest"]
    }
  }
}

By providing this structured context (CWE, OWASP, Fix), we enable AI tools to reason about the security flaw rather than hallucinating. This allows Copilot/Cursor to suggest the exact correct fix immediately.


๐Ÿ”’ Privacy

This plugin runs 100% locally. No data ever leaves your machine.

Part of the Interlace ESLint Ecosystem โ€” AI-native security plugins with LLM-optimized error messages:

Plugin Downloads Description
eslint-plugin-secure-coding downloads General security rules & OWASP guidelines.
eslint-plugin-pg downloads PostgreSQL security & best practices.
eslint-plugin-crypto downloads NodeJS Cryptography security rules.
eslint-plugin-jwt downloads JWT security & best practices.
eslint-plugin-browser-security downloads Browser-specific security & XSS prevention.
eslint-plugin-express-security downloads Express.js security hardening rules.
eslint-plugin-lambda-security downloads AWS Lambda security best practices.
eslint-plugin-nestjs-security downloads NestJS security rules & patterns.
eslint-plugin-mongodb-security downloads MongoDB security best practices.
eslint-plugin-vercel-ai-security downloads Vercel AI SDK security hardening.
eslint-plugin-import-next downloads Next-gen import sorting & architecture.

๐Ÿ“„ License

MIT ยฉ Ofri Peretz

ESLint Interlace Plugin