portfolio-security-check
Skill0 starsChanged 3 days agoMITView on GitHub
Security checklist for this portfolio's Supabase RLS, admin auth, secrets and link handling. Use when reviewing or making changes to migrations, auth, the admin panel, environment variables, or anything that renders user-supplied URLs or Markdown.
- Reads credentials
In this repository10 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- .github/copilot-instructions.mdCopilot instructions
- add-page-sectionSkill
- database-changeSkill
- verify-changesSkill
- add-page-sectionSkill
- database-changeSkill
- portfolio-security-checkSkill
- verify-changesSkill
The file
Files
Portfolio security check
Threat model
- Anyone on the internet can call Supabase directly with the public
publishable key. RLS is the only real guard. Client-side checks, such as
the
/adminbeforeLoadgate or hidden buttons, are only for user experience. - There is a single admin. Admin rights come only from a row in
public.user_roles.
Checklist
Database (drizzle/migrations/*.sql)
- Every table has
ENABLE ROW LEVEL SECURITY. - Write policies (
INSERT/UPDATE/DELETE/ALL) requirepublic.has_role(auth.uid(), 'admin')in bothUSINGandWITH CHECK. anonhas no grant beyondSELECT, andSELECTonly on tables the public site shows.- Nothing reintroduces an automatic admin grant, such as a trigger on
auth.users. SECURITY DEFINERfunctions setsearch_path = public, andanoncannot execute them (see0005_security_hardening.sql).public.user_rolesstays readable only by its own user and is never writable from the client.
Secrets and environment
- No service-role or secret key in code, in
.env, or in anyVITE_*variable.client.server.tsreadsSUPABASE_SERVICE_ROLE_KEYfrom the server environment only, and only server code may import it. .envcontains onlySUPABASE_*/VITE_SUPABASE_*URL, project id andsb_publishable_key.
Server functions (src/data/portfolio.functions.ts)
- They use the publishable-key
publicClient(), so RLS still applies. - They select explicit columns, so no private column leaks if one is added later.
- Errors are generic and do not pass on Postgres messages.
Admin and auth
- Login error messages stay generic ("Sign-in failed"), so they do not reveal whether an account exists.
- There is no public sign-up path in the UI.
- Admin routes stay
ssr: falsewithrobots: noindex.
Rendering
- User-supplied links are
https://only. The admin forms validate them, and every render passes them throughisSafeUrl()from@/lib/utils, plus the DB CHECK constraint onprojects. - External links use
target="_blank" rel="noreferrer", as in the existing code (noreferreralso impliesnoopener). - Markdown is rendered with
react-markdownwithout raw HTML. NodangerouslySetInnerHTML.
Headers and dependencies
src/lib/security-headers.tsstill sets the CSP and frame protection. A new external origin is added to the narrowest directive (font-src,connect-src, …), never as a wildcard indefault-srcorscript-src.bun auditshows no new high or critical advisories in runtime dependencies. Advisories in dev-only tools (eslint, drizzle-kit, the Vite dev server) are lower priority.
Report
List each item that fails, with file and line and a concrete fix. If something can only be checked in the Supabase or Lovable dashboard (for example "sign-ups disabled" or "leaked password protection on"), say so instead of assuming.
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.

