Claude MCP skill HTTP security header misconfiguration in deployments — SA-SKL-HEADERS1
HTTP security headers are a cheap, well-supported defence-in-depth layer, yet they are consistently absent from MCP skill deployments. The four SA-SKL-HEADERS1 patterns cover the highest-impact missing headers found in community skill codebases: Content-Security-Policy that would block stored XSS execution, HSTS that would prevent HTTP downgrade on API subdomains, frame-ancestors that would block clickjacking on privileged UI actions, and Referrer-Policy that would prevent token leakage via cross-origin image loads — each absent by default in common Node.js frameworks without explicit configuration.
Why security headers are routinely missing from MCP skill deployments
Node.js frameworks like Express ship with no security headers by default. Developers building MCP skill backends reach for express() and immediately focus on API routes, database connections, and business logic. Security headers require deliberate opt-in — adding helmet() or writing each header manually. Without a checklist or automated scanner in the CI pipeline, they remain absent at launch.
The impact of missing headers is not theoretical. A CSP that blocks inline scripts is the last line of defence when a stored XSS vulnerability exists despite input sanitisation. HSTS prevents the class of attacks where a user's first request to an API subdomain goes over HTTP before the browser learns to use HTTPS. The headers are collectively a few lines of configuration, but their absence means that every other security control must work perfectly — there is no fallback layer.
script-src directive; attacker injects script via stored XSS; no CSP to block execution in victim's browserframe-ancestors not set; skill dashboard iframeable from attacker page; clickjacking on audit approval button without user awarenessno-referrer-when-downgrade; audit report URL with token in fragment sent as Referer on cross-origin resource loadHEADERS1-001 — Missing Content-Security-Policy allows stored XSS execution
Content-Security-Policy is the browser's enforcement mechanism for restricting what scripts, styles, and resources a page can load and execute. Without a script-src directive, the browser applies no restriction: any <script> tag that appears in the page's HTML will execute, including those injected by a stored XSS vulnerability that evaded server-side sanitisation. Even a sanitiser that correctly strips most injection attempts will occasionally be bypassed — CSP is the layer that prevents browser execution when the sanitiser fails.
A strict nonce-based CSP is the most effective: the server generates a random nonce per page response, includes it in the CSP header as script-src 'nonce-{random}', and injects it as an attribute on every legitimate script tag. Only scripts with the matching nonce execute; injected scripts that do not know the per-request nonce are blocked by the browser.
// VULNERABLE — Express app with no security headers
import express from 'express';
const app = express();
app.get('/dashboard', (req, res) => {
// No Content-Security-Policy header — any script in the page executes
// If a stored XSS payload reaches this page (e.g., from audit report title),
// the browser will execute the attacker's script without restriction
res.send(renderDashboard(req.user));
});
// FIXED — strict nonce-based CSP via helmet; set all security headers
import express from 'express';
import helmet from 'helmet';
import { randomBytes } from 'crypto';
const app = express();
// Generate a fresh nonce per request
app.use((req, res, next) => {
res.locals.cspNonce = randomBytes(16).toString('base64');
next();
});
app.use(helmet({
contentSecurityPolicy: {
directives: {
defaultSrc: ["'self'"],
// nonce-based allowlist — injected scripts lack the nonce and are blocked
scriptSrc: ["'self'", (req, res) => `'nonce-${res.locals.cspNonce}'`],
styleSrc: ["'self'", "'unsafe-inline'"], // relax only if needed
imgSrc: ["'self'", 'data:', 'https:'],
connectSrc: ["'self'"],
frameAncestors: ["'self'"], // also covers HEADERS1-003
objectSrc: ["'none'"],
baseUri: ["'self'"],
formAction: ["'self'"],
},
},
// HEADERS1-002: HSTS with includeSubDomains covers API subdomain
hsts: {
maxAge: 31_536_000,
includeSubDomains: true,
preload: true,
},
// HEADERS1-003: also set X-Frame-Options for compatibility
frameguard: { action: 'sameorigin' },
// HEADERS1-004: strict referrer policy
referrerPolicy: { policy: 'strict-origin-when-cross-origin' },
// Additional recommended headers
xContentTypeOptions: true, // X-Content-Type-Options: nosniff
xDnsPrefetchControl: false, // X-DNS-Prefetch-Control: off
}));
app.get('/dashboard', (req, res) => {
// Pass nonce to template engine so it can be injected on script tags
res.send(renderDashboard(req.user, { nonce: res.locals.cspNonce }));
});
HEADERS1-002 — HSTS absent on API subdomain enables MitM credential capture
HTTP Strict Transport Security tells browsers to always use HTTPS for a domain and its subdomains for a specified period. When HSTS is absent from an API subdomain (api.skillaudit.dev), the first request a user's browser makes to that subdomain may go over HTTP if the user typed the URL without an explicit https:// scheme, was redirected from an HTTP link, or is on a network where DNS is manipulated. A man-in-the-middle attacker on the same network can intercept that first HTTP request and capture the Authorization: Bearer token header before any HTTPS upgrade occurs.
The fix is to include includeSubDomains in the HSTS header on the apex domain so all subdomains inherit the policy. Additionally, submit the domain to the HSTS preload list (preload flag) so browsers enforce HTTPS from the first ever request, before they have seen a single response from the server.
# Caddy configuration — VULNERABLE (no HSTS on API subdomain)
api.skillaudit.dev {
reverse_proxy localhost:3000
# Missing: Strict-Transport-Security header
# First HTTP request to api.skillaudit.dev is unprotected
}
# Caddy configuration — FIXED (HSTS with includeSubDomains)
skillaudit.dev, api.skillaudit.dev {
reverse_proxy localhost:3000
header {
# 1-year HSTS with subdomains and preload flag
Strict-Transport-Security "max-age=31536000; includeSubDomains; preload"
# Set all security headers at the reverse proxy level (applies to all routes)
Content-Security-Policy "default-src 'self'; script-src 'self' 'nonce-{nonce}'; frame-ancestors 'self'; object-src 'none'"
X-Frame-Options "SAMEORIGIN"
X-Content-Type-Options "nosniff"
Referrer-Policy "strict-origin-when-cross-origin"
Permissions-Policy "geolocation=(), camera=(), microphone=()"
}
}
# Redirect HTTP to HTTPS — required before HSTS takes effect
http://skillaudit.dev, http://api.skillaudit.dev {
redir https://{host}{uri} 301
}
HEADERS1-003 — Missing frame-ancestors enables clickjacking on privileged actions
When a page does not set Content-Security-Policy: frame-ancestors 'self' (or the legacy X-Frame-Options: SAMEORIGIN), the browser allows any page to load it inside an <iframe>. An attacker can embed the skill's audit approval page inside a transparent iframe positioned over a decoy UI, then trick the victim into clicking what appears to be a harmless button while actually confirming an audit approval or policy change. This is a clickjacking attack — the victim's authenticated session performs the action without their knowledge.
The frame-ancestors CSP directive is more precise than X-Frame-Options (it supports multiple origins and is not affected by double-encoding) but both should be set for maximum browser compatibility. Setting both costs two header lines and prevents an entire class of UI redressing attacks.
// VULNERABLE — audit approval endpoint renders without framing protection
app.get('/audits/:id/approve', requireAuth, (req, res) => {
// No X-Frame-Options or frame-ancestors CSP directive
// Attacker embeds this page in a transparent iframe over their page
// Victim clicks "approve" thinking they're clicking something else
res.render('audit-approve', { audit: req.locals.audit });
});
// FIXED — set frame-ancestors on all sensitive pages
app.get('/audits/:id/approve', requireAuth, (req, res) => {
// Set individually on sensitive routes, in addition to the global helmet config
// For routes where framing is explicitly disallowed even same-origin:
res.setHeader('Content-Security-Policy',
`default-src 'self'; script-src 'self' 'nonce-${res.locals.cspNonce}'; frame-ancestors 'none'`
);
res.setHeader('X-Frame-Options', 'DENY'); // legacy browser fallback
res.render('audit-approve', { audit: req.locals.audit, nonce: res.locals.cspNonce });
});
HEADERS1-004 — Default Referrer-Policy leaks URL-fragment tokens on cross-origin load
Some MCP skill platforms include a short-lived access token in the URL fragment to authenticate audit report share links: https://app.skillaudit.dev/reports/abc123#token=eyJhbGc.... URL fragments are not sent in HTTP requests (the browser keeps them local), so this pattern is considered safe — except when the page at that URL loads a cross-origin resource (an image, a script, an iframe). The browser's default Referer header behaviour under no-referrer-when-downgrade (the default for many browsers when no policy is set) sends the full URL including the fragment as the Referer header on cross-origin requests over HTTPS. An attacker who owns any cross-origin resource loaded on the report page will receive the fragment token in the Referer header of the resource request.
The fix is to set Referrer-Policy: strict-origin-when-cross-origin, which sends only the origin (no path, no fragment) on cross-origin requests. The longer-term fix is to move tokens out of URL fragments entirely; but the header fix is immediate and covers all current URLs without requiring a URL migration.
// VULNERABLE — no Referrer-Policy; default browser behaviour leaks fragment
app.get('/reports/:id', requireShareToken, (req, res) => {
// Page loads cross-origin analytics image:
//
// Browser sends: Referer: https://app.skillaudit.dev/reports/abc123#token=eyJ...
// cdn.example.com receives the full URL including the fragment token
res.render('report', { report: req.locals.report });
});
// FIXED — strict-origin-when-cross-origin prevents fragment leakage
app.get('/reports/:id', requireShareToken, (req, res) => {
// Cross-origin requests receive only: Referer: https://app.skillaudit.dev/
// The path, query string, and fragment are stripped from cross-origin Referer
res.setHeader('Referrer-Policy', 'strict-origin-when-cross-origin');
res.render('report', { report: req.locals.report });
});
// Better: set it globally via helmet (from HEADERS1-001 fix) so it applies everywhere
// helmet({ referrerPolicy: { policy: 'strict-origin-when-cross-origin' } })
Detection with SkillAudit
SkillAudit's SA-SKL-HEADERS1 rule set detects HTTP security header misconfigurations by analysing the skill's Express (or other framework) middleware configuration for the presence and correctness of each required header. The active probe makes HTTP requests to the skill's deployed endpoint in the scan sandbox and inspects response headers, checking for the presence of CSP, HSTS, X-Frame-Options, and Referrer-Policy headers and validating that their values are not trivially bypassed (e.g., CSP with unsafe-inline in script-src is flagged as effectively no CSP). See also SA-SKL-UPLOAD8 for file upload vulnerabilities that CSP and X-Content-Type-Options help contain.
Run SA-SKL-HEADERS1 on your skill: Paste your MCP skill's GitHub URL at skillaudit.dev to get a full scan. The free tier covers public repositories and returns a shareable security badge.
| Finding | Severity | Vulnerable pattern | Fix |
|---|---|---|---|
HEADERS1-001 | Critical | CSP missing script-src; stored XSS payload executes without restriction in victim browser | Nonce-based CSP via helmet({ contentSecurityPolicy: { directives: { scriptSrc: ['nonce-…'] } } }) |
HEADERS1-002 | High | HSTS absent on API subdomain; first HTTP request interceptable by MitM for credential capture | Strict-Transport-Security: max-age=31536000; includeSubDomains; preload on apex + API subdomain |
HEADERS1-003 | High | No frame-ancestors; audit approval page iframeable; clickjacking on privileged UI action | frame-ancestors 'none' on approval pages + X-Frame-Options: DENY for compatibility |
HEADERS1-004 | Medium | Default Referrer-Policy sends full URL (incl. fragment token) as Referer on cross-origin resource loads | Referrer-Policy: strict-origin-when-cross-origin globally via helmet |