npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

eslint-plugin-browser-security

v1.2.1

Published

Security-focused ESLint plugin for browser applications. Detects XSS vulnerabilities, postMessage abuse, localStorage/sessionStorage/IndexedDB token exposure, cookie security issues, WebSocket security, Blob URL leaks, Service Worker risks, and CSP miscon

Readme

Description

This plugin provides Browser-specific security rules to prevent XSS and other client-side attacks. 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

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

💡 What You Get

  • 21 security rules targeting browser-specific vulnerabilities
  • XSS prevention via DOM manipulation and dynamic content detection
  • Storage security preventing sensitive data exposure in localStorage/sessionStorage/IndexedDB
  • Cross-origin protection with postMessage origin validation
  • LLM-optimized messages with CWE references and auto-fix suggestions
  • OWASP Top 10 coverage for browser security patterns

🎯 Why This Plugin?

Modern browser applications face unique security challenges across storage APIs, cross-origin communication, and dynamic content rendering. This plugin provides static analysis rules specifically designed for browser security patterns:

  • XSS Prevention: Detects dangerous DOM manipulation patterns
  • Storage Security: Prevents sensitive data exposure in localStorage/sessionStorage/IndexedDB
  • Cross-Origin Protection: Validates postMessage origin checks
  • Cookie Security: Identifies insecure cookie handling in JavaScript
  • LLM-Optimized: All rules include AI-friendly remediation guidance

🔍 Detection Examples

❌ Vulnerable Code

// XSS via innerHTML
element.innerHTML = userInput;

// Code injection via eval
eval(dynamicCode);

// JWT in localStorage (XSS can steal it)
localStorage.setItem('token', jwt);

// postMessage without origin check
window.addEventListener('message', (event) => {
  processData(event.data); // Anyone can send messages!
});

✅ Secure Code

// Safe text assignment
element.textContent = userInput;

// Or sanitize before HTML insertion
element.innerHTML = DOMPurify.sanitize(userInput);

// Use HttpOnly cookies for auth tokens (set by server)
// Server: Set-Cookie: token=xxx; HttpOnly; Secure; SameSite=Strict

// Origin validation
window.addEventListener('message', (event) => {
  if (event.origin !== 'https://trusted-domain.com') return;
  processData(event.data);
});

⚙️ Configuration Presets

| Preset | Description | | :------------ | :-------------------------------------------------- | | recommended | Recommended security configuration | | strict | Strict security configuration - all rules as errors |

🤖 LLM-Optimized Messages

All rules include structured remediation guidance designed for AI assistants:

[browser-security/no-innerhtml] XSS vulnerability: Direct HTML assignment detected.

📋 CONTEXT:
  • Pattern: element.innerHTML = unsanitizedInput
  • Risk: Any script in unsanitizedInput will execute

🛠️ REMEDIATION:
  Option A (Preferred): Use textContent for plain text
    element.textContent = userInput;

  Option B: Sanitize before insertion
    element.innerHTML = DOMPurify.sanitize(userInput);

📚 References:
  • CWE-79: https://cwe.mitre.org/data/definitions/79.html
  • OWASP XSS Prevention: 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.

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 | 💼 | ⚠️ | 🔧 | 💡 | 🚫 | | :--- | :---: | :---: | :---: | :--- | :---: | :---: | :---: | :---: | :---: | | detect-mixed-content | | | | ESLint rule documentation for detect-mixed-content | | | | | | | no-allow-arbitrary-loads | | | | ESLint rule documentation for no-allow-arbitrary-loads | | | | | | | no-clickjacking | | | | ESLint rule documentation for no-clickjacking | | | | | | | no-client-side-auth-logic | | | | ESLint rule documentation for no-client-side-auth-logic | | | | | | | no-cookie-auth-tokens | CWE-1004 | A02:2025 | 5.3 | ESLint rule documentation for no-cookie-auth-tokens | 💼 | | | 💡 | | | no-credentials-in-query-params | | | | ESLint rule documentation for no-credentials-in-query-params | | | | | | | no-disabled-certificate-validation | | | | ESLint rule documentation for no-disabled-certificate-validation | | | | | | | no-dynamic-service-worker-url | CWE-829 | A08:2025 | 7.5 | ESLint rule documentation for no-dynamic-service-worker-url | 💼 | | | 💡 | | | no-eval | CWE-95 | A03:2025 | 9.8 | ESLint rule documentation for no-eval | 💼 | | | 💡 | 🚫 | | no-filereader-innerhtml | CWE-79 | A03:2025 | 6.1 | ESLint rule documentation for no-filereader-innerhtml | 💼 | | | 💡 | | | no-http-urls | | | | ESLint rule documentation for no-http-urls | | | | | | | no-innerhtml | CWE-79 | A03:2025 | 6.1 | ESLint rule documentation for no-innerhtml | 💼 | | | 💡 | | | no-insecure-redirects | | | | ESLint rule documentation for no-insecure-redirects | | | | | | | no-insecure-websocket | | | | ESLint rule documentation for no-insecure-websocket | | | | | | | no-jwt-in-storage | CWE-922 | A02:2025 | 7.5 | ESLint rule documentation for no-jwt-in-storage | 💼 | | | 💡 | | | no-missing-cors-check | | | | ESLint rule documentation for no-missing-cors-check | | | | | | | no-missing-csrf-protection | | | | ESLint rule documentation for no-missing-csrf-protection | | | | | | | no-missing-security-headers | | | | ESLint rule documentation for no-missing-security-headers | | | | | | | no-password-in-url | | | | ESLint rule documentation for no-password-in-url | | | | | | | no-permissive-cors | | | | ESLint rule documentation for no-permissive-cors | | | | | | | no-postmessage-innerhtml | CWE-79 | A03:2025 | 6.1 | ESLint rule documentation for no-postmessage-innerhtml | 💼 | | | | | | no-postmessage-wildcard-origin | CWE-346 | A01:2025 | 8.8 | ESLint rule documentation for no-postmessage-wildcard-origin | 💼 | | | | | | no-sensitive-cookie-js | CWE-1004 | A02:2025 | 5.3 | ESLint rule documentation for no-sensitive-cookie-js | 💼 | | | 💡 | | | no-sensitive-data-in-analytics | | | | ESLint rule documentation for no-sensitive-data-in-analytics | | | | | | | no-sensitive-data-in-cache | | | | ESLint rule documentation for no-sensitive-data-in-cache | | | | | | | no-sensitive-indexeddb | CWE-922 | A02:2025 | 7.5 | ESLint rule documentation for no-sensitive-indexeddb | 💼 | | | 💡 | | | no-sensitive-localstorage | CWE-922 | A02:2025 | 7.5 | ESLint rule documentation for no-sensitive-localstorage | 💼 | | | 💡 | | | no-sensitive-sessionstorage | CWE-922 | A02:2025 | 7.5 | ESLint rule documentation for no-sensitive-sessionstorage | 💼 | | | 💡 | | | no-tracking-without-consent | | | | ESLint rule documentation for no-tracking-without-consent | | | | | | | no-unencrypted-transmission | | | | ESLint rule documentation for no-unencrypted-transmission | | | | | | | no-unescaped-url-parameter | | | | ESLint rule documentation for no-unescaped-url-parameter | | | | | | | no-unsafe-eval-csp | CWE-95 | A03:2025 | 9.8 | ESLint rule documentation for no-unsafe-eval-csp | 💼 | | | 💡 | | | no-unsafe-inline-csp | CWE-79 | A03:2025 | 6.1 | ESLint rule documentation for no-unsafe-inline-csp | 💼 | | | 💡 | | | no-unvalidated-deeplinks | | | | ESLint rule documentation for no-unvalidated-deeplinks | | | | | | | no-websocket-eval | CWE-95 | A03:2025 | 9.8 | ESLint rule documentation for no-websocket-eval | 💼 | | | 💡 | | | no-websocket-innerhtml | CWE-79 | A03:2025 | 6.1 | ESLint rule documentation for no-websocket-innerhtml | 💼 | | | 💡 | | | no-worker-message-innerhtml | CWE-79 | A03:2025 | 6.1 | ESLint rule documentation for no-worker-message-innerhtml | 💼 | | | | | | require-blob-url-revocation | CWE-401 | A04:2025 | 5.3 | ESLint rule documentation for require-blob-url-revocation | 💼 | ⚠️ | | 💡 | | | require-cookie-secure-attrs | CWE-614 | A05:2025 | 5.3 | ESLint rule documentation for require-cookie-secure-attrs | 💼 | | | | 🚫 | | require-csp-headers | | | | ESLint rule documentation for require-csp-headers | | | | | | | require-https-only | | | | ESLint rule documentation for require-https-only | | | | | | | require-mime-type-validation | | | | ESLint rule documentation for require-mime-type-validation | | | | | | | require-postmessage-origin-check | CWE-346 | A01:2025 | 8.8 | ESLint rule documentation for require-postmessage-origin-check | 💼 | | | | | | require-url-validation | | | | ESLint rule documentation for require-url-validation | | | | | | | require-websocket-wss | CWE-319 | A02:2025 | 7.5 | ESLint rule documentation for require-websocket-wss | 💼 | | | 💡 | 🚫 |

🔗 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 | 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