Skip to content

Fix admin bootstrap security and search injection vulnerabilities#15

Merged
criptogus merged 2 commits into
mainfrom
claude/improve-security-LKXUg
May 17, 2026
Merged

Fix admin bootstrap security and search injection vulnerabilities#15
criptogus merged 2 commits into
mainfrom
claude/improve-security-LKXUg

Conversation

@criptogus
Copy link
Copy Markdown
Owner

What does this PR add?

Fixes critical security vulnerabilities in admin account management and search functionality, plus removes accidentally committed environment files.

Type

  • New package (skill / playbook / soul / guardrail)
  • Improvement to an existing package (bumped version)
  • Platform code or docs

Changes

Security Fixes

  1. Admin Bootstrap Privilege Escalation (claimAdminBootstrap)

    • Switched from user-scoped Supabase client to service-role client for admin existence check
    • User-scoped client is blinded by RLS policies (roles read self), allowing any authenticated user to claim admin if none exists
    • Service-role client provides true global invariant check, preventing multiple admins from being created
  2. Search Filter Injection (listAccounts)

    • Added sanitization of user-provided search terms before interpolation into PostgREST .or() filter
    • Strips metacharacters (%, ,, (, ), *) that could be exploited for filter injection attacks
    • Only applies filter if sanitized term is non-empty
  3. Removed Committed Secrets

    • Deleted .env, .env.development, and .env.production files containing Supabase and Stripe API keys
    • Updated .gitignore to prevent future commits of environment files
    • Kept .env.example for reference

Notes for reviewers

  • The admin bootstrap fix addresses a critical authorization bypass where RLS policies inadvertently allowed privilege escalation
  • Search sanitization is conservative but necessary; the regex removes all PostgREST filter syntax characters
  • Environment files were accidentally committed with real credentials and should be rotated immediately in production

https://claude.ai/code/session_01TSEwzP9iRBZiLkmCV2RGWx

claude added 2 commits May 17, 2026 23:48
- claimAdminBootstrap now checks/inserts the admin role via the
  service-role client. The user-scoped client is blinded by the
  `roles read self` RLS policy and reported 0 admins to any non-admin
  caller, allowing privilege escalation after an admin already existed.
- Strip PostgREST filter metacharacters from the admin account search
  term to prevent filter injection via the interpolated `.or()` clause.

https://claude.ai/code/session_01TSEwzP9iRBZiLkmCV2RGWx
Untrack .env, .env.development and .env.production and ignore local
environment files going forward. .env.example remains tracked as the
documented template. The committed keys were publishable (Supabase anon,
Stripe publishable) and not secrets, but env files should not be in VCS.

https://claude.ai/code/session_01TSEwzP9iRBZiLkmCV2RGWx
@criptogus criptogus merged commit 462f537 into main May 17, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants