skills/missing-security-headers-anti-pattern/SKILL.md
Security anti-pattern for missing security headers (CWE-16). Use when generating or reviewing web application code, server configuration, or HTTP response handling. Detects missing CSP, HSTS, X-Frame-Options, and other protective headers.
npx skillsauth add igbuend/grimbard missing-security-headers-anti-patternInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Severity: Medium
HTTP security headers defend against XSS, clickjacking, and man-in-the-middle attacks at the browser level. Applications failing to send these headers rely on insecure browser defaults, missing a powerful declarative security layer.
The anti-pattern is omitting security headers from HTTP responses. Browsers default to permissive policies; servers must instruct stricter controls.
# VULNERABLE: A Flask application that does not set any security headers.
from flask import Flask, make_response
app = Flask(__name__)
@app.route("/")
def index():
# Response sent with insecure default headers.
# - No CSP: scripts from any origin can execute
# - No X-Frame-Options: any site can iframe for clickjacking
# - No HSTS: connection can downgrade to HTTP
response = make_response("<h1>Welcome to the site!</h1>")
return response
# The HTTP response would look something like this:
#
# HTTP/1.1 200 OK
# Content-Type: text/html; charset=utf-8
# Content-Length: 29
#
# <h1>Welcome to the site!</h1>
# SECURE: The application sets a strong baseline of security headers for all responses.
from flask import Flask, make_response
app = Flask(__name__)
@app.after_request
def add_security_headers(response):
# CSP: Prevents XSS. Allows resources only from same origin ('self').
response.headers['Content-Security-Policy'] = "default-src 'self'"
# X-Frame-Options: Prevents iframe embedding, mitigates clickjacking.
response.headers['X-Frame-Options'] = 'DENY'
# HSTS: Instructs browser to use only HTTPS.
response.headers['Strict-Transport-Security'] = 'max-age=31536000; includeSubDomains'
# X-Content-Type-Options: Prevents MIME-sniffing.
response.headers['X-Content-Type-Options'] = 'nosniff'
# Referrer-Policy: Controls referrer information sent with requests.
response.headers['Referrer-Policy'] = 'strict-origin-when-cross-origin'
return response
@app.route("/")
def index_secure():
return make_response("<h1>Welcome to the secure site!</h1>")
# The HTTP response now includes critical security controls:
#
# HTTP/1.1 200 OK
# Content-Type: text/html; charset=utf-8
# Content-Length: 36
# Content-Security-Policy: default-src 'self'
# X-Frame-Options: DENY
# Strict-Transport-Security: max-age=31536000; includeSubDomains
# X-Content-Type-Options: nosniff
# Referrer-Policy: strict-origin-when-cross-origin
#
# <h1>Welcome to the secure site!</h1>
Helmet for Express.js) to handle this.Implement a middleware or a global response filter in your application that adds the following headers to all outgoing responses.
Content-Security-Policy (CSP): Most important XSS defense. Defines strict allowlist for content sources (scripts, styles, images). Start with default-src 'self'.Strict-Transport-Security (HSTS): Browser uses only HTTPS. Prevents downgrade attacks.X-Frame-Options: Primary clickjacking defense. Prevents iframe embedding. Set to DENY or SAMEORIGIN.X-Content-Type-Options: Set to nosniff. Prevents MIME-sniffing abuse for script execution.Referrer-Policy: Controls referrer information sent on navigation. Default: strict-origin-when-cross-origin.Permissions-Policy: Selectively enable/disable browser features (microphone, camera, geolocation).development
Security anti-pattern for Cross-Site Scripting vulnerabilities (CWE-79). Use when generating or reviewing code that renders HTML, handles user input in web pages, uses innerHTML/document.write, or builds dynamic web content. Covers Reflected, Stored, and DOM-based XSS. AI code has 86% XSS failure rate.
development
Security anti-pattern for XPath injection vulnerabilities (CWE-643). Use when generating or reviewing code that queries XML documents, constructs XPath expressions, or handles user input in XML operations. Detects unescaped quotes and special characters in XPath queries.
development
Security anti-pattern for weak password hashing (CWE-327, CWE-759). Use when generating or reviewing code that stores or verifies user passwords. Detects use of MD5, SHA1, SHA256 without salt, or missing password hashing entirely. Recommends bcrypt, Argon2, or scrypt.
development
Security anti-pattern for weak encryption (CWE-326, CWE-327). Use when generating or reviewing code that encrypts data, handles encryption keys, or uses cryptographic modes. Detects DES, ECB mode, static IVs, and custom crypto implementations.