Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cada14bb94 |
No files matched your search
@@ -0,0 +1,69 @@
|
||||
#!/usr/bin/env bash
|
||||
# Runs on the probe VM inside the VPC. Env: DBHOST, DBPORT, ROOTPW. CA at ./ca.crt
|
||||
set -u
|
||||
export PGSSLMODE=verify-full PGSSLROOTCERT=$PWD/ca.crt PGHOST=$DBHOST PGPORT=$DBPORT PGCONNECT_TIMEOUT=10
|
||||
MIGPW=$(openssl rand -hex 16); APPPW=$(openssl rand -hex 16)
|
||||
A=00000000-0000-0000-0000-00000000000a; B=00000000-0000-0000-0000-00000000000b
|
||||
q() { local user=$1 pw=$2 db=$3; shift 3; PGPASSWORD=$pw psql -X -v ON_ERROR_STOP=0 -U "$user" -d "$db" "$@" 2>&1; }
|
||||
|
||||
echo "== 0. DNS + TLS"
|
||||
getent hosts "$DBHOST"
|
||||
q akmadmin "$ROOTPW" defaultdb -Atc "select 'tls='||ssl||' '||version from pg_stat_ssl where pid=pg_backend_pid()"
|
||||
PGSSLMODE=verify-full PGPASSWORD=$ROOTPW psql -X -h "$(getent hosts "$DBHOST" | awk '{print $1}')" -U akmadmin -d defaultdb -Atc 'select 1' 2>&1 | sed 's/^/by-IP (expect cert mismatch): /'
|
||||
|
||||
echo "-- server cert names"
|
||||
openssl s_client -starttls postgres -connect "$DBHOST:$DBPORT" </dev/null 2>/dev/null | openssl x509 -noout -subject -ext subjectAltName 2>&1
|
||||
echo "== 1. platform settings / akmadmin attributes"
|
||||
q akmadmin "$ROOTPW" defaultdb -Atc "select version()" -c "show password_encryption" -c "show max_connections" -c "show superuser_reserved_connections" -c "show reserved_connections" \
|
||||
-c "select rolname, rolsuper, rolcreaterole, rolcreatedb, rolbypassrls from pg_roles where rolname = current_user" \
|
||||
-c "show createrole_self_grant"
|
||||
|
||||
echo "== 2. bootstrap as akmadmin"
|
||||
q akmadmin "$ROOTPW" defaultdb -c "create role hapi_migrator login password '$MIGPW'" -c "create role hapi_app login password '$APPPW'" \
|
||||
-c "select rolname, rolpassword like 'SCRAM%' as scram from pg_authid where rolname like 'hapi_%'" \
|
||||
-c "create database hapi owner hapi_migrator"
|
||||
echo "-- retry create database after granting SET on hapi_migrator to akmadmin"
|
||||
q akmadmin "$ROOTPW" defaultdb -c "grant hapi_migrator to akmadmin with set true, inherit false" -c "create database hapi owner hapi_migrator"
|
||||
echo "-- db-level grants as owner hapi_migrator"
|
||||
q hapi_migrator "$MIGPW" hapi -c "revoke all on database hapi from public" -c "grant connect on database hapi to hapi_app" -c "revoke create on schema public from public"
|
||||
echo "-- audit: per-role log_statement"
|
||||
q akmadmin "$ROOTPW" defaultdb -c "alter role hapi_migrator set log_statement = 'all'" -c "alter role hapi_migrator set log_min_duration_statement = 0"
|
||||
echo "-- can akmadmin grant BYPASSRLS?"
|
||||
q akmadmin "$ROOTPW" defaultdb -c "create role probe_bypass bypassrls" -c "drop role if exists probe_bypass"
|
||||
|
||||
echo "== 3. schema + RLS as hapi_migrator"
|
||||
q hapi_migrator "$MIGPW" hapi -c "create schema finance" -c "grant usage on schema finance to hapi_app" \
|
||||
-c "alter default privileges in schema finance grant select, insert, update, delete on tables to hapi_app" \
|
||||
-c "create table finance.note (id uuid primary key default uuidv7(), owner_id uuid not null, body text)" \
|
||||
-c "alter table finance.note enable row level security" -c "alter table finance.note force row level security" \
|
||||
-c "create policy own on finance.note using (owner_id = nullif(current_setting('hapi.principal_id', true), '')::uuid) with check (owner_id = nullif(current_setting('hapi.principal_id', true), '')::uuid)"
|
||||
echo "-- owner under FORCE, no principal set: insert (expect RLS violation)"
|
||||
q hapi_migrator "$MIGPW" hapi -c "insert into finance.note(owner_id, body) values ('$A','a1')"
|
||||
echo "-- owner seeds via per-row principal"
|
||||
q hapi_migrator "$MIGPW" hapi -c "begin" -c "select set_config('hapi.principal_id','$A',true)" -c "insert into finance.note(owner_id, body) values ('$A','a1'),('$A','a2')" -c "commit" \
|
||||
-c "begin" -c "select set_config('hapi.principal_id','$B',true)" -c "insert into finance.note(owner_id, body) values ('$B','b1')" -c "commit"
|
||||
echo "-- owner, no principal: count (FORCE => 0)"
|
||||
q hapi_migrator "$MIGPW" hapi -Atc "select count(*) from finance.note"
|
||||
echo "-- owner temporarily NO FORCE (data-repair path)"
|
||||
q hapi_migrator "$MIGPW" hapi -Atc "begin" -c "alter table finance.note no force row level security" -c "select count(*) from finance.note" -c "rollback"
|
||||
|
||||
echo "== 4. hapi_app"
|
||||
echo "-- DDL attempts (expect permission denied x2)"
|
||||
q hapi_app "$APPPW" hapi -c "create table finance.evil(x int)" -c "create table public.evil(x int)"
|
||||
echo "-- no principal set: count (expect 0)"
|
||||
q hapi_app "$APPPW" hapi -Atc "select count(*) from finance.note"
|
||||
echo "-- SET LOCAL A in txn, then after commit on same connection (expect 2 then 0)"
|
||||
q hapi_app "$APPPW" hapi -Atc "begin" -c "set local hapi.principal_id = '$A'" -c "select count(*) from finance.note" -c "commit" -c "select count(*) from finance.note" -c "select '['||current_setting('hapi.principal_id', true)||']'"
|
||||
echo "-- set_config(..., true) as A (expect 2)"
|
||||
q hapi_app "$APPPW" hapi -Atc "begin" -c "select set_config('hapi.principal_id','$A',true)" -c "select count(*) from finance.note" -c "commit"
|
||||
echo "-- WITH CHECK: as A insert B-owned row (expect RLS violation)"
|
||||
q hapi_app "$APPPW" hapi -c "begin" -c "set local hapi.principal_id = '$A'" -c "insert into finance.note(owner_id, body) values ('$B','x')" -c "rollback"
|
||||
echo "-- as A update B rows (expect UPDATE 0)"
|
||||
q hapi_app "$APPPW" hapi -c "begin" -c "set local hapi.principal_id = '$A'" -c "update finance.note set body='pwn' where owner_id='$B'" -c "rollback"
|
||||
echo "-- escalation attempts (expect all denied)"
|
||||
q hapi_app "$APPPW" hapi -c "set role hapi_migrator" -c "alter table finance.note no force row level security" -c "alter table finance.note disable row level security" -c "drop policy own on finance.note"
|
||||
echo "-- spoof: leaked hapi_app creds can set any principal (expect 1 = B's row visible)"
|
||||
q hapi_app "$APPPW" hapi -Atc "set hapi.principal_id = '$B'" -c "select count(*) from finance.note"
|
||||
echo "-- connections in use"
|
||||
q akmadmin "$ROOTPW" defaultdb -Atc "select backend_type, usename, count(*) from pg_stat_activity group by 1,2 order by 1,2"
|
||||
echo DONE
|
||||
@@ -0,0 +1,75 @@
|
||||
terraform {
|
||||
required_providers {
|
||||
linode = { source = "linode/linode", version = "~> 4.10" }
|
||||
}
|
||||
}
|
||||
provider "linode" {}
|
||||
|
||||
resource "linode_vpc" "v" {
|
||||
label = "hapi-verify-64"
|
||||
region = "us-iad"
|
||||
}
|
||||
resource "linode_vpc_subnet" "s" {
|
||||
vpc_id = linode_vpc.v.id
|
||||
label = "hapi-verify-64"
|
||||
ipv4 = "10.64.0.0/24"
|
||||
}
|
||||
|
||||
resource "linode_database_postgresql_v2" "db" {
|
||||
label = "hapi-verify-64"
|
||||
engine_id = "postgresql/18"
|
||||
region = "us-iad"
|
||||
type = "g6-standard-1"
|
||||
cluster_size = 1
|
||||
allow_list = ["10.64.0.0/24"]
|
||||
engine_config_pg_password_encryption = "scram-sha-256"
|
||||
private_network = {
|
||||
vpc_id = linode_vpc.v.id
|
||||
subnet_id = linode_vpc_subnet.s.id
|
||||
public_access = false
|
||||
}
|
||||
}
|
||||
|
||||
resource "linode_instance" "probe" {
|
||||
label = "hapi-verify-64"
|
||||
region = "us-iad"
|
||||
type = "g6-nanode-1"
|
||||
image = "linode/debian13"
|
||||
authorized_keys = [chomp(file("${path.module}/id_ed25519.pub"))]
|
||||
linode_interfaces {
|
||||
firewall_id = linode_firewall.fw.id
|
||||
public {
|
||||
ipv4 {
|
||||
addresses {
|
||||
address = "auto"
|
||||
primary = true
|
||||
}
|
||||
}
|
||||
}
|
||||
default_route {
|
||||
ipv4 = true
|
||||
ipv6 = true
|
||||
}
|
||||
}
|
||||
linode_interfaces {
|
||||
firewall_id = linode_firewall.fw.id
|
||||
vpc { subnet_id = linode_vpc_subnet.s.id }
|
||||
}
|
||||
}
|
||||
|
||||
output "probe_ip" { value = linode_instance.probe.ip_address }
|
||||
output "db_host" { value = linode_database_postgresql_v2.db.host_primary }
|
||||
output "db_port" { value = linode_database_postgresql_v2.db.port }
|
||||
|
||||
resource "linode_firewall" "fw" {
|
||||
label = "hapi-verify-64"
|
||||
inbound_policy = "DROP"
|
||||
outbound_policy = "ACCEPT"
|
||||
inbound {
|
||||
label = "ssh"
|
||||
action = "ACCEPT"
|
||||
protocol = "TCP"
|
||||
ports = "22"
|
||||
ipv4 = ["0.0.0.0/0"]
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,223 @@
|
||||
13:05:53 up
|
||||
13:05:58 up
|
||||
13:06:03 up
|
||||
13:06:08 up
|
||||
13:06:13 up
|
||||
13:06:18 up
|
||||
13:06:23 up
|
||||
13:06:28 up
|
||||
13:06:33 up
|
||||
13:06:38 up
|
||||
13:06:44 up
|
||||
13:06:49 up
|
||||
13:06:54 up
|
||||
13:06:59 up
|
||||
13:07:04 up
|
||||
13:07:09 up
|
||||
13:07:14 up
|
||||
13:07:19 up
|
||||
13:07:24 up
|
||||
13:07:29 up
|
||||
13:07:34 up
|
||||
13:07:39 up
|
||||
13:07:45 up
|
||||
13:07:50 up
|
||||
13:07:55 up
|
||||
13:08:00 up
|
||||
13:08:05 up
|
||||
13:08:10 up
|
||||
13:08:15 up
|
||||
13:08:20 up
|
||||
13:08:25 up
|
||||
13:08:30 up
|
||||
13:08:35 up
|
||||
13:08:40 up
|
||||
13:08:46 up
|
||||
13:08:51 up
|
||||
13:08:56 up
|
||||
13:09:01 up
|
||||
13:09:06 up
|
||||
13:09:11 up
|
||||
13:09:16 up
|
||||
13:09:21 up
|
||||
13:09:26 up
|
||||
13:09:31 up
|
||||
13:09:36 up
|
||||
13:09:41 up
|
||||
13:09:46 up
|
||||
13:09:52 up
|
||||
13:09:57 up
|
||||
13:10:02 up
|
||||
13:10:07 up
|
||||
13:10:12 up
|
||||
13:10:17 up
|
||||
13:10:22 up
|
||||
13:10:27 up
|
||||
13:10:32 up
|
||||
13:10:37 up
|
||||
13:10:43 up
|
||||
13:10:48 up
|
||||
13:10:53 up
|
||||
13:10:58 up
|
||||
13:11:03 up
|
||||
13:11:08 up
|
||||
13:11:13 up
|
||||
13:11:18 up
|
||||
13:11:23 up
|
||||
13:11:28 up
|
||||
13:11:33 up
|
||||
13:11:38 up
|
||||
13:11:43 up
|
||||
13:11:49 up
|
||||
13:11:54 up
|
||||
13:11:59 up
|
||||
13:12:04 up
|
||||
13:12:09 up
|
||||
13:12:14 up
|
||||
13:12:19 up
|
||||
13:12:24 up
|
||||
13:12:29 up
|
||||
13:12:34 up
|
||||
13:12:39 up
|
||||
13:12:44 up
|
||||
13:12:49 up
|
||||
13:12:55 up
|
||||
13:13:00 up
|
||||
13:13:05 up
|
||||
13:13:10 up
|
||||
13:13:15 up
|
||||
13:13:20 up
|
||||
13:13:25 up
|
||||
13:13:30 up
|
||||
13:13:35 up
|
||||
13:13:40 up
|
||||
13:13:45 up
|
||||
13:13:51 up
|
||||
13:13:56 up
|
||||
13:14:01 up
|
||||
13:14:06 up
|
||||
13:14:11 up
|
||||
13:14:16 up
|
||||
13:14:21 up
|
||||
13:14:26 up
|
||||
13:14:31 up
|
||||
13:14:36 up
|
||||
13:14:41 up
|
||||
13:14:46 up
|
||||
13:14:52 up
|
||||
13:14:57 up
|
||||
13:15:02 up
|
||||
13:15:07 up
|
||||
13:15:12 up
|
||||
13:15:17 up
|
||||
13:15:22 up
|
||||
13:15:27 up
|
||||
13:15:32 up
|
||||
13:15:37 up
|
||||
13:15:43 up
|
||||
13:15:48 up
|
||||
13:15:53 up
|
||||
13:15:58 up
|
||||
13:16:03 up
|
||||
13:16:08 up
|
||||
13:16:13 up
|
||||
13:16:18 up
|
||||
13:16:23 up
|
||||
13:16:28 up
|
||||
13:16:34 up
|
||||
13:16:39 up
|
||||
13:16:44 up
|
||||
13:16:49 up
|
||||
13:16:54 up
|
||||
13:16:59 up
|
||||
13:17:04 up
|
||||
13:17:09 up
|
||||
13:17:14 up
|
||||
13:17:19 up
|
||||
13:17:24 up
|
||||
13:17:29 up
|
||||
13:17:35 up
|
||||
13:17:40 up
|
||||
13:17:45 up
|
||||
13:17:50 up
|
||||
13:17:55 up
|
||||
13:18:00 up
|
||||
13:18:05 up
|
||||
13:18:10 up
|
||||
13:18:15 up
|
||||
13:18:20 up
|
||||
13:18:25 up
|
||||
13:18:30 up
|
||||
13:18:36 up
|
||||
13:18:41 up
|
||||
13:18:46 up
|
||||
13:18:51 up
|
||||
13:18:56 up
|
||||
13:19:01 up
|
||||
13:19:06 up
|
||||
13:19:11 up
|
||||
13:19:16 up
|
||||
13:19:21 up
|
||||
13:19:26 up
|
||||
13:19:32 up
|
||||
13:19:37 up
|
||||
13:19:42 up
|
||||
13:19:47 up
|
||||
13:19:52 up
|
||||
13:19:57 up
|
||||
13:20:02 up
|
||||
13:20:07 up
|
||||
13:20:12 up
|
||||
13:20:17 up
|
||||
13:20:22 up
|
||||
13:20:27 up
|
||||
13:20:33 up
|
||||
13:20:38 up
|
||||
13:20:43 up
|
||||
13:20:48 up
|
||||
13:20:53 up
|
||||
13:20:58 up
|
||||
13:21:03 up
|
||||
13:21:08 up
|
||||
13:21:13 up
|
||||
13:21:18 up
|
||||
13:21:23 up
|
||||
13:21:28 up
|
||||
13:21:34 up
|
||||
13:21:39 up
|
||||
13:21:44 up
|
||||
13:21:49 up
|
||||
13:21:54 up
|
||||
13:21:59 up
|
||||
13:22:04 up
|
||||
13:22:09 up
|
||||
13:22:14 up
|
||||
13:22:19 up
|
||||
13:22:24 up
|
||||
13:22:29 up
|
||||
13:22:35 up
|
||||
13:22:40 up
|
||||
13:22:45 up
|
||||
13:22:50 up
|
||||
13:22:55 up
|
||||
13:23:00 up
|
||||
13:23:05 up
|
||||
13:23:10 up
|
||||
13:23:15 up
|
||||
13:23:20 up
|
||||
13:23:26 up
|
||||
13:23:31 up
|
||||
13:23:36 up
|
||||
13:23:41 up
|
||||
13:23:46 up
|
||||
13:23:51 up
|
||||
13:23:56 up
|
||||
13:24:01 up
|
||||
13:24:06 up
|
||||
13:24:11 up
|
||||
13:24:16 up
|
||||
13:24:21 up
|
||||
13:24:27 up
|
||||
13:24:32 up
|
||||
13:24:37 up
|
||||
13:24:42 up
|
||||
@@ -0,0 +1,121 @@
|
||||
== 0. DNS + TLS
|
||||
tls=true TLSv1.3
|
||||
by-IP (expect cert mismatch): 1
|
||||
-- server cert names
|
||||
subject=ST=service, O=a6555122-1463-44bd-bdcc-b8dd91653408, CN=a568915-1
|
||||
X509v3 Subject Alternative Name:
|
||||
IP Address:10.64.0.32, DNS:10.64.0.32, DNS:2600:3c05::2000:adff:fe30:f6eb, DNS:private-a568915-akamai-prod-1130531-default.g2a.akamaidb.net, IP Address:172.234.33.213, DNS:*.g2a.akamaidb.net, DNS:public-n-a568915-1.g2a.akamaidb.net, DNS:public-replica-a568915-akamai-prod-1130531-default.g2a.akamaidb.net, DNS:172.234.33.213, DNS:fda7:a938:5bfe:5fa6:0:5f7:bc5a:cb01, DNS:private-replica-a568915-akamai-prod-1130531-default.g2a.akamaidb.net, DNS:a568915-akamai-prod-1130531-default.g2a.akamaidb.net, IP Address:2600:3C05:0:0:2000:ADFF:FE30:F6EB, DNS:replica-a568915-akamai-prod-1130531-default.g2a.akamaidb.net, DNS:n-a568915-1.g2a.akamaidb.net, IP Address:FDA7:A938:5BFE:5FA6:0:5F7:BC5A:CB01, DNS:public-a568915-akamai-prod-1130531-default.g2a.akamaidb.net
|
||||
== 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
|
||||
50
|
||||
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
|
||||
-- db-level grants as owner hapi_migrator
|
||||
REVOKE
|
||||
GRANT
|
||||
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
|
||||
autovacuum launcher||1
|
||||
background writer||1
|
||||
checkpointer||1
|
||||
client backend|akmadmin|1
|
||||
client backend|postgres|1
|
||||
io worker||3
|
||||
logical replication launcher|postgres|1
|
||||
pg_cron launcher|postgres|1
|
||||
pg_failover_slots worker|postgres|1
|
||||
TimescaleDB Background Worker Launcher|postgres|1
|
||||
walsender|_aiven|1
|
||||
walwriter||1
|
||||
DONE
|
||||
@@ -0,0 +1,109 @@
|
||||
== 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
|
||||
Reference in new issue
Block a user