Skip to content

security: lock down functions, hide poster fingerprints, spatial_ref_sys read-only - #13

Merged
ralyodio merged 1 commit into
masterfrom
security/secdef-lockdown
Oct 26, 2026
Merged

ralyodio merged 1 commit into
masterfrom
security/secdef-lockdown

Conversation

@ralyodio

Copy link
Copy Markdown
Contributor

From the 2026-10-26 fleet SECURITY DEFINER audit (icemap-app-supabase-db).

3 exposed SECURITY DEFINER -> 0. These are the three PostGIS st_estimatedextent overloads in public, which were executable by anon and read planner statistics of any table.

The app talks to Supabase only with the service role (lib/supabase.ts refuses to start without it), so the rest is defence in depth. Today the anon key is not shipped to browsers.

  • every app function (create_post, record_post, get_or_create_anonymous_id, cleanup_*...) was executable by anon/authenticated. They are now service_role only.
  • spatial_ref_sys has no RLS, and anon/authenticated could INSERT/UPDATE/DELETE it, which would break every geography transform. It is now read-only for them.
  • posts.fingerprint and comments.fingerprint/anonymous_id were readable through the public SELECT policies. They link one poster's reports together, so anon/authenticated now get column grants without them.
  • default privileges no longer grant EXECUTE on new functions, and trigger functions are revoked.

Applied by hand after a schema backup and a rolled-back dry run, followed by notify pgrst. Live checks:

  • anon posts?select=fingerprint -> 42501
  • anon posts?select=id,summary -> 200
  • anon rpc/can_user_post -> permission denied
  • anon DELETE spatial_ref_sys -> 42501
  • icemap.app/api/posts (bounds) 200, /api/posts/nearby 200, /api/me 200. The test anonymous id was deleted.

There are no app code changes.

🤖 Generated with Claude Code

…anon, lock spatial_ref_sys

Applied to prod by hand.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

ThreatCrush Security Scan

3 finding(s)

HIGH/CRITICAL: 1 | LOW: 2

Severity Rule Location
HIGH js-ssrf-outbound-request apps/web/src/app/api/media/[...path]/route.ts:28
LOW secret-generic-credential packages/supabase/supabase/config.toml:271
LOW secret-generic-credential packages/supabase/supabase/config.toml:303

Snippets are redacted; ThreatCrush never prints matched credential material.

@ralyodio
ralyodio merged commit 36558af into master Oct 26, 2026
6 checks passed
@ralyodio
ralyodio deleted the security/secdef-lockdown branch October 26, 2026 21:02
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.

1 participant