Skip to content

security: quick-win hardening fixes - #242

Merged
ChristopherRotnes merged 1 commit into
masterfrom
security/quick-wins
May 15, 2026
Merged

ChristopherRotnes merged 1 commit into
masterfrom
security/quick-wins

Conversation

@ChristopherRotnes

@ChristopherRotnes ChristopherRotnes commented May 15, 2026 •

Copy link
Copy Markdown
Owner

Summary

All four changes are low-risk and non-breaking. The DB migration has already been applied to the live project.

Test plan

  • Verify POST /rest/v1/rpc/handle_new_user returns 404/403 for unauthenticated requests
  • Verify new user sign-up still creates a profile row correctly
  • Verify Supabase security advisor no longer flags the three functions
  • Verify app loads without CSP violations in browser console (check both g10 and g100)
  • Verify session save, template update, and template exercise replace flows still work
  • Confirm git add . does not pick up app/api/local.settings.json

🤖 Generated with Claude Code

- Add app/api/local.settings.json to .gitignore to prevent accidental
  secret exposure via git add
- Tighten CSP: scope connect-src to specific Supabase project subdomain
  and add frame-ancestors 'none' directive
- DB migration: revoke EXECUTE on handle_new_user() from anon and
  authenticated roles (was callable via REST RPC with SECURITY DEFINER)
- DB migration: set search_path = public on save_session, update_session,
  and replace_template_exercises to prevent schema injection

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@supabase

supabase Bot commented May 15, 2026 •

Copy link
Copy Markdown

Updates to Preview Branch (security/quick-wins) ↗︎

Deployments Status Updated
Database ✅ Fri, 15 May 2026 20:44:00 UTC
Services ✅ Fri, 15 May 2026 20:44:00 UTC
APIs ✅ Fri, 15 May 2026 20:44:00 UTC

Tasks are run on every commit but only new migration files are pushed.
Close and reopen this PR if you want to apply changes from existing seed or migration files.

Tasks Status Updated
Configurations ✅ Fri, 15 May 2026 20:44:12 UTC
Migrations ❌ Fri, 15 May 2026 20:44:15 UTC
Seeding ⏸️ Fri, 15 May 2026 20:43:45 UTC
Edge Functions ⏸️ Fri, 15 May 2026 20:43:45 UTC

❌ Branch Error • Fri, 15 May 2026 20:44:16 UTC

ERROR: relation "session_templates" does not exist (SQLSTATE 42P01)
At statement: 0
-- Sprint 3: add template_type to session_templates
-- Nullable, no default — existing rows keep null (treated as unset in UI).
ALTER TABLE session_templates ADD COLUMN template_type text

View logs for this Workflow Run ↗︎.
Learn more about Supabase for Git ↗︎.

@github-actions

Copy link
Copy Markdown

Azure Static Web Apps: Your stage site is ready! Visit it here: https://white-island-090dfd003-242.westeurope.7.azurestaticapps.net

@ChristopherRotnes
ChristopherRotnes merged commit c15894b into master May 15, 2026
2 of 3 checks passed
@ChristopherRotnes
ChristopherRotnes deleted the security/quick-wins branch May 15, 2026 20:51
ChristopherRotnes added a commit that referenced this pull request May 15, 2026
 #236 #242 #247)

- Add 20260101000000_baseline_schema.sql: full idempotent snapshot of all 15
  tables, functions, trigger, grants and RLS policies so Supabase preview
  branches and local db reset work without errors (issue #247)
- Add 20260515_rec_cache_ownership.sql: owner-scoped write policies for
  recommendation_cache, adding written_by column (issue #235; already live)
- Make 20260514 delta idempotent: ADD COLUMN IF NOT EXISTS
- Update CHANGELOG.md with [1.5.7] security + infra entries
- Update CLAUDE.md: sportySync JWT auth, rec_cache written_by, prompt XML
  tags, Supabase preview pitfall (#247)
- Update README.md: SPORTY_SYNC_API_KEY now health-endpoint-only

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
ChristopherRotnes added a commit that referenced this pull request May 15, 2026
* chore: add Supabase baseline migration + security docs (issues #228 #235 #236 #242 #247)

- Add 20260101000000_baseline_schema.sql: full idempotent snapshot of all 15
  tables, functions, trigger, grants and RLS policies so Supabase preview
  branches and local db reset work without errors (issue #247)
- Add 20260515_rec_cache_ownership.sql: owner-scoped write policies for
  recommendation_cache, adding written_by column (issue #235; already live)
- Make 20260514 delta idempotent: ADD COLUMN IF NOT EXISTS
- Update CHANGELOG.md with [1.5.7] security + infra entries
- Update CLAUDE.md: sportySync JWT auth, rec_cache written_by, prompt XML
  tags, Supabase preview pitfall (#247)
- Update README.md: SPORTY_SYNC_API_KEY now health-endpoint-only

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix: use DROP+CREATE instead of CREATE POLICY IF NOT EXISTS (PG15 compat)

CREATE POLICY IF NOT EXISTS is PostgreSQL 17+ only. Supabase preview branches
run PG15/16. Replace every occurrence in the baseline and rec_cache_ownership
migrations with DROP POLICY IF EXISTS + CREATE POLICY (idempotent on PG15+).
Same fix for CREATE TRIGGER IF NOT EXISTS.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix: remove UTF-8 BOM from baseline migration (PostgreSQL rejects it)

* chore: retrigger CI after Supabase GitHub App removal

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>

This branch was previously deployed

1 inactive deployment
preview — 19d6c4a2 Deployed May 15, 2026 by ChristopherRotnes via Build and deploy #4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment