---
name: security-hardening-audit
description: Use when asked to check or harden a website's or web app's security posture from the outside in - HTTPS/HSTS, security headers and CSP, cookies, forms (CSRF, spam, bot protection), exposed files (.env, .git, backups, debug pages), admin and login surface, and third-party scripts - and to propose fixes as a review PR. Audit is read-only and non-intrusive by default. Not a penetration test, not for dependency updates (use dependency-update-pass).
---

# Security hardening audit

Last reviewed: 2026-11-10

## Quick prompts

For anyone improving a site or app, whether a small-business owner or someone at a larger company practicing better prompts. Most website break-ins use common, preventable gaps, and checking for them from the outside is safe and quick. Paste a prompt into any AI assistant that can see the site or repo.

1. "Without logging in or testing anything aggressive, check the public security settings of the site I work on (HTTPS and security headers). Explain in plain language what is missing and why it matters, before suggesting changes."
   *Why this prompt works:* Set limits up front (read-only, nothing aggressive) so the assistant stays safe.

2. "List the outside scripts the site I work on loads, like analytics, chat, or fonts. For each, say what it does and whether it looks unused. Report only; don't remove anything."
   *Why this prompt works:* Ask for a report first: removing a script can break something someone relies on.

3. "Here are the security headers from the site I work on: [paste]. Explain what each one does, which are missing, and which matter most, in plain English. Don't change anything yet."
   *Why this prompt works:* Giving the assistant the actual data beats asking it to guess.

Find the common, preventable weaknesses of a public website or web app and propose the smallest safe fixes. This is a passive, owner-authorized review, not an attack.

## Hard limits

- Only test sites the owner controls and has asked you to check. No scanning of third parties.
- Passive and polite: normal requests, a browser user agent, a pause between requests, no brute force, no fuzzing, no load tests, no exploit attempts, no form submissions with real data.
- If you find an exposed secret (key in a JS bundle, `.env` served publicly), **do not print, copy, test, or commit it**. Report the URL and type only, and tell the owner to rotate it.
- Fixes go in a review PR. Header and config changes at the CDN/host, DNS, mail (SPF/DKIM/DMARC), and secret rotation need the owner's explicit approval and are usually done by them.
- Never weaken an existing control to make something work.

## Inputs to gather

1. Domains and subdomains in scope (production, staging, preview).
2. Hosting/CDN and where headers are set (framework middleware, `_headers` file, server config, CDN rules).
3. Stack: static, SSR, SPA plus API, CMS (WordPress etc.), auth provider.
4. Forms and endpoints that accept input; how spam is handled today.
5. Third-party scripts and why each exists (analytics, ads, chat, embeds, fonts).

## Step 1: Classify

| Type | Focus | Lower priority |
|---|---|---|
| Static content site (articles, marketing, docs) | HTTPS/HSTS, headers, CSP for third-party scripts, exposed files, form spam, staging exposure | Session handling (usually none) |
| CMS site | Admin path exposure, login rate limiting, plugin/theme versions shown, XML-RPC, user enumeration, backups in web root | — |
| E-commerce | Payment page isolation (hosted fields/iframes), CSP on checkout, cookie flags, third-party script inventory (skimming risk) | — |
| SaaS / app with auth | Cookies (`Secure`, `HttpOnly`, `SameSite`), CSRF on state-changing requests, CORS, session timeout, password reset flow, MFA availability, error pages leaking stack traces | — |
| SPA + API | CORS allowlist, tokens kept out of `localStorage` where possible, API error verbosity, source maps in production | — |

## Step 2: Check (read-only)

**Transport**
- HTTP redirects to HTTPS with one hop; certificate valid and auto-renewing.
- `Strict-Transport-Security: max-age=31536000; includeSubDomains` once every subdomain is HTTPS. Only add `preload` after the owner understands it is hard to undo.

**Headers** (compare against the OWASP Secure Headers recommendations)
- `Content-Security-Policy`: start as `Content-Security-Policy-Report-Only`, list every real source, avoid `unsafe-inline`/`unsafe-eval` where feasible (nonces or hashes instead), include `frame-ancestors`, `base-uri 'self'`, `object-src 'none'`, `form-action`.
- `X-Content-Type-Options: nosniff`; `Referrer-Policy: strict-origin-when-cross-origin`; `Permissions-Policy` turning off unused features; `frame-ancestors` (or `X-Frame-Options: DENY/SAMEORIGIN` for old browsers).
- Remove version-leaking headers (`X-Powered-By`, detailed `Server`).
- `Cross-Origin-Opener-Policy: same-origin` where popups do not need it.

**Cookies**: every session or auth cookie has `Secure`, `HttpOnly`, and `SameSite=Lax` or `Strict`; consider the `__Host-` prefix.

**Forms and input**
- CSRF protection on state-changing requests (token or SameSite plus origin check).
- Spam/bot protection that does not hurt accessibility: honeypot field, server-side validation, rate limiting, and a privacy-friendly challenge (for example Cloudflare Turnstile or similar) verified **server-side**.
- Contact forms must not allow header injection or arbitrary recipients; success and error pages should not echo raw input.

**Exposed files and surfaces** (request with HEAD/GET, expect 403/404)
- `/.env`, `/.git/HEAD`, `/.git/config`, `/.DS_Store`, `/backup.zip`, `*.sql`, `*.bak`, `/wp-config.php.bak`, `/phpinfo.php`, `/server-status`, `/.well-known/` contents, production source maps (`*.map`) if they reveal private code.
- Directory listing off. Custom 404/500 pages that do not show stack traces.
- Admin/login paths: rate limited, MFA available, not indexed. Staging/preview: password- or access-protected, or at least `noindex`.
- `/.well-known/security.txt` with a contact (RFC 9116).

**Third-party scripts**: inventory each one, its purpose, and whether it is still used. Use Subresource Integrity (`integrity` + `crossorigin`) for static CDN files; remove dead tags.

**Email domain (report only)**: SPF, DKIM, DMARC records exist. Changing them is a DNS change that needs approval.

Helpful tools: browser DevTools network panel, `curl -sI` for headers on hosts that allow it, Mozilla HTTP Observatory, securityheaders.com, SSL Labs. Note that third-party scanners make requests on your behalf, so confirm the owner is fine with that.

## Step 3: Propose fixes

- Ship headers through the place the stack already uses (framework config, `_headers`, middleware). One review PR.
- CSP in report-only first; switch to enforce only after a clean period and owner approval.
- Remove exposed files from the deploy output and add them to ignore rules; rotation of any leaked secret is the owner's job.

## Validation

- Re-request headers on the preview URL in a real browser; confirm no console CSP violations on key templates (home, article, form, checkout/login).
- Forms still work end to end in a test mode that sends nothing real (or with the owner's test inbox).
- Build and tests pass.

## Report format

Table: finding, severity (high/medium/low/info), evidence (URL, header, response code; never secret values), fix, where it is applied, needs-approval yes/no. Then: what was not tested and why, and the PR link marked "not merged".

## References

- OWASP Secure Headers Project: https://owasp.org/www-project-secure-headers/
- OWASP ASVS 5.0: https://asvs.owasp.org/
- OWASP Cheat Sheets (CSP, CSRF, Session Management, HTTP Headers): https://cheatsheetseries.owasp.org/
- MDN CSP: https://developer.mozilla.org/en-US/docs/Web/HTTP/Guides/CSP
- MDN Strict-Transport-Security and Set-Cookie: https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Strict-Transport-Security , https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Set-Cookie
- Subresource Integrity: https://developer.mozilla.org/en-US/docs/Web/Security/Subresource_Integrity
- RFC 9116 security.txt: https://www.rfc-editor.org/rfc/rfc9116
- Mozilla HTTP Observatory: https://developer.mozilla.org/en-US/observatory
- Cloudflare Turnstile server-side validation: https://developers.cloudflare.com/turnstile/get-started/server-side-validation/
