{"slug": "catching-column-level-privilege-escalation-non-invoker-views-and-bundled-secrets", "title": "Catching Column-Level Privilege Escalation, Non-Invoker Views, and Bundled Secrets in Supabase (v0.7.0)", "summary": "A developer released supabase-rls-check v0.7.0, an MIT-licensed Python tool with 159 passing tests that detects column-level privilege escalation in Supabase apps, where table-level UPDATE grants let authenticated users modify sensitive columns like role, is_admin, and credits despite row-level ownership policies. The release adds offline detection of this pattern and non-invoker views in raw SQL migration files, plus a new scan-bundle command and MCP server support for scanning compiled frontend bundles for leaked keys.", "body_md": "The most common Row Level Security bug I see in AI-generated Supabase apps (Lovable, Bolt, v0, Cursor) passes every basic \"is RLS enabled?\" check.\n\nThe developer enables RLS on `public.profiles` and adds an ownership policy for updates:\n\n```\nCREATE POLICY \"users_update_own_profile\" ON public.profiles\n  FOR UPDATE TO authenticated\n  USING ((SELECT auth.uid()) = user_id);\n```\n\nLater, they add billing or role columns to `public.profiles`: `role`, `is_admin`, `plan`, `credits`, or `balance`. Because PostgreSQL grants table-level `UPDATE` to `authenticated` by default on new Supabase tables, and `USING ((SELECT auth.uid()) = user_id)` only restricts which row is targeted, any signed-in user can open DevTools and run:\n\n```\nPATCH /rest/v1/profiles?user_id=eq.<their-uid>\nContent-Type: application/json\n\n{\"role\": \"admin\", \"is_admin\": true, \"credits\": 999999}\n```\n\nPostgREST updates the columns directly.\n\nI released `supabase-rls-check` v0.7.0 (MIT, Python 3.11+, 159 automated tests passing) to catch this pattern alongside non-invoker views and leaked keys inside compiled frontend bundles.\n\nGitHub: [https://github.com/Tthanh2k6/supabase-rls-check](https://github.com/Tthanh2k6/supabase-rls-check)\n\nPyPI: [https://pypi.org/project/supabase-rls-check/](https://pypi.org/project/supabase-rls-check/)\n\n`column_update_escalation` (Catalog + Static SQL DDL)\nRule #21 in `check.sql` (`column_update_escalation`, High severity) inspects `pg_catalog.pg_policies` and `pg_catalog.pg_attribute` in one read-only query. It flags any `PERMISSIVE` policy for `UPDATE` or `ALL` in `public` granted to `anon`, `authenticated`, or `PUBLIC` when:\n\n`role`, `is_admin`, `plan`, `tier`, `credits`, `balance`, `subscription_status`, or `org_id`.` UPDATE` privileges on those columns (`has_table_privilege` or `has_column_privilege`).` WITH CHECK` expression does not reference and guard the column name.\nThe `basis` field lists the exact updatable columns (for example, `credits, is_admin, role`).\n\nTo fix it without breaking profile edits, revoke table-level `UPDATE` and grant column-level `UPDATE` only on safe user-editable columns (or move billing and role state to a separate server-managed table):\n\n```\nREVOKE UPDATE ON public.profiles FROM PUBLIC, anon, authenticated;\nGRANT UPDATE (display_name, avatar_url) ON public.profiles TO authenticated;\n```\n\nIn v0.7.0, the static SQL parser (`scan_sql`) also detects `column_update_escalation` directly on raw migration `.sql` files before you apply them to a database, tracking `CREATE TABLE`, `ALTER TABLE ... ADD COLUMN`, `REVOKE UPDATE`, and column-specific `GRANT UPDATE (col1, col2)`.\n\n`view_not_invoker` Across Catalogs and Raw Migrations\nIn PostgreSQL, `CREATE VIEW public.user_summaries AS ...` defaults to `security_invoker = false`. When queried through PostgREST (`/rest/v1/user_summaries`), the view executes with the permissions of the view owner (`postgres`), bypassing RLS on the underlying tables.\n\n`check.sql` already checked live catalogs for views in `public` missing `security_invoker=true` in `pg_class.reloptions`. In v0.7.0, `scan_sql` brings the same `view_not_invoker` detection to offline `.sql` migration files and folders. It flags `CREATE [OR REPLACE] VIEW` statements in `public` unless the view is created with `WITH (security_invoker = true)` (or `on` / `1`) or followed by:\n\n```\nALTER VIEW public.user_summaries SET (security_invoker = true);\n```\n\nMaterialized views are skipped by this check and covered separately under `matview_api_exposed` and `auth_users_exposed`.\n\n`scan-bundle`)\nEarlier versions included `scan-env` for project source directories (which skips `dist/`, `build/`, and `web-build/`). When auditing a deployed or pre-release build artifact where source files are already bundled into `dist/assets/index-a1b2c3.js` or static `.html` files, you want to scan the compiled output directly.\n\nv0.7.0 adds `scan-bundle` to both the CLI and the read-only stdio MCP server:\n\n```\nsupabase-rls-check scan-bundle ./dist --out bundlescan.json\n```\n\n`scan-bundle` walks build output, source files (`.js`, `.mjs`, `.cjs`, `.jsx`, `.ts`, `.tsx`, `.html`, `.htm`, `.vue`, `.svelte`), `.env*`, `app.json`, and `eas.json` up to 5 MB per file with zero network calls. It detects:\n\n`service_role_in_client_code` and `public_env_service_role` (Critical): JWTs whose payload decodes to `\"role\": \"service_role\"` (ignoring safe `anon` JWTs) and `sb_secret_*` keys.`db_url_in_client_code` (Critical): `postgres://` or `postgresql://` connection strings containing a literal password (ignoring placeholders such as `${DB_PASSWORD}`).` public_env_secret_key` (High): client-prefixed variables (`NEXT_PUBLIC_`, `VITE_`, `EXPO_PUBLIC_`, `REACT_APP_`, `PUBLIC_`, `NUXT_PUBLIC_`) carrying secret prefixes (` sk_live_`, `rk_live_`, `sk-proj-`, `sk-ant-`) or secret variable names.\nEvery match is masked before printing (`first6…last4`) so secrets never leak into terminal logs or CI artifacts.\n\n```\npipx install supabase-rls-check\n# or run via uvx:\nuvx supabase-rls-check --version\n```\n\nTo inspect the full explanation and remediation SQL for the new column escalation rule:\n\n```\nsupabase-rls-check explain column_update_escalation\n```\n\n", "url": "https://wpnews.pro/news/catching-column-level-privilege-escalation-non-invoker-views-and-bundled-secrets", "canonical_source": "https://dev.to/tthanh2k6/catching-column-level-privilege-escalation-non-invoker-views-and-bundled-secrets-in-supabase-paf", "published_at": "2026-11-29 06:04:43+00:00", "updated_at": "2026-11-29 06:12:50.666841+00:00", "lang": "en", "topics": ["ai-tools", "developer-tools", "ai-agents", "ai-safety"], "entities": ["supabase-rls-check", "Supabase", "PostgREST", "PostgreSQL", "Lovable", "Bolt", "v0", "Cursor"], "also_reported_by": [], "takeaway": "Table-level UPDATE grants on Supabase tables let any authenticated user PATCH sensitive columns like role or credits even under row-ownership RLS policies; revoke table UPDATE and grant column-level UPDATE only on safe fields such as display_name and avatar_url.", "recommendation": null, "alternates": {"html": "https://wpnews.pro/news/catching-column-level-privilege-escalation-non-invoker-views-and-bundled-secrets", "markdown": "https://wpnews.pro/news/catching-column-level-privilege-escalation-non-invoker-views-and-bundled-secrets.md", "text": "https://wpnews.pro/news/catching-column-level-privilege-escalation-non-invoker-views-and-bundled-secrets.txt", "jsonld": "https://wpnews.pro/news/catching-column-level-privilege-escalation-non-invoker-views-and-bundled-secrets.jsonld"}}