security-law
Skill2 starsChanged 2 months agoMITView on GitHub
The Atelier Security Law — OWASP-grade defense for every request path (injection, XSS, CSRF, tenant isolation, rate limiting, transport). Load before writing ANY endpoint, form, or data-processing code — not just auth. Auth token/session mechanics live in [[auth-law]]; this is everything else.
In this repository28 other files it gives its agents.
- anime-jsSkill
- apple-designSkill
- asset-pipelineSkill
- atelier-bootstrapSkill
- atelier-buildSkill
- atelier-clarifySkill
- atelier-doctorSkill
- atelier-learnSkill
- atelier-planSkill
- atelier-promoteSkill
- atelier-reviewSkill
- atelier-shipSkill
- atelier-statusSkill
- atelier-updateSkill
- auth-lawSkill
- clean-code-lawSkill
- deploy-advisorSkill
- design-lawSkill
- docs-siteSkill
- gatewaySkill
- living-graphicsSkill
- loop-engineSkill
- mcp-makerSkill
- principal-mindSkill
- stack-guidesSkill
- structure-lawSkill
- web-3dSkill
- web-qualitySkill
The file
We split this skill into the rules it gives an agent
4 rules. About 0 are common, 2 are distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 14
SQL/NoSQL: parameterized queries / ORM only: Never string-concat or f-string a query.
- Very specific: line 21
Never dangerouslySetInnerHTML (or equivalent) on untrusted content — user text, imported files (Excel/CSV), rendered markdown.
- Very specific: line 49
Every list/detail/mutation endpoint filters by the session's tenant AND checks resource ownership — "authenticated" is not "authorized."
- Distinctive: line 51
Test this class explicitly: user A's token against user B's resource ID must 403/404, never 200.
≈ “Common” is an estimate: at least 1 in 5 of the 213,895 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Security Law
Assume every request is hostile until proven otherwise. Client-sent data is never trusted, including things that "should" be safe (an org id, a role, a price) — trust only what the server derives from the verified session.
1. Injection
- SQL/NoSQL: parameterized queries / ORM only. Never string-concat or f-string a query. No exceptions for "internal" or "admin" endpoints.
- Shell/command execution: never pass user input to a shell; use argument
arrays, never
shell=True/ string-built commands.
2. XSS
- Never
dangerouslySetInnerHTML(or equivalent) on untrusted content — user text, imported files (Excel/CSV), rendered markdown. Sanitize server-side (allowlist tags/attrs) before it's ever stored or rendered. - Set a CSP header; no inline
<script>from user data. - React/Vue/etc. auto-escaping is the default path — don't opt out of it to "fix" a rendering quirk.
3. CSRF & cookie theft
- Session cookies:
HttpOnly+Secure+SameSite=Lax/Strict(see [[auth-law]] for the token model itself). - No state change on GET. Mutations only via POST/PUT/PATCH/DELETE with the session cookie + (for cookie-authed browser clients) a CSRF token or origin check.
4. Transport & replay
- HTTPS + HSTS everywhere; no mixed content.
- Short-lived access tokens, single-use rotating refresh (already specified in [[auth-law]]) — this is what makes a captured token worthless within minutes even without CSRF.
5. Tenant isolation (the worst bug class)
organization_id/tenant_idused in ANY query comes from the verified JWT/session server-side — never from the request body, query string, or a client-supplied header. A user editing a JSON payload must not be able to touch another tenant's row.- Every list/detail/mutation endpoint filters by the session's tenant AND checks resource ownership — "authenticated" is not "authorized."
- Test this class explicitly: user A's token against user B's resource ID must 403/404, never 200.
6. Abuse & brute force
- Rate-limit login, 2FA verify, password reset, and any public form (Redis
SETNX+expiry, see [[stack-guides/redis-celery]]). Lock/backoff after N failures per account AND per IP. - Turnstile/CAPTCHA on public unauthenticated forms (signup, contact, reset).
- Generic errors outward ("invalid credentials"), detailed errors only in server logs — never leak which field was wrong, or stack traces, to the client.
7. Validation at trust boundaries
- Validate/normalize on the server regardless of client-side validation — Zod on the frontend is UX, not security; the backend schema (Pydantic/etc.) is the actual gate.
- File uploads: validate type/size server-side by content, not extension; store outside the webroot; serve through a handler, not direct static path.
Shipping checklist
- No string-built queries anywhere in the diff
- No
dangerouslySetInnerHTML/raw-HTML render on user-sourced content - Every mutating endpoint requires non-GET + authz check on the resource
- Every tenant-scoped query derives
organization_idfrom the session, never the payload - Public forms rate-limited + Turnstile; login/2FA rate-limited per account+IP
- Server-side validation exists independent of client-side validation
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

