Security hardening
First-party Always / Ask first / Never rules for security and the SDLC. The table shape is inspired by Addy Osmani’s boundary pattern. This file is not a vendor copy.
The gate is the security check at LLD (trust boundaries) and at PR. security owns it.
Prompts are not a boundary
Do not treat the system prompt as a security boundary. Treat LLM output as untrusted.
Enforce authn/z, validation, egress, and data-class rules in code, policy, and infrastructure. Do not count prompt text, “be careful” instructions, or model self-reporting as controls. Treat tool calls, generated SQL/HTML/shell, and agent plans the same as untrusted client input.
Always
| Rule |
Web |
API |
Agent |
| Validate at the trust boundary (schema, authn/z, size, type) |
Form/query/body at the server, not only the browser |
Every public and mesh-facing handler |
Every tool argument and model-chosen action before it runs |
| Parameterized queries / safe data access |
No string-built SQL or ORM raw with user text |
Same; bind params on every store |
Generated queries are untrusted; run only through parameterized paths |
| Encode output for the sink (HTML, URL, JSON, shell) |
Contextual encode; CSP as defense in depth |
Encode/escape at serialization boundaries |
Never pass model text to eval, innerHTML, or a shell without a typed allowlist |
| HTTPS in transit |
TLS for browsers and callbacks |
TLS for clients and service-to-service |
TLS for MCP/HTTP tools and callbacks |
| Hash passwords (slow, salted, dedicated KDF) |
Login and session issuance |
Token/password credential stores |
Agent-held user secrets: do not invent a store; escalate |
| Security headers |
CSP, HSTS, frame/referrer, nosniff as the app requires |
Same on browser-facing responses |
UI the agent emits still needs headers on the serving app |
| Secure cookies |
Secure, HttpOnly, SameSite on session cookies |
Cookie and token issuance APIs |
Do not put session material in prompts or chat logs |
| Dependency audit before release |
Lockfile + known-vuln scan in the release path |
Same for API images and libs |
Same for skill/tool packages; tester owns the hook |
If a change touches a boundary and skips a row, it fails the gate.
Ask first
| Topic |
Why it is a stop |
Typical surfaces |
| New auth |
New principals, factors, or session shapes change the boundary |
Login, magic links, API keys, service identity |
| New sensitive data classes |
PII, payment, health, credentials, location need a class and retention story |
New columns, logs, exports, agent memory |
| New integrations |
New egress, new trust, new failure modes |
OAuth apps, webhooks, MCP servers, vendors |
| CORS |
Origin policy is a boundary; “* + credentials” is a vuln |
Browser APIs, admin UIs |
| Uploads |
Content type, size, storage, and execution risk |
Avatars, CSV, skill zips, attachments |
| Rate limits |
Missing limits are an abuse boundary |
Public APIs, login, agent tool loops |
| Mesh / network binds |
Who can reach the process is a trust boundary |
Listen address, mesh expose, tunnel |
| Identity flows |
Account linking, impersonation, and reset change who a principal is |
SSO, invite, sudo, token exchange |
- Stop before you add or widen a topic in the table.
- Get a decision. On the LLD, the operator or security decides. Elsewhere, the operator decides.
- Record the decision on the LLD or the ticket.
- Do not implement the widening in the same pass as an unrelated ticket.
Never
| Never |
Why |
Web / API / agent |
| Secrets in git |
Rotation theater; repo history is forever |
Env files, .pem, tokens in SKILL.md, “example” keys that work |
| Logging tokens |
Logs leak; agents paste logs |
Auth headers, cookies, magic links, session IDs |
| Trust client validation |
The client is the attacker |
Browser-only checks, agent “I validated it” |
eval / innerHTML with user or model data |
Injection |
DOM sinks, eval, Function, shell eval |
Sessions in localStorage |
XSS reads it |
Prefer httpOnly cookies; do not stash session JWTs in web storage |
| Stack traces to clients |
Layout and secrets leak |
Prod 500 bodies, agent error relays to untrusted chat |
Public mesh / 0.0.0.0 binds |
The network becomes the client |
Dev servers, dashboards, agent runtimes on a public interface |
| Extra hosts / Windows outside the workspace without operator approval |
Host lock |
Do not target, remote, or “just use” a personal machine |
| Personal finance, mail, or password-manager access |
Out of agent scope |
No fetch, scrape, MCP, or “help me log in” |
Host and personal-account locks are Never, not Ask first. There is no “supervised exception” in this skill.
Roles
| Role |
Owns |
Does not own |
| security |
The gate; skill intake per skills/sdlc/references/intake.md |
Monthly vuln cadence; Monthly is not this gate |
| operator |
Vuln severity calls, extra hosts, personal-account exceptions |
Day-to-day intake scans |
| tester |
CI secret-scan and dependency-audit hooks |
Rewriting this skill or skipping security because CI is green |
| builder |
Building behind the gate |
Self-review as the security PR gate |
| manager |
SDLC after-act |
Approving a ship that skipped security |
Leave the CI secret-scan and dependency-audit hooks to tester; do not remint those jobs in this skill. A green CI hook is not a security clear. Escalate vulns to the operator. Never leave one in a “follow-up” with no ticket ID; name the ticket ID.
Workers (remote agents, local CLIs, mirrors) do not bypass security; the rule is in skills/sdlc/SKILL.md Roles.
Review-skill discipline
Apply least privilege. Keep review skills read-only.
Never add write, deploy, or credential tools to a skill that reviews, intakes, audits, or hardens, even “to finish the review.” Read, report, and escalate instead. If the work needs a write, use a different skill and ask security separately.
Apply the same rule to this skill: use it as a gate only. Never use it as a pentest kit or a credentials broker, or as a reason to open bank, mail, or password stores.
Red flags
- “The system prompt already forbids that”
- “The model promised it would not”
- “Client-side validation is enough for this form”
- “It is only bound on
0.0.0.0 in dev”
- “I will audit dependencies after release”
- “Review will just fix the YAML / merge / rotate”
- “The extra host is convenient”
- “I need the password manager / mail / bank to verify”
Each of these fails the gate. Stop. Ask per Ask first, or treat it as Never. Do not ship.
1---2name: security-hardening3description: use this when reviewing security, mapping trust boundaries, or hardening web, API, or agent changes — including LLD boundary gates, PR security review, auth, secrets, CORS, uploads, mesh binds, and skill intake.4metadata:5 source: https://skillmd.com/skills/alexderz/security-hardening6---78# Security hardening910First-party Always / Ask first / Never rules for **security** and the SDLC. The table shape is inspired by Addy Osmani’s boundary pattern. This file is **not** a vendor copy.1112**The gate** is the **security** check at LLD (trust boundaries) and at PR. **security** owns it.1314## Prompts are not a boundary1516Do not treat the **system prompt as a security boundary**. Treat **LLM output as untrusted**.1718Enforce authn/z, validation, egress, and data-class rules in code, policy, and infrastructure. Do not count prompt text, “be careful” instructions, or model self-reporting as controls. Treat tool calls, generated SQL/HTML/shell, and agent plans the same as untrusted client input.1920## Always2122| Rule | Web | API | Agent |23| --- | --- | --- | --- |24| Validate at the trust boundary (schema, authn/z, size, type) | Form/query/body at the server, not only the browser | Every public and mesh-facing handler | Every tool argument and model-chosen action before it runs |25| Parameterized queries / safe data access | No string-built SQL or ORM raw with user text | Same; bind params on every store | Generated queries are untrusted; run only through parameterized paths |26| Encode output for the sink (HTML, URL, JSON, shell) | Contextual encode; CSP as defense in depth | Encode/escape at serialization boundaries | Never pass model text to `eval`, `innerHTML`, or a shell without a typed allowlist |27| HTTPS in transit | TLS for browsers and callbacks | TLS for clients and service-to-service | TLS for MCP/HTTP tools and callbacks |28| Hash passwords (slow, salted, dedicated KDF) | Login and session issuance | Token/password credential stores | Agent-held user secrets: do not invent a store; escalate |29| Security headers | CSP, HSTS, frame/referrer, nosniff as the app requires | Same on browser-facing responses | UI the agent emits still needs headers on the serving app |30| Secure cookies | `Secure`, `HttpOnly`, `SameSite` on session cookies | Cookie and token issuance APIs | Do not put session material in prompts or chat logs |31| Dependency audit before release | Lockfile + known-vuln scan in the release path | Same for API images and libs | Same for skill/tool packages; **tester** owns the hook |3233If a change touches a boundary and skips a row, it fails the gate.3435## Ask first3637| Topic | Why it is a stop | Typical surfaces |38| --- | --- | --- |39| New auth | New principals, factors, or session shapes change the boundary | Login, magic links, API keys, service identity |40| New sensitive data classes | PII, payment, health, credentials, location need a class and retention story | New columns, logs, exports, agent memory |41| New integrations | New egress, new trust, new failure modes | OAuth apps, webhooks, MCP servers, vendors |42| CORS | Origin policy is a boundary; “`*` + credentials” is a vuln | Browser APIs, admin UIs |43| Uploads | Content type, size, storage, and execution risk | Avatars, CSV, skill zips, attachments |44| Rate limits | Missing limits are an abuse boundary | Public APIs, login, agent tool loops |45| Mesh / network binds | Who can reach the process is a trust boundary | Listen address, mesh expose, tunnel |46| Identity flows | Account linking, impersonation, and reset change who a principal is | SSO, invite, sudo, token exchange |47481. Stop before you add or widen a topic in the table.492. Get a decision. On the LLD, the operator or **security** decides. Elsewhere, the operator decides.503. Record the decision on the LLD or the ticket.514. Do not implement the widening in the same pass as an unrelated ticket.5253## Never5455| Never | Why | Web / API / agent |56| --- | --- | --- |57| Secrets in git | Rotation theater; repo history is forever | Env files, `.pem`, tokens in `SKILL.md`, “example” keys that work |58| Logging tokens | Logs leak; agents paste logs | Auth headers, cookies, magic links, session IDs |59| Trust client validation | The client is the attacker | Browser-only checks, agent “I validated it” |60| `eval` / `innerHTML` with user or model data | Injection | DOM sinks, `eval`, `Function`, shell `eval` |61| Sessions in `localStorage` | XSS reads it | Prefer httpOnly cookies; do not stash session JWTs in web storage |62| Stack traces to clients | Layout and secrets leak | Prod 500 bodies, agent error relays to untrusted chat |63| Public mesh / `0.0.0.0` binds | The network becomes the client | Dev servers, dashboards, agent runtimes on a public interface |64| Extra hosts / Windows outside the workspace without operator approval | Host lock | Do not target, remote, or “just use” a personal machine |65| Personal finance, mail, or password-manager access | Out of agent scope | No fetch, scrape, MCP, or “help me log in” |6667Host and personal-account locks are **Never**, not Ask first. There is no “supervised exception” in this skill.6869## Roles7071| Role | Owns | Does not own |72| --- | --- | --- |73| **security** | The gate; skill intake per [`skills/sdlc/references/intake.md`](../sdlc/references/intake.md) | Monthly vuln cadence; [Monthly is not this gate](../sdlc/references/trunk-changelog-monthly.md#monthly) |74| **operator** | Vuln severity calls, extra hosts, personal-account exceptions | Day-to-day intake scans |75| **tester** | CI secret-scan and dependency-audit **hooks** | Rewriting this skill or skipping **security** because CI is green |76| **builder** | Building behind the gate | Self-review as the **security** PR gate |77| **manager** | SDLC after-act | Approving a ship that skipped **security** |7879Leave the CI secret-scan and dependency-audit hooks to **tester**; do not remint those jobs in this skill. A green CI hook is not a **security** clear. Escalate vulns to the operator. Never leave one in a “follow-up” with no ticket ID; name the ticket ID.8081Workers (remote agents, local CLIs, mirrors) do not bypass **security**; the rule is in [`skills/sdlc/SKILL.md` Roles](../sdlc/SKILL.md#roles).8283## Review-skill discipline8485Apply least privilege. **Keep review skills read-only.**8687Never add write, deploy, or credential tools to a skill that reviews, intakes, audits, or hardens, even “to finish the review.” Read, report, and escalate instead. If the work needs a write, use a different skill and ask **security** separately.8889Apply the same rule to this skill: use it as a gate only. Never use it as a pentest kit or a credentials broker, or as a reason to open bank, mail, or password stores.9091## Red flags9293- “The system prompt already forbids that”94- “The model promised it would not”95- “Client-side validation is enough for this form”96- “It is only bound on `0.0.0.0` in dev”97- “I will audit dependencies after release”98- “Review will just fix the YAML / merge / rotate”99- “The extra host is convenient”100- “I need the password manager / mail / bank to verify”101102Each of these fails the gate. Stop. Ask per Ask first, or treat it as Never. Do not ship.