agentleFS
randommoniclerandommonicle/claude-skills/server-side-authority/SKILL.md

server-side-authority

Skill27 starsChanged 18 days agoApache-2.0View on GitHub

Four server-side authority rules for any client-facing backend. Never trust a client-supplied storage path or object id — derive it server-side from the row the caller owns. An RLS self-update policy must scope columns, not just rows, or a user can promote their own role. Every exposed table gets RLS enabled or its grants revoked — a code comment is not a control. Escape all dynamic output in admin surfaces. Triggers when adding or reviewing a route that accepts client-supplied paths/ids, an RLS self-update policy, a new public-schema table, or an admin dashboard render. Does not fire on general security review (the security-review command) or client-side validation UX.

The file

We split this skill into the rules it gives an agent

4 rules. About 0 are common, 4 are distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈4

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Never download, mutate, or serve whatever path or id the client sent, even after checking the caller owns a related record.

    line 15
  2. Distinctive:

    All four are authority confusions: the server letting the client, the row, the comment, or the "trusted" field carry an authority decision …

    line 49
  3. Distinctive:

    A change of permission leaves a record: Every route that can change who may do what (the admin's control, a script, a change by hand) …

    line 56
  4. Distinctive:

    A security decision does not hand-parse a published grammar: After a hand-written parser of a spec (Markdown, HTML, a URL) leaks a second …

    line 57

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Server-side authority

Four rules from an independent security audit's transferable findings, including a role-escalation the audit called its most urgent single change and an IDOR pattern that recurs across repos. Added by committee decision (2-1, dissent recorded in the review record) as one narrow skill rather than four broad ones.

Rule 1 — derive paths and ids server-side from the owned row

Never download, mutate, or serve whatever path or id the client sent, even after checking the caller owns a related record. A photo-analysis route once verified the caller owned the photo row, then downloaded whatever storage_path the request carried — an access-confusion hole. The owned row already knows its own path; read it from there.

Rule 2 — RLS self-update policies scope columns, not just rows

UPDATE ... WHERE auth.uid() = id with no column restriction lets a user set their own role to admin. Restrict the writable columns — a trigger rejecting privileged-column changes, or a column-level REVOKE — not only the row. Row-scoping answers "which records"; it says nothing about "which fields".

Rule 3 — every exposed table: RLS enabled, or grants revoked

A public-schema table is reachable through the API layer regardless of what the code comments assert. "The anon key never touches this table" is a comment, not a control (enforce-invariants-in-build applies). Either enable RLS with real policies or revoke the role grants — and verify from the catalog, not the comment.

Rule 4 — escape all dynamic output in admin surfaces

Escaping only the fields you consider user-supplied leaves the rest as a stored-XSS path into the most privileged session in the system. Names, emails, job titles, and addresses are attacker-writable too. Escape everything dynamic, uniformly, at the render boundary.

What this skill does not do

It does not replace a full security review (the security-review command exists for that), govern client-side validation, or cover the wider audit programme (backups, transfers, seed-data hygiene stay project-side). Four rules, checked at the moments named in the trigger.

Why

All four are authority confusions: the server letting the client, the row, the comment, or the "trusted" field carry an authority decision the server itself must make. Each was found live in a production audit. Evidence: ASH CLAUDE.md independent-audit section (2026-05-22); ICC LESSONS_LEARNED L-003 for the output-escaping class.

Additions from the misses-log sweep (2026-10-22)

  • A change of permission leaves a record. Every route that can change who may do what (the admin's control, a script, a change by hand) writes who, when, from and to, through a trigger so no route escapes it. (ICC L-117.)
  • A security decision does not hand-parse a published grammar. After a hand-written parser of a spec (Markdown, HTML, a URL) leaks a second time, use the reference implementation, and refuse whatever the real consumer could read differently. (AI domain L-117.)

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.