== 0. DNS + TLS
10.64.0.16      private-a568914-akamai-prod-1130531-default.g2a.akamaidb.net
tls=true TLSv1.3
by-IP (expect cert mismatch): 1
== 1. platform settings / akmadmin attributes
PostgreSQL 18.7 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 15.3.1 20260722 (Red Hat 15.3.1-1), 64-bit
scram-sha-256
25
3
0
akmadmin|f|t|t|t
inherit,set
== 2. bootstrap as akmadmin
CREATE ROLE
CREATE ROLE
ERROR:  permission denied for table pg_authid
CREATE DATABASE
-- retry create database after granting SET on hapi_migrator to akmadmin
GRANT ROLE
ERROR:  database "hapi" already exists
WARNING:  no privileges could be revoked for "hapi"
REVOKE
WARNING:  no privileges were granted for "hapi"
GRANT
WARNING:  no privileges could be revoked for "public"
REVOKE
-- audit: per-role log_statement
ERROR:  permission denied to set parameter "log_statement"
ERROR:  permission denied to set parameter "log_min_duration_statement"
-- can akmadmin grant BYPASSRLS?
CREATE ROLE
DROP ROLE
== 3. schema + RLS as hapi_migrator
CREATE SCHEMA
GRANT
ALTER DEFAULT PRIVILEGES
CREATE TABLE
ALTER TABLE
ALTER TABLE
CREATE POLICY
-- owner under FORCE, no principal set: insert (expect RLS violation)
ERROR:  new row violates row-level security policy for table "note"
-- owner seeds via per-row principal
BEGIN
              set_config              
--------------------------------------
 00000000-0000-0000-0000-00000000000a
(1 row)

INSERT 0 2
COMMIT
BEGIN
              set_config              
--------------------------------------
 00000000-0000-0000-0000-00000000000b
(1 row)

INSERT 0 1
COMMIT
-- owner, no principal: count (FORCE => 0)
0
-- owner temporarily NO FORCE (data-repair path)
BEGIN
ALTER TABLE
3
ROLLBACK
== 4. hapi_app
-- DDL attempts (expect permission denied x2)
ERROR:  permission denied for schema finance
LINE 1: create table finance.evil(x int)
                     ^
ERROR:  permission denied for schema public
LINE 1: create table public.evil(x int)
                     ^
-- no principal set: count (expect 0)
0
-- SET LOCAL A in txn, then after commit on same connection (expect 2 then 0)
BEGIN
SET
2
COMMIT
0
[]
-- set_config(..., true) as A (expect 2)
BEGIN
00000000-0000-0000-0000-00000000000a
2
COMMIT
-- WITH CHECK: as A insert B-owned row (expect RLS violation)
BEGIN
SET
ERROR:  new row violates row-level security policy for table "note"
ROLLBACK
-- as A update B rows (expect UPDATE 0)
BEGIN
SET
UPDATE 0
ROLLBACK
-- escalation attempts (expect all denied)
ERROR:  permission denied to set role "hapi_migrator"
ERROR:  must be owner of table note
ERROR:  must be owner of table note
ERROR:  must be owner of relation note
-- spoof: leaked hapi_app creds can set any principal (expect 1 = B's row visible)
SET
1
-- connections in use
14
DONE
