From: aaron-congo (@aaron-congo) <noreply+aaron-congo@github.com>
To: aws/aws-advanced-jdbc-wrapper <noreply+aws-aws-advanced-jdbc-wrapper@github.com>
Subject: Re: [aws/aws-advanced-jdbc-wrapper] PR #2244: docs: kms least privilege
Date: Tue, 17 Nov 2026 20:53:13 +0000
Message-ID: <gh-aws-aws-advanced-jdbc-wrapper-2244-rc4605649570@github.com> (raw)
In-Reply-To: <gh-aws-aws-advanced-jdbc-wrapper-2244@github.com>
References: <gh-aws-aws-advanced-jdbc-wrapper-2244@github.com>
(on docs/using-the-jdbc-driver/using-plugins/UsingTheKmsEncryptionPlugin.md:874)
The schema should be transferred to `app_admin` first, not just the tables. In PostgreSQL a schema's owner can drop any table in it, even one owned by another role. So if `app_runtime` created `encrypt` in step 2, it can still run `DROP TABLE encrypt.key_storage CASCADE` and re-create the metadata with its own HMAC key. The same applies to `users` if `app_runtime` owns its schema. On PostgreSQL 15 and later, `public` is owned by whoever owns the database.
Moving the schema first also fixes the "member of both roles" option below. That role can only run `ALTER TABLE ... OWNER TO app_admin` if `app_admin` has `CREATE` on the schema. Otherwise it fails with `permission denied for schema encrypt`.
```suggestion
ALTER SCHEMA encrypt OWNER TO app_admin;
ALTER TABLE encrypt.key_storage OWNER TO app_admin;
ALTER TABLE encrypt.encryption_metadata OWNER TO app_admin;
-- The admin role owns the application table so that the runtime role cannot drop its triggers.
-- Also make sure app_runtime does not own the table's schema or the database.
ALTER TABLE users OWNER TO app_admin;
```
Could the verification step at line 921 also check that `DROP TABLE encrypt.key_storage` fails?