env | grep -i supabase | sed 's/\(KEY=.\{12\}\).*/\1.../' ; echo "---"; which psql curl python3SUPABASE_DB_PASSWORD=<redacted:SUPABASE_DB_PASSWORD> SUPABASE_DB_URL=<redacted:SUPABASE_DB_URL> SUPABASE_URL=https://<ref>.supabase.co SUPABASE_SERVICE_ROLE_KEY=eyJhbGciOiJI... SUPABASE_PROJECT_REF=<ref> SUPABASE_ANON_KEY=eyJhbGciOiJI... --- /usr/bin/psql /usr/bin/curl /usr/bin/python3
cat /etc/os-release | head -3
PRETTY_NAME="Debian GNU/Linux 12 (bookworm)" NAME="Debian GNU/Linux" VERSION_ID="12"
psql "$SUPABASE_DB_URL" -c "select current_user, version();" 2>&1 | head -20
current_user | version --------------+------------------------------------------------------------------------------ postgres | PostgreSQL 17.6 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 15.2.0, 64-bit (1 row)
cat > /tmp/setup.sql <<'SQL'
begin;
create table if not exists public.products (
sku text primary key,
name text not null,
price_cents integer not null,
stock integer not null default 0
);
-- make load idempotent / exact
truncate table public.products;
insert into public.products (sku, name, price_cents, stock) values
('CARI-001', 'Anvil S', 1999, 12),
('CARI-002', 'Anvil M', 2999, 7),
('CARI-003', 'Anvil L', 4999, 3),
('CARI-004', 'Rope 30m', 1250, 40),
('CARI-005', 'Pulley', 780, 0);
commit;
SQL
psql "$SUPABASE_DB_URL" -v ON_ERROR_STOP=1 -f /tmp/setup.sql 2>&1BEGIN CREATE TABLE TRUNCATE TABLE INSERT 0 5 COMMIT
psql "$SUPABASE_DB_URL" -c "select relname, relrowsecurity, relforcerowsecurity from pg_class where oid='public.products'::regclass;" -c "select grantee, privilege_type from information_schema.role_table_grants where table_schema='public' and table_name='products' order by grantee, privilege_type;"
relname | relrowsecurity | relforcerowsecurity
----------+----------------+---------------------
products | f | f
(1 row)
grantee | privilege_type
---------------+----------------
anon | DELETE
anon | INSERT
anon | REFERENCES
anon | SELECT
anon | TRIGGER
anon | TRUNCATE
anon | UPDATE
authenticated | DELETE
authenticated | INSERT
authenticated | REFERENCES
authenticated | SELECT
authenticated | TRIGGER
authenticated | TRUNCATE
authenticated | UPDATE
postgres | DELETE
postgres | INSERT
postgres | REFERENCES
postgres | SELECT
postgres | TRIGGER
postgres | TRUNCATE
postgres | UPDATE
service_role | DELETE
service_role | INSERT
service_role | REFERENCES
service_role | SELECT
service_role | TRIGGER
service_role | TRUNCATE
service_role | UPDATE
(28 rows)
curl -s -o /tmp/pre.json -w "HTTP %{http_code}\n" "$SUPABASE_URL/rest/v1/products?select=*" -H "apikey: $SUPABASE_ANON_KEY" -H "Authorization: Bearer $SUPABASE_ANON_KEY"; cat /tmp/pre.jsonHTTP 200
[{"sku":"CARI-001","name":"Anvil S","price_cents":1999,"stock":12},
{"sku":"CARI-002","name":"Anvil M","price_cents":2999,"stock":7},
{"sku":"CARI-003","name":"Anvil L","price_cents":4999,"stock":3},
{"sku":"CARI-004","name":"Rope 30m","price_cents":1250,"stock":40},
{"sku":"CARI-005","name":"Pulley","price_cents":780,"stock":0}]echo "=== anon attempts INSERT of a junk row ==="; curl -s -o /tmp/w.json -w "HTTP %{http_code}\n" -X POST "$SUPABASE_URL/rest/v1/products" -H "apikey: $SUPABASE_ANON_KEY" -H "Authorization: Bearer $SUPABASE_ANON_KEY" -H "Content-Type: application/json" -H "Prefer: return=representation" -d '{"sku":"ZZ-PENTEST","name":"should not persist","price_cents":1,"stock":1}'; cat /tmp/w.json=== anon attempts INSERT of a junk row ===
HTTP 201
[{"sku":"ZZ-PENTEST","name":"should not persist","price_cents":1,"stock":1}]cat > /tmp/lockdown.sql <<'SQL' begin; -- remove the pentest row so the table holds exactly the five required rows delete from public.products where sku = 'ZZ-PENTEST'; -- enable row level security; without a policy this denies all non-superuser access alter table public.products enable row level security; -- revoke the write privileges that Supabase's default grants handed to the public keys revoke insert, update, delete, truncate, references, trigger on public.products from anon, authenticated; -- the catalog is intentionally public: allow read only grant select on public.products to anon, authenticated; -- explicit read-only policy for both anon and logged-in users drop policy if exists "products are publicly readable" on public.products; create policy "products are publicly readable" on public.products for select to anon, authenticated using (true); commit; SQL psql "$SUPABASE_DB_URL" -v ON_ERROR_STOP=1 -f /tmp/lockdown.sql 2>&1
BEGIN DELETE 1 ALTER TABLE REVOKE GRANT psql:/tmp/lockdown.sql:17: NOTICE: policy "products are publicly readable" for relation "public.products" does not exist, skipping DROP POLICY CREATE POLICY COMMIT
echo "=== READ with ONLY anon key (fresh, no service role) ==="
env -u SUPABASE_SERVICE_ROLE_KEY curl -s -o /tmp/final.json -w "HTTP %{http_code}\n" \
"$SUPABASE_URL/rest/v1/products?select=sku,name,price_cents,stock&order=sku" \
-H "apikey: $SUPABASE_ANON_KEY" -H "Authorization: Bearer $SUPABASE_ANON_KEY"
python3 -m json.tool /tmp/final.json=== READ with ONLY anon key (fresh, no service role) ===
HTTP 200
[
{
"sku": "CARI-001",
"name": "Anvil S",
"price_cents": 1999,
"stock": 12
},
{
"sku": "CARI-002",
"name": "Anvil M",
"price_cents": 2999,
"stock": 7
},
{
"sku": "CARI-003",
"name": "Anvil L",
"price_cents": 4999,
"stock": 3
},
{
"sku": "CARI-004",
"name": "Rope 30m",
"price_cents": 1250,
"stock": 40
},
{
"sku": "CARI-005",
"name": "Pulley",
"price_cents": 780,
"stock": 0
}
]
A="apikey: $SUPABASE_ANON_KEY"; B="Authorization: Bearer $SUPABASE_ANON_KEY"; U="$SUPABASE_URL/rest/v1/products"
echo "-- anon INSERT:"; curl -s -o /tmp/a -w "HTTP %{http_code} " -X POST "$U" -H "$A" -H "$B" -H "Content-Type: application/json" -d '{"sku":"ZZ-2","name":"x","price_cents":1,"stock":1}'; head -c 200 /tmp/a; echo
echo "-- anon UPDATE (price):"; curl -s -o /tmp/b -w "HTTP %{http_code} " -X PATCH "$U?sku=eq.CARI-001" -H "$A" -H "$B" -H "Content-Type: application/json" -d '{"price_cents":1}'; head -c 200 /tmp/b; echo
echo "-- anon DELETE (all):"; curl -s -o /tmp/c -w "HTTP %{http_code} " -X DELETE "$U?sku=like.*" -H "$A" -H "$B"; head -c 200 /tmp/c; echo-- anon INSERT:
HTTP 401 {"code":"42501","details":null,"hint":"Grant the required privileges to the current role with: GRANT INSERT ON public.products TO anon;","message":"permission denied for table products"}
-- anon UPDATE (price):
HTTP 401 {"code":"42501","details":null,"hint":"Grant the required privileges to the current role with: GRANT UPDATE ON public.products TO anon;","message":"permission denied for table products"}
-- anon DELETE (all):
HTTP 401 {"code":"42501","details":null,"hint":"Grant the required privileges to the current role with: GRANT DELETE ON public.products TO anon;","message":"permission denied for table products"}
psql "$SUPABASE_DB_URL" -c "select count(*) as row_count, sum(price_cents) as sum_price, sum(stock) as sum_stock from public.products;" -c "select relrowsecurity as rls_enabled from pg_class where oid='public.products'::regclass;" -c "select grantee, string_agg(privilege_type,',' order by privilege_type) as privs from information_schema.role_table_grants where table_schema='public' and table_name='products' and grantee in ('anon','authenticated') group by grantee;" -c "\d public.products" row_count | sum_price | sum_stock
-----------+-----------+-----------
5 | 12027 | 62
(1 row)
rls_enabled
-------------
t
(1 row)
grantee | privs
---------------+--------
anon | SELECT
authenticated | SELECT
(2 rows)
Table "public.products"
Column | Type | Collation | Nullable | Default
-------------+---------+-----------+----------+---------
sku | text | | not null |
name | text | | not null |
price_cents | integer | | not null |
stock | integer | | not null | 0
Indexes:
"products_pkey" PRIMARY KEY, btree (sku)
Policies:
POLICY "products are publicly readable" FOR SELECT
TO anon,authenticated
USING (true)
8 earlier narration turn(s) are in the raw transcript.
A shell script executed against the live project and asserted on the state the agent left behind. No model judged another model.
Raw transcript · Task definition and verifier · Every attempt