kit-hardening
Harden the security configuration in the user's repository, including HTTP security headers and Content Security Policy, CORS, cookie flags, TLS and redirect settings, Dockerfiles, CI workflow permiss
SKILL.mdregistry/skills/hardening/SKILL.md
GitHubHardening
Change files in the repository only; do not modify live systems, cloud settings, or secrets.
1. Inventory the configuration
Find the web framework and its security middleware (Helmet, @fastify/helmet, Django SECURE_* settings, Starlette middleware), CORS and cookie settings, reverse proxy configuration, Dockerfiles and compose files, CI workflows, dependency manifests, and how secrets reach the app.
2. Harden
- Headers:
Strict-Transport-Security(with care for subdomains),Content-Security-Policythat starts strict and lists the sources the app actually uses,X-Content-Type-Options: nosniff,Referrer-Policy, and frame protection (frame-ancestors). RemoveX-Powered-Byand version banners. - CORS: an explicit origin allowlist; never reflect arbitrary origins together with credentials.
- Cookies:
Secure,HttpOnlyfor session cookies, andSameSite=LaxorStrict; short session lifetimes where appropriate. - Errors and debug: debug mode, stack traces, and docs endpoints disabled or protected in production configuration.
- Containers: pinned base images (digest or exact tag), a non-root
USER, no secrets in layers or build args, a minimal runtime image, and a.dockerignorethat excludes.envand.git. - CI: least-privilege
permissions:per workflow or job, third-party actions pinned to a commit SHA (if you cannot look the SHA up, keep the tag, mark it, and give the user the command to resolve it, such asgh api repos/<owner>/<repo>/commits/<tag> --jq .sha), never checking out or running pull request code underpull_request_targetorworkflow_run(usepull_requestfor untrusted code),persist-credentials: falseon checkout, and untrusted input never interpolated intorun:scripts. - Secrets and dependencies: no committed secrets (
.envin.gitignore, example files without real values); a secret that was already committed must be rotated by the user, because removing or untracking it does not revoke it; lockfiles committed, and automated dependency updates if the project uses them.
3. Verify
Run the app's tests, and add tests that assert important headers and cookie flags where the project has HTTP tests. Build the container if one changed. Check that a strict CSP does not break pages the project serves; relax it only for named sources.
4. Report
List each change with its reason, the checks run, every action still on a tag with the exact command that resolves its commit SHA (gh api repos/<owner>/<repo>/commits/<tag> --jq .sha), anything that could break clients (CSP, CORS, SameSite), and remaining items that need infrastructure changes outside the repository.
Examples
- Use: "Add security headers to the Express app." "Lock down our GitHub Actions permissions." "Harden this Dockerfile."
- Skip: "Find vulnerabilities in the login code." (kit-security-audit) "Change the production firewall rules."