agentleFS
kaandgnshkaandgnsh/Claude-Blue/skills/database-security/db-privilege-review/SKILL.md

db-privilege-review

Skill0 starsChanged 11 days agoMITView on GitHub

Review database privileges — superuser/sysadmin holders, application accounts with DDL or excessive rights, PUBLIC grants, shared DBA accounts, cross-database access, password vs. IAM/Kerberos authentication — for PostgreSQL, SQL Server, MySQL, Oracle and cloud databases. Use for database access audits, least-privilege remediation, or after suspected database compromise.

The file

Files
SKILL.md

Database Privilege Review

Queries

PostgreSQL:

SELECT rolname, rolsuper, rolcreaterole, rolcreatedb, rolcanlogin, rolbypassrls, rolvaliduntil FROM pg_roles ORDER BY rolsuper DESC;
SELECT grantee, table_schema, table_name, privilege_type FROM information_schema.role_table_grants
 WHERE grantee NOT IN ('postgres') AND table_schema NOT IN ('pg_catalog','information_schema') ORDER BY grantee;
SELECT r.rolname, m.rolname AS member_of FROM pg_auth_members am JOIN pg_roles r ON r.oid = am.member JOIN pg_roles m ON m.oid = am.roleid;

SQL Server:

SELECT p.name, p.type_desc, r.name AS server_role FROM sys.server_role_members rm
 JOIN sys.server_principals r ON rm.role_principal_id = r.principal_id JOIN sys.server_principals p ON rm.member_principal_id = p.principal_id;
SELECT dp.name, dp.type_desc, rp.name AS db_role FROM sys.database_role_members drm
 JOIN sys.database_principals rp ON drm.role_principal_id = rp.principal_id JOIN sys.database_principals dp ON drm.member_principal_id = dp.principal_id;
SELECT * FROM sys.database_permissions WHERE grantee_principal_id = DATABASE_PRINCIPAL_ID('public') AND state_desc = 'GRANT';

MySQL:

SELECT user, host, Super_priv, Grant_priv, File_priv, Process_priv FROM mysql.user;
SHOW GRANTS FOR 'app'@'%';

Findings

FindingRisk
App account with superuser/sysadmin/db_owner/DDLSQL injection → full DB/host compromise (e.g. xp_cmdshell, COPY ... PROGRAM)
Accounts with host % (MySQL) or 0.0.0.0/0 in pg_hbaLogin from anywhere
FILE/pg_read_server_files/pg_execute_server_program grantsServer file access / command execution
Shared DBA loginsNo accountability
PUBLIC grants on sensitive objectsEveryone can read
Password auth for humans instead of IAM/Kerberos/SSOCredential sprawl
Default/sample accounts (sa enabled, scott)Easy targets

Fix

Per-application least-privilege roles (DML on specific schemas only), separate migration role for DDL used only by CI, named DBA accounts via PAM/JIT, IAM database authentication (RDS IAM auth, Entra auth for Azure SQL, Cloud SQL IAM), revoke PUBLIC, row-level security for multi-tenant data.

Related skills

db-hardening, db-audit-logging, privileged-access-review, access-certification

References

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.