security: harden remote-access stack (pentest remediation R1-R4)
App layer (R1): bind frps NewProxy to token-owned subdomain (anti-hijack), default-deny unknown webhook ops, HMAC-verify stripe-stub billing webhook, enforce bandwidth quota kill-switch (Ping op), least-privilege table grants (migrations 0002/0003), GOTRUE_PASSWORD_MIN_LENGTH=12. Infra/net (R2): unpublish internal host ports (kong/pooler/analytics/frps-dash), read-only docker-socket-proxy for vector (no host breakout), on-demand-TLS allow-list authorizer, edge-block machine-only webhooks, no-new-privileges on custom containers. Secrets (R3): rotate Postgres password (all roles) + frps dashboard; replace predictable supavisor defaults; secrets externalized to gitignored .env. Med/Low (R4): security response headers (HSTS/XCTO/XFO/Referrer/Permissions/COOP), restrict frp proxy_type to http (no open relay), disable destructive redis commands, tighten frps.toml perms. No secrets committed; rotated values live only in gitignored .env files.
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
-- 0003: least-privilege table grants (A4/W3 hardening).
|
||||
-- Supabase's default privileges grant ALL on public tables to anon &
|
||||
-- authenticated. RLS gates DML, but TRUNCATE bypasses RLS and unauthenticated
|
||||
-- (anon) should have no direct table rights at all. Reduce to the minimum the
|
||||
-- app actually needs; service_role (which bypasses RLS) keeps full access.
|
||||
BEGIN;
|
||||
|
||||
REVOKE ALL ON public.tunnels FROM anon, authenticated;
|
||||
REVOKE ALL ON public.subscriptions FROM anon, authenticated;
|
||||
REVOKE ALL ON public.usage_samples FROM anon, authenticated;
|
||||
REVOKE ALL ON public.users_profile FROM anon, authenticated;
|
||||
|
||||
-- Authenticated users get read-only dashboard access (still gated by RLS
|
||||
-- owner policies). users_profile also needs UPDATE (it has an owner policy).
|
||||
GRANT SELECT ON public.tunnels TO authenticated;
|
||||
GRANT SELECT ON public.subscriptions TO authenticated;
|
||||
GRANT SELECT, UPDATE ON public.users_profile TO authenticated;
|
||||
-- usage_samples: service_role only (no anon/authenticated access).
|
||||
|
||||
COMMIT;
|
||||
Reference in New Issue
Block a user