eslint-plugin-crypto
v2.2.3
Published
Security-focused ESLint plugin with 24 AI-parseable rules for cryptographic best practices. Detects weak algorithms, insecure key handling, CVE-specific vulnerabilities, and deprecated crypto patterns.
Downloads
88
Maintainers
Readme
Description
This plugin provides Cryptographic security rules enforcing best practices and modern standards (Node.js crypto). By using this plugin, you can proactively identify and mitigate security risks across your entire codebase.
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
- To check out the guide, visit eslint.interlace.tools. 📚
- 要查看中文 指南, 请访问 eslint.interlace.tools. 📚
- 가이드 문서는 eslint.interlace.tools에서 확인하실 수 있습니다. 📚
- ガイドは eslint.interlace.toolsでご確認ください。 📚
- Para ver la guía, visita eslint.interlace.tools. 📚
- للاطلاع على الدليل، قم بزيارة eslint.interlace.tools. 📚
npm install eslint-plugin-crypto --save-dev💡 What You Get
- 24 security rules covering cryptographic best practices
- CVE detection for CVE-2023-46809, CVE-2020-36732, CVE-2023-46233
- OWASP Top 10 coverage for cryptographic vulnerabilities
- LLM-optimized messages with CWE references and fix guidance
- Package support for crypto-hash, crypto-random-string, crypto-js
Features
- 🔐 24 Rules covering crypto best practices
- 🎯 CVE Detection (CVE-2023-46809, CVE-2020-36732, CVE-2023-46233)
- 🤖 AI-Optimized messages with CWE references
- ⚡ Auto-Fix suggestions where safe
- 📦 Package Support for crypto-hash, crypto-random-string, crypto-js
⚙️ Configuration Presets
| Preset | Description |
| :------------------- | :------------------------------------------- |
| recommended | Balanced security defaults for most projects |
| strict | Strict preset - all rules as errors |
| cryptojs-migration | For teams migrating from crypto-js |
| nodejs-only | Only Node.js crypto rules |
| cve-focused | Rules targeting specific CVEs |
📚 Supported Libraries
| Library | npm | Downloads | Detection |
| ------------------ | ------------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------- | --------------------------------- |
| crypto (Node.js) | | - | Weak Algo, Key Length, Randomness |
|
crypto-js | |
| Legacy patterns, Weak PRNG |
Examples
❌ Bad
// CVE-2023-46809: Marvin Attack
crypto.privateDecrypt({ key, padding: crypto.constants.RSA_PKCS1_PADDING }, buffer);
// CWE-338: Weak random
const token = Math.random().toString(36);
// CWE-327: ECB mode leaks patterns
crypto.createCipheriv('aes-256-ecb', key, iv);
// CWE-208: Timing attack
if (userToken === storedToken) { ... }✅ Good
// Use OAEP padding
crypto.privateDecrypt({ key, padding: crypto.constants.RSA_PKCS1_OAEP_PADDING }, buffer);
// Secure random
const token = crypto.randomBytes(32).toString('hex');
// GCM provides authentication
crypto.createCipheriv('aes-256-gcm', key, iv);
// Constant-time comparison
if (crypto.timingSafeEqual(Buffer.from(userToken), Buffer.from(storedToken))) { ... }Peer Dependencies (Optional)
{
"crypto-hash": ">=3.0.0",
"crypto-random-string": ">=4.0.0",
"crypto-js": ">=4.0.0"
}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-crypto-key | CWE-321 | A02:2025 | 9.8 | Enforce no hardcoded crypto key | 💼 | | | 💡 | | | no-key-reuse | CWE-323 | A02:2025 | 7.5 | Enforce no key reuse | 💼 | ⚠️ | | 💡 | | | no-math-random-crypto | CWE-338 | A07:2025 | 5.3 | Enforce no math random crypto | 💼 | | | 💡 | | | no-numeric-only-tokens | CWE-330 | A07:2025 | 5.3 | Enforce no numeric only tokens | 💼 | ⚠️ | | 💡 | | | no-predictable-salt | CWE-331 | A07:2025 | 7.5 | Enforce no predictable salt | 💼 | | | 💡 | | | no-web-crypto-export | CWE-321 | A02:2025 | 5.0 | Enforce no web crypto export | 💼 | ⚠️ | | 💡 | | | require-authenticated-encryption | CWE-327 | A04:2025 | 6.5 | Enforce require authenticated encryption | 💼 | ⚠️ | | 💡 | | | require-key-length | CWE-326 | A02:2025 | 7.5 | Enforce require key length | 💼 | ⚠️ | | 💡 | | | require-random-iv | CWE-329 | A02:2025 | 7.5 | Enforce require random iv | 💼 | ⚠️ | | 💡 | | | require-secure-pbkdf2-digest | CWE-916 | A02:2025 | 9.1 | Enforce require secure pbkdf2 digest | 💼 | | | 💡 | | | require-sufficient-length | CWE-326 | A02:2025 | 7.5 | Enforce require sufficient length | 💼 | ⚠️ | | 💡 | |
🔗 Related ESLint Plugins
Part of the Interlace ESLint Ecosystem — AI-native security plugins with LLM-optimized error messages:
| Plugin | Downloads | Description |
| :--- | :---: | :--- |
| eslint-plugin-secure-coding | | General security rules & OWASP guidelines. |
|
eslint-plugin-pg | | PostgreSQL security & best practices. |
|
eslint-plugin-crypto | | NodeJS Cryptography security rules. |
|
eslint-plugin-jwt | | JWT security & best practices. |
|
eslint-plugin-browser-security | | Browser-specific security & XSS prevention. |
|
eslint-plugin-express-security | | Express.js security hardening rules. |
|
eslint-plugin-lambda-security | | AWS Lambda security best practices. |
|
eslint-plugin-nestjs-security | | NestJS security rules & patterns. |
|
eslint-plugin-mongodb-security | | MongoDB security best practices. |
|
eslint-plugin-vercel-ai-security | | Vercel AI SDK security hardening. |
|
eslint-plugin-import-next | | Next-gen import sorting & architecture. |
📄 License
MIT © Ofri Peretz
