hermes

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.

context

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.

task

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:

  1. If you do not know where headers are set, write the config for nginx and ask which layer the app uses.
  2. Content Security Policy: prefer a strict policy with nonces or hashes and 'strict-dynamic', plus object-src 'none', base-uri 'none' (or 'self'), and frame-ancestors. Fall back to an allowlist only where a nonce is impossible, and say why. Include a reporting endpoint. Deploy it first as Content-Security-Policy-Report-Only.
  3. HSTS: start with a short max-age, raise it to at least one year after checking, add includeSubDomains only once every subdomain serves HTTPS, and treat preload as a separate, deliberate decision that is hard to reverse.
  4. Other headers: X-Content-Type-Options: nosniff, Referrer-Policy: strict-origin-when-cross-origin, a Permissions-Policy that disables features the app does not use, Cross-Origin-Opener-Policy: same-origin (check OAuth and payment popups first), and X-Frame-Options: DENY as a fallback for old browsers. Do not set the deprecated X-XSS-Protection filter.
  5. 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.
  6. Cookies: Secure, HttpOnly for anything scripts do not read, SameSite=Lax by default (Strict for sensitive actions, None only with Secure and a real cross-site need), the __Host- prefix for session cookies, and no Domain attribute unless subdomains must share it.
constraints
  • 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.
output format

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

Edit on GitHubReport a problem

use in

Hodios CLI
npx @hermes-hq/hodios install harden-web-app-config --target claude-code
Agent Skills
npx skills add hermes-hq/hodios-dist --skill harden-web-app-config -a claude-code
Add the Hodios marketplace (once)
claude plugin marketplace add hermes-hq/hodios-dist
Install the software-engineering plugin
claude plugin install hodios-software-engineering@hodios

The plugin brings every entry in this domain at once.

pairs well with

All of Security
PersonaSecurity

Security 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-auditor
PromptSecurity

Respond 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-secret
PromptSecurity

Review 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-security
PromptSecurity

Review 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-policy
PromptSecurity

Review 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-security
PromptSecurity

Threat 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