Harden web app headers and cookies
Produces hardened HTTP security headers, a Content Security Policy, CORS and cookie settings for a web app, rolled out first in report-only mode. Use before launch or after a security scan.
Security headers copied from a blog post either break the site on the first deploy (a CSP that blocks the payment widget, HSTS with preload on a domain whose subdomains are not all HTTPS) or are so loose they protect nothing (unsafe-inline everywhere, CORS reflecting any origin with credentials). Safe hardening means a policy fitted to how this app actually loads code and data, deployed in report-only mode first, then enforced.
Produce hardened header, CORS and cookie settings for: Only if [THIRD_PARTY_ORIGINS] is given: Third-party origins in use: Only if [FRAMEWORK] is given: Headers are set in:
- If you do not know where headers are set, write the config for nginx and ask which layer the app uses.
- Content Security Policy: prefer a strict policy with nonces or hashes and
'strict-dynamic', plusobject-src 'none',base-uri 'none'(or'self'), andframe-ancestors. Fall back to an allowlist only where a nonce is impossible, and say why. Include a reporting endpoint. Deploy it first asContent-Security-Policy-Report-Only. - HSTS: start with a short
max-age, raise it to at least one year after checking, addincludeSubDomainsonly once every subdomain serves HTTPS, and treatpreloadas a separate, deliberate decision that is hard to reverse. - Other headers:
X-Content-Type-Options: nosniff,Referrer-Policy: strict-origin-when-cross-origin, aPermissions-Policythat disables features the app does not use,Cross-Origin-Opener-Policy: same-origin(check OAuth and payment popups first), andX-Frame-Options: DENYas a fallback for old browsers. Do not set the deprecatedX-XSS-Protectionfilter. - CORS: only for endpoints that need cross-origin access; an explicit origin allowlist; never reflect the request origin or use
*together with credentials;Vary: Origin; minimal allowed methods and headers. - Cookies:
Secure,HttpOnlyfor anything scripts do not read,SameSite=Laxby default (Strictfor sensitive actions,Noneonly withSecureand a real cross-site need), the__Host-prefix for session cookies, and noDomainattribute unless subdomains must share it.
- Fit the policy to the third-party origins given. If an origin's needs are unclear, leave it out of the enforced policy and let report-only mode reveal it.
- Never recommend
'unsafe-inline'or'unsafe-eval'for scripts without stating the risk and a plan to remove it. - Write config only for the stated framework or server; do not invent middleware names you are unsure exist.
- Do only what was asked. If you notice something else worth changing, mention it in one line at the end instead of changing it.
- Keep the change as small as it can be while still being correct.
Policy
A table: header or setting, value, why, rollout stage (report-only, ramp, enforce).
Config
Fenced code for the framework or server.
Rollout
Numbered stages with durations and the signal to move to the next stage.
Breakage to watch
Features likely to break (inline handlers, popups, embeds, widgets) and how to tell from violation reports.
Verify
How to check the live headers and read the CSP reports.
1 required value still a placeholder; the assistant will ask for it.
details
- kind
- Prompt: a task you run by name to get one finished thing back
- domain
- Software engineering
- category
- Security
- level
- Intermediate
- made for
- Security engineer, Frontend engineer, Backend engineer, Full-stack engineer
- risk
- read-only
- version
- v1.0.0 · incubating
- reviewed
- 2026-10-02
- works in
- Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Antigravity, OpenCode, Windsurf, Zed, Continue, AGENTS.md, ChatGPT, claude.ai
use in
npx @hermes-hq/hodios install harden-web-app-config --target claude-codenpx skills add hermes-hq/hodios-dist --skill harden-web-app-config -a claude-codeclaude plugin marketplace add hermes-hq/hodios-distclaude plugin install hodios-software-engineering@hodiosThe plugin brings every entry in this domain at once.
pairs well with
All of SecuritySecurity auditor
Reviews code for exploitable weaknesses and reports only issues with a concrete attack path. Use as a reviewer persona or subagent for security-sensitive changes.
security-auditorRespond to a leaked secret
Produces an ordered response plan for an exposed key, token or password - revoke and rotate, audit use, clean up copies, notify and prevent. Use right after a secret is committed, logged or shared.
respond-to-leaked-secretReview an API against the OWASP API Top 10
Reviews an API design or implementation against the OWASP API Security Top 10, from object-level authorization and mass assignment to rate limits and SSRF, with attack paths and fixes.
review-api-securityReview a cloud IAM policy
Reviews AWS, GCP or Azure IAM policies for over-broad permissions, privilege-escalation paths, wildcard resources and missing conditions, and proposes least-privilege versions.
review-cloud-iam-policyReview a pull request for security
Reviews a diff for exploitable vulnerabilities and reports only findings with a concrete attack path. Use before merging changes to input handling, auth, data access or dependencies.
review-pr-for-securityThreat model a feature
Builds a threat model for one feature or change, mapping data flows and trust boundaries to ranked threats and mitigations. Use during design, before the code is written or merged.
threat-model-feature