Open source · MIT · Node 22+

Catch frontend vulnerabilities before they ship.

FrontGuard scans React, Vue, Svelte, Angular and plain JS/TS for XSS sinks, leaked secrets, insecure auth and vulnerable dependencies. One command, no account, your code never leaves your machine.

npx @juliocarneiro/frontguard
Get started See all rules
src/Comment.tsx
export function Comment({ comment, user }: Props) {
  useEffect(() => {
    localStorage.setItem('authToken', user.token);
  }, [user]);
 
  const preview = document.getElementById('preview')!;
  preview.innerHTML = comment.draft;
 
  return (
    <article>
      <div dangerouslySetInnerHTML={{ __html: comment.body }} />
      <a href={`/u/${user.id}?token=${user.token}`}>Profile</a>
    </article>
  );
}

npx @juliocarneiro/frontguard

  1. highAuth token stored in Web Storage: key "authToken"src/Comment.tsx:3:5 · FG-AUTH-001
  2. highDynamic innerHTML/outerHTML assignment: innerHTMLsrc/Comment.tsx:7:3 · FG-XSS-001
  3. highReact dangerouslySetInnerHTMLsrc/Comment.tsx:11:12 · FG-XSS-004
  4. highCredential passed in a URLsrc/Comment.tsx:12:16 · FG-AUTH-002

✖ 4 issues (4 high) · 1 file scanned

Real output of FrontGuard on these samples.

31built-in rules
130+secret formats
5lockfile formats
5frameworks
Coverage

What it finds

Five categories, tuned for code that runs in the browser.

XSS sinks

innerHTML, eval, document.write, dangerouslySetInnerHTML, v-html, {@html}, Angular sanitizer bypasses and javascript: URLs.

Leaked secrets

130+ provider token formats, private keys, JWTs and database URLs. Masked in every report, and browser-safe keys are ignored.

Insecure auth

Tokens in localStorage, credentials in query strings and hardcoded passwords.

Misconfiguration

Public source maps, http:// and ws:// resources, third-party scripts without SRI and postMessage to "*".

Vulnerable dependencies

Exact versions from npm, pnpm, yarn and bun lockfiles, checked against OSV.dev with CVEs and fixed versions.

Get started

Three ways in

Try it in ten seconds, then keep it in your workflow.

  1. Scan now

    Nothing to install: npx downloads the package and scans the current directory, exiting with 1 when it finds something serious. Use the full scoped name, shown below.

  2. Set up the project

    Installs FrontGuard, creates the config, adds a "security" script and a GitHub Actions workflow. Asks before each step.

  3. Run it everywhere

    Locally, in pre-commit hooks or in CI. Results go to the console, JSON, an HTML dashboard or SARIF.

The npm package is @juliocarneiro/frontguard. There is no unscoped "frontguard" package, so "npx frontguard" only works after FrontGuard is installed in the project; "frontguard" is the name of the command it installs (used by npm run security).

Built for frontend

Fewer false alarms, more real bugs

Framework-aware

Script blocks in .vue, .svelte, .astro and .html files are analyzed in place, so every finding points at the right line and column.

Knows what is public

Stripe publishable keys, Sentry DSNs and Supabase anon keys are made for the browser. FrontGuard does not cry wolf about them.

Never leaks what it finds

Secrets are masked in the terminal, JSON, HTML and SARIF output, including the context lines around other findings.

Reads your lockfile

Transitive packages included, dev-only packages detected by walking the dependency graph, and the fix version for each advisory.

One parse per file

Every rule shares a single Babel parse and traversal, ESLint style, so large projects scan in seconds.

Quiet when you need it

Per-rule levels, a "warn" mode that never fails the build, and inline // frontguard-ignore-next-line comments.

Rules

Every rule, documented

Each rule has a stable id, a severity, a CWE mapping and a concrete fix.

RuleSeverityWhat it catches
FG-XSS-001no-inner-htmlhighDynamic innerHTML/outerHTML assignmentAssigning a dynamic value to innerHTML or outerHTML parses it as HTML, which executes injected markup and scripts.
FG-XSS-002no-evalcriticalDynamic code executioneval(), new Function() and string arguments to setTimeout/setInterval compile strings as code, turning any injected value into code execution.
FG-XSS-003no-document-writehighdocument.write() calldocument.write() and document.writeln() inject raw HTML into the page and are a classic XSS sink.
FG-XSS-004no-dangerously-set-inner-htmlhighReact dangerouslySetInnerHTMLdangerouslySetInnerHTML bypasses React escaping. Any untrusted data that reaches __html is executed as markup.
FG-XSS-005no-v-htmlhighVue v-html directivev-html renders raw HTML and executes any markup injected into the bound value.
FG-XSS-006no-bypass-security-trustcriticalAngular sanitizer bypassDomSanitizer.bypassSecurityTrust* disables the built-in Angular XSS protection for that value.
FG-XSS-007no-html-sink-callhighDynamic HTML passed to a parsing APIinsertAdjacentHTML, Range.createContextualFragment and setHTMLUnsafe parse their argument as HTML, executing injected markup.
FG-XSS-008no-javascript-urlmediumjavascript: URLjavascript: URLs run code when followed. They are a common XSS vector in href, src and form actions.
FG-XSS-009no-svelte-htmlhighSvelte {@html} tag{@html ...} inserts raw HTML without escaping and executes injected markup.
FG-XSS-010no-open-redirecthighNavigation to a URL taken from the page addressA value read from location.search/hash, URLSearchParams, document.referrer or window.name is used as a navigation target. Attackers craft links that redirect victims to phishing pages, or run code with a javascript: URL (DOM-based XSS).
FG-XSS-011no-dangerous-attributehighCode-executing attribute set from a dynamic valueEvent-handler attributes (onclick, onerror...) are compiled as JavaScript and iframe srcdoc is parsed as a full HTML document, so a dynamic value there executes injected code. URL attributes fed from the page address accept javascript: URLs.
FG-XSS-012no-prototype-pollutionhighPrototype pollution in object mergeA merge/extend/set helper copies attacker-controllable keys onto an object without rejecting "__proto__", "constructor" and "prototype". A payload such as {"__proto__": {...}} then adds properties to every object on the page, which turns into DOM XSS through sanitizers and templating (DOMPurify CVE-2026-41238) or code execution on the server (React2Shell, CVE-2025-55182).
FG-SEC-001no-aws-credentialscriticalAWS credentials exposedAWS access keys or secret keys were found in source code. They grant direct access to AWS services and can lead to full account compromise.
FG-SEC-002no-api-tokenshighAPI key or token exposedA provider API key or token was found hardcoded in source code. Anything bundled into frontend code is readable by every visitor.
FG-SEC-003no-private-keyscriticalPrivate key exposedA private cryptographic key (RSA, EC, DSA, PGP or OpenSSH) was found.
FG-SEC-004no-hardcoded-jwthighHardcoded JWTA JSON Web Token was found in source code. JWTs carry identity claims and are often still valid when leaked.
FG-SEC-005no-connection-stringscriticalDatabase connection string exposedA database URL containing credentials was found in source code.
FG-SEC-006no-high-entropy-stringsmediumHigh-entropy stringA long random-looking string was found. It may be a credential; review it and suppress the finding if it is not.
FG-SEC-007no-secret-in-public-envhighServer secret exposed through a public env variableVariables prefixed with NEXT_PUBLIC_, VITE_, REACT_APP_, NUXT_PUBLIC_, PUBLIC_, EXPO_PUBLIC_... are inlined into the JavaScript sent to the browser. A name like VITE_SUPABASE_SERVICE_ROLE_KEY or NEXT_PUBLIC_STRIPE_SECRET means a server secret is readable by every visitor.
FG-AUTH-001no-token-in-web-storagehighAuth token stored in Web StoragelocalStorage and sessionStorage are readable by any script on the page, so a single XSS bug leaks every token stored there.
FG-AUTH-002no-token-in-urlhighCredential passed in a URLTokens in query strings end up in browser history, server and proxy logs, and Referer headers.
FG-AUTH-003no-hardcoded-credentialscriticalHardcoded credentialA password or secret is assigned as a string literal. Everything in frontend code ships to the browser and can be read by anyone.
FG-AUTH-004no-insecure-randommediumMath.random() used for a security valueMath.random() is not cryptographically secure: its output can be predicted from a few samples. Tokens, nonces, OAuth state, PKCE verifiers, salts or passwords generated with it can be guessed.
FG-AUTH-005no-insecure-cookiemediumAuth cookie written from JavaScriptA session or token cookie is set through document.cookie. Cookies written by JavaScript can never be httpOnly, so any XSS can read them, and without Secure and SameSite they also travel over plain HTTP and cross-site requests.
FG-CFG-001no-public-sourcemapsmediumPublic source maps in build configPublishing source maps exposes your original source code, comments and internal paths to anyone.
FG-CFG-002no-mixed-contentmediumInsecure http:// or ws:// resourceLoading scripts, data or sockets over plain HTTP/WS lets anyone on the network read or tamper with them, and browsers block it on HTTPS pages.
FG-CFG-003require-srilowThird-party resource without Subresource IntegrityA script or stylesheet is loaded from another origin without an integrity hash. If that host is compromised, its code runs on your page.
FG-CFG-004no-wildcard-postmessagemediumpostMessage with "*" target originpostMessage(data, "*") delivers the message to whatever origin the target window currently has, leaking data to attacker-controlled frames.
FG-CFG-005require-message-origin-checkmediummessage event handler without an origin checkA window "message" listener reads the event without checking event.origin. Any site that can open or frame your page can post messages to it, so the data must be treated as attacker-controlled (DOM XSS, token theft, CSRF-style actions).
FG-CFG-006no-exposed-dev-servermediumDev server protections disabledThe dev server accepts any Host header, any CORS origin or serves files outside the project. Any website you visit can then read your source and files such as .env through your local dev server (DNS rebinding and cross-origin reads, as in the Vite file-read CVEs CVE-2025-30208, CVE-2025-31125 and CVE-2025-24010).
FG-DEP-001no-vulnerable-dependencieshighVulnerable dependencyAn installed package version has a published security advisory (source: OSV.dev).

Full rule reference

CI

Findings in the Security tab

The SARIF output uses relative paths, stable fingerprints and GitHub security-severity, so alerts are deduplicated across runs and ranked correctly. npm create @juliocarneiro/frontguard writes this workflow for you.

  • Fails the job at the severity you choose
  • Annotates pull requests
  • Works with any CI that reads SARIF or JSON
.github/workflows/frontguard.yml
name: FrontGuard
on: [push, pull_request]
permissions:
  contents: read
  security-events: write
jobs:
  scan:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v5
      - uses: actions/setup-node@v5
        with: { node-version: 22 }
      - run: npx --yes @juliocarneiro/frontguard@latest -r console,sarif
      - uses: github/codeql-action/upload-sarif@v4
        if: ${{ !cancelled() }}
        with:
          sarif_file: frontguard-report/frontguard-report.sarif
scan.ts
import { defineRule, scan, toSarif } from '@juliocarneiro/frontguard';

const noAlert = defineRule({
  meta: {
    id: 'ACME-001', name: 'no-alert', title: 'alert() call',
    severity: 'low', category: 'misconfig',
    description: 'alert() blocks the UI.',
    remediation: 'Use the design-system dialog.',
  },
  create: (context) => ({
    CallExpression({ node }) {
      if (node.callee.name === 'alert') {
        context.report({ line: node.loc.start.line, column: 1 });
      }
    },
  }),
});

const result = await scan({ config: { customRules: [noAlert] } });
await writeFile('report.sarif', toSarif(result));
API

Your own rules, same engine

Use FrontGuard as a library, and add rules for your team’s conventions with the same visitor API the built-in rules use.

Ship it safer today.

Free and open source, under the MIT license.

npm create @juliocarneiro/frontguard
Star on GitHub