Backend Security
Purpose
Establish the backend's baseline security posture and coordinate the specialist skills that own each control. Assessment of a finished system belongs to ../../security-review; this skill designs the controls in.
When to Use
- When establishing a backend foundation or hardening an existing one.
- Not as the audit itself (
../../security-review) and not for per-domain detail owned by the specialists below.
Inputs
- Endpoint inventory + data sensitivity map; deployment shape.
- Findings from
existing-backend-audit / ../../environment-audit if present.
Discovery Questions
- What sensitive data classes exist (credentials, PII, payment data), and where do they flow?
- Who are the callers (browsers → CORS/cookies matter; servers → key management matters)?
- What regulatory/compliance constraints apply?
Responsibilities
- Secrets: env/secret-store only, validated at boot, never in code/logs/errors/git history; per-environment values; rotation story (
../../environment-audit).
- Transport & headers: TLS assumed at the edge; security headers (HSTS, nosniff, frame denial, minimal CSP for any served HTML); correct trust of proxy headers.
- CORS: explicit allowed origins per environment — never wildcard with credentials.
- Injection defenses: parameterized queries only (
../../database/database-security), no shell/eval on input, path traversal blocked on any filesystem access; output encoding where HTML is produced.
- Request hygiene: body-size limits, upload constraints (
file-storage), pagination caps — resource exhaustion is a security issue.
- Cookies/CSRF: httpOnly/secure/sameSite; CSRF protection for cookie-authenticated state changes.
- Audit logging: security-relevant events (logins, permission changes, admin actions, data exports) logged with actor + target, PII-safe (
backend-observability).
- Delegate and verify: input validation →
backend-validation; authn → backend-authentication; authz + IDOR → backend-authorization/ownership-authorization; abuse → rate-limiting/captcha-abuse-prevention; dependencies → ../../dependency-audit.
Required Workflow
- Map sensitive data classes and their flow.
- Set the baseline controls above for the chosen framework.
- Confirm each delegated area has its skill's design recorded.
- Define audit-logging events.
- Hand the whole surface to
../../security-review before release (Gate).
Decision Rules
- Defense in depth: no control is "covered elsewhere" — validation AND authz AND limits.
- Default deny: new endpoints inherit strict defaults (auth required, tight CORS, limits) and relax explicitly.
- Anything readable by the client is public: no secrets in responses, headers, or verbose errors (
backend-error-handling).
- Compliance constraints are requirements — surface them at planning, not release.
Rules
- Never print or commit a secret while working — flag + rotate if found.
- Security controls are configuration-as-code, reviewable — not console-clicked.
- No security claim without
../../security-review — this skill designs, it doesn't certify.
Anti-Patterns
cors({ origin: true, credentials: true }).
- Secrets in code "temporarily."
- String-built SQL/shell commands from input.
- Verbose stack traces in production responses.
- Treating rate limiting or CAPTCHA as the authorization story.
- One giant "security later" ticket.
Validation Checklist
Definition of Done
A recorded baseline-hardening design — secrets, headers, CORS, injection defenses, request hygiene, audit logging — with every delegated control owned by its specialist skill and the surface queued for security review.
Related Skills
../../security-review, backend-validation, backend-authentication, backend-authorization, ownership-authorization, rate-limiting, captcha-abuse-prevention, ../../database/database-security, ../../dependency-audit, ../../environment-audit.
Related Knowledge
../../../knowledge/ (data classes, compliance constraints).
Related References
../../../references/backend/security/ (hardening notes, when populated).
Context Loading Guidance
- Requires: data-sensitivity map, caller types, deployment shape.
- Does not require: each specialist's full detail (verify their outputs exist).
- May load:
../../security-review (hand-off), ../../environment-audit.
- Stop when: the baseline design is recorded and delegations confirmed.
Token Efficiency Guidance
Work the checklist; link specialist skill outputs instead of restating them. The sensitive-data flow map is the one artifact worth drawing.
1---2name: backend-security3description: Use to plan backend security hardening — secrets handling, security headers, CORS, injection defenses, dependency risk, request limits, and audit logging. Coordinates the specialist skills (validation, authz, rate limiting) and feeds security-review.4---56# Backend Security78## Purpose910Establish the backend's baseline security posture and coordinate the specialist skills that own each control. Assessment of a finished system belongs to `../../security-review`; this skill designs the controls in.1112## When to Use1314- When establishing a backend foundation or hardening an existing one.15- **Not** as the audit itself (`../../security-review`) and not for per-domain detail owned by the specialists below.1617## Inputs1819- Endpoint inventory + data sensitivity map; deployment shape.20- Findings from `existing-backend-audit` / `../../environment-audit` if present.2122## Discovery Questions2324- What sensitive data classes exist (credentials, PII, payment data), and where do they flow?25- Who are the callers (browsers → CORS/cookies matter; servers → key management matters)?26- What regulatory/compliance constraints apply?2728## Responsibilities2930- **Secrets**: env/secret-store only, validated at boot, never in code/logs/errors/git history; per-environment values; rotation story (`../../environment-audit`).31- **Transport & headers**: TLS assumed at the edge; security headers (HSTS, nosniff, frame denial, minimal CSP for any served HTML); correct trust of proxy headers.32- **CORS**: explicit allowed origins per environment — never wildcard with credentials.33- **Injection defenses**: parameterized queries only (`../../database/database-security`), no shell/`eval` on input, path traversal blocked on any filesystem access; output encoding where HTML is produced.34- **Request hygiene**: body-size limits, upload constraints (`file-storage`), pagination caps — resource exhaustion is a security issue.35- **Cookies/CSRF**: httpOnly/secure/sameSite; CSRF protection for cookie-authenticated state changes.36- **Audit logging**: security-relevant events (logins, permission changes, admin actions, data exports) logged with actor + target, PII-safe (`backend-observability`).37- **Delegate and verify**: input validation → `backend-validation`; authn → `backend-authentication`; authz + IDOR → `backend-authorization`/`ownership-authorization`; abuse → `rate-limiting`/`captcha-abuse-prevention`; dependencies → `../../dependency-audit`.3839## Required Workflow40411. Map sensitive data classes and their flow.422. Set the baseline controls above for the chosen framework.433. Confirm each delegated area has its skill's design recorded.444. Define audit-logging events.455. Hand the whole surface to `../../security-review` before release (Gate).4647## Decision Rules4849- Defense in depth: no control is "covered elsewhere" — validation AND authz AND limits.50- Default deny: new endpoints inherit strict defaults (auth required, tight CORS, limits) and relax explicitly.51- Anything readable by the client is public: no secrets in responses, headers, or verbose errors (`backend-error-handling`).52- Compliance constraints are requirements — surface them at planning, not release.5354## Rules5556- Never print or commit a secret while working — flag + rotate if found.57- Security controls are configuration-as-code, reviewable — not console-clicked.58- No security claim without `../../security-review` — this skill designs, it doesn't certify.5960## Anti-Patterns6162- `cors({ origin: true, credentials: true })`.63- Secrets in code "temporarily."64- String-built SQL/shell commands from input.65- Verbose stack traces in production responses.66- Treating rate limiting or CAPTCHA as the authorization story.67- One giant "security later" ticket.6869## Validation Checklist7071- [ ] Sensitive-data map recorded.72- [ ] Secrets: storage, boot validation, rotation story.73- [ ] Headers + CORS explicit per environment.74- [ ] Injection defenses + request limits set.75- [ ] Cookie/CSRF posture set for browser callers.76- [ ] Audit events defined, PII-safe.77- [ ] Delegated areas each have recorded designs.7879## Definition of Done8081A recorded baseline-hardening design — secrets, headers, CORS, injection defenses, request hygiene, audit logging — with every delegated control owned by its specialist skill and the surface queued for security review.8283## Related Skills8485`../../security-review`, `backend-validation`, `backend-authentication`, `backend-authorization`, `ownership-authorization`, `rate-limiting`, `captcha-abuse-prevention`, `../../database/database-security`, `../../dependency-audit`, `../../environment-audit`.8687## Related Knowledge8889`../../../knowledge/` (data classes, compliance constraints).9091## Related References9293`../../../references/backend/security/` (hardening notes, when populated).9495## Context Loading Guidance9697- **Requires:** data-sensitivity map, caller types, deployment shape.98- **Does not require:** each specialist's full detail (verify their outputs exist).99- **May load:** `../../security-review` (hand-off), `../../environment-audit`.100- **Stop when:** the baseline design is recorded and delegations confirmed.101102## Token Efficiency Guidance103104Work the checklist; link specialist skill outputs instead of restating them. The sensitive-data flow map is the one artifact worth drawing.