eslint-plugin-vercel-ai-security
Vercel AI SDK security rules for generateText, streamText, and LLM tools
AI-Optimized Security
Every rule includes CWE, OWASP LLM Top 10, and CVSS metadata for AI assistants to provide precise, context-aware fixes.
Install
npm install -D eslint-plugin-vercel-ai-securityRules (19)
Browse all Vercel AI security rules with OWASP LLM mapping
Changelog
View version history and updates
Live from GitHub
This content is fetched directly from README.md on GitHub and cached for 1 hour.
β 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 Vercel AI SDK usage (prompt injection, data handling).
- 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
- To check out the guide, visit eslint.interlace.tools. π
npm install eslint-plugin-vercel-ai-security --save-devβοΈ Configuration Presets
| Preset | Description |
|---|---|
recommended | Balanced security (7 errors, 7 warnings) |
strict | Maximum security (17 errors, 2 warnings) |
minimal | Minimal config |
π Supported Libraries
π€ AI-Agent Optimized Messages
All rule messages follow a structured format optimized for AI coding assistants:
π CWE-74 OWASP:A03-Injection CVSS:9 | Unsafe Prompt | CRITICAL [SOC2,GDPR]
Fix: Validate input before use | https://owasp.org/...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.
π§ Supported AI SDK Functions
| Function | Full Coverage |
|---|---|
generateText | β All 19 rules |
streamText | β All 19 rules + abort signal |
generateObject | β All 19 rules |
streamObject | β All 19 rules + abort signal |
tool() helper | β Schema validation |
embed() / embeddings | β Embedding validation |
π Test Coverage
| Metric | Coverage |
|---|---|
| Rules | 19 |
| Tests | 200 |
| Lines | 98%+ |
| Functions | 100% |
π FAQ
What's the difference between this and generic AI security linters?
Generic linters guess at patterns. This plugin knows the exact Vercel AI SDK API.
Does this work with ESLint 9 Flat Config?
Yes! Designed specifically for ESLint Flat Config β works on ESLint 8 (with flat config), 9, and 10. See the ESLint Version Support Policy for the full matrix.
How do I suppress a rule for a specific line?
// eslint-disable-next-line vercel-ai-security/require-validated-prompt
await generateText({ prompt: internalPrompt });Why is ASI06 (Memory Corruption) not covered?
TypeScript/JavaScript are memory-safe languages. Memory corruption vulnerabilities (buffer overflows, use-after-free, etc.) are not possible in these environments.
π¦ Compatibility
See the ESLint Version Support Policy for the full matrix.
Rules
Legend
| Icon | Description |
|---|---|
| πΌ | 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. |
| Rule | CWE | OWASP | CVSS | Description | π§ | πΌ | β οΈ | π§ | π‘ | π« |
|---|---|---|---|---|---|---|---|---|---|---|
| no-dynamic-system-prompt | CWE-74 | This rule identifies code patterns where system prompts contain dynamic or user-controlled content | π’ | |||||||
| no-hardcoded-api-keys | CWE-798 | This rule identifies hardcoded API keys, tokens, and secrets in your codebase that are used with AI SDK proβ¦ | π’ | |||||||
| no-sensitive-in-prompt | CWE-200 | This rule identifies code patterns where sensitive data like passwords, API keys, tokens, or personally ideβ¦ | π’ | |||||||
| no-system-prompt-leak | CWE-200 | This rule identifies code patterns where system prompts or AI instructions are returned in API responses, lβ¦ | π’ | |||||||
| no-training-data-exposure | CWE-359 | This rule identifies code patterns where user data might be sent to LLM training endpoints or when trainingβ¦ | π’ | |||||||
| no-unsafe-output-handling | CWE-94 | This rule identifies code patterns where AI-generated output is passed directly to dangerous functions thatβ¦ | π’ | |||||||
| require-abort-signal | CWE-404 | This rule identifies streaming AI SDK calls (streamText, streamObject) that don't include an AbortSignal foβ¦ | π’ | |||||||
| require-audit-logging | CWE-778 | This rule identifies AI SDK calls that aren't preceded by logging statements | π’ | |||||||
| require-embedding-validation | CWE-20 | This rule identifies code patterns where embeddings are stored in vector databases without validation. | π’ | |||||||
| require-error-handling | CWE-755 | This rule identifies AI SDK calls that aren't wrapped in try-catch blocks | π’ | |||||||
| require-max-steps | CWE-834 | This rule identifies AI SDK calls that use tools but don't specify a step limit (maxSteps or stopWhen) | π’ | |||||||
| require-max-tokens | CWE-770 | This rule identifies AI SDK calls that don't specify a token limit (maxTokens or maxOutputTokens) | π’ | |||||||
| require-output-filtering | CWE-200 | This rule identifies tool execute functions that return raw data from data sources (databases, APIs, file sβ¦ | π’ | |||||||
| require-output-validation | CWE-707 | This rule identifies code patterns where AI-generated output is displayed to users without validation or faβ¦ | π’ | |||||||
| require-rag-content-validation | CWE-74 | This rule identifies code patterns where content retrieved from vector stores or document retrieval systemsβ¦ | π’ | |||||||
| require-request-timeout | CWE-400 | This rule identifies AI SDK calls that don't have timeout or abort signal configuration. | π’ | |||||||
| require-tool-confirmation | CWE-862 | This rule identifies destructive tools (delete, transfer, execute, etc.) that don't require human confirmatβ¦ | π’ | |||||||
| require-tool-schema | CWE-20 | Get weather | π’ | |||||||
| require-validated-prompt | CWE-74 | This rule identifies code patterns where user-controlled input is passed directly to AI prompts without valβ¦ | π’ |
π Related ESLint Plugins
Part of the Interlace ESLint ecosystem β AI-native rules with LLM-optimized error messages:
Security
Code quality
| Plugin | Downloads | Description |
|---|---|---|
eslint-plugin-conventions | Team-specific habits and styles. | |
eslint-plugin-import-next | Fast cycle + import-graph analysis. | |
eslint-plugin-maintainability | Cognitive load and clean-code patterns. | |
eslint-plugin-modernization | ESNext migration + syntax evolution. | |
eslint-plugin-modularity | Structural integrity and DDD patterns. | |
eslint-plugin-operability | Production readiness and resource health. | |
eslint-plugin-react-a11y | React accessibility / WCAG. | |
eslint-plugin-react-features | React best practices and optimization. | |
eslint-plugin-reliability | Runtime 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.
π 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.