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.
In this repository273 other files it gives its agents.
- ad-attack-path-analysisSkill
- adcs-security-reviewSkill
- ad-privileged-access-reviewSkill
- dcsync-detectionSkill
- gpo-security-reviewSkill
- kerberos-attack-detectionSkill
- agent-tool-permission-reviewSkill
- ai-incident-responseSkill
- llm-gateway-controlsSkill
- llm-security-evaluationSkill
- mcp-server-security-reviewSkill
- model-artifact-securitySkill
- prompt-injection-reviewSkill
- rag-security-reviewSkill
- api-abuse-detectionSkill
- api-authorization-testingSkill
- api-inventorySkill
- api-schema-securitySkill
- dast-baselineSkill
- sast-triageSkill
- sca-dependency-riskSkill
- secure-code-reviewSkill
- security-requirementsSkill
- threat-modelingSkill
- asset-criticality-tieringSkill
- asset-inventory-reconciliationSkill
- external-attack-surface-reviewSkill
- shadow-it-discoverySkill
- aws-credential-compromiseSkill
- aws-iam-reviewSkill
- aws-org-guardrailsSkill
- cloudtrail-investigationSkill
- guardduty-triageSkill
- s3-exposure-reviewSkill
- azure-activity-investigationSkill
- azure-rbac-reviewSkill
- conditional-access-reviewSkill
- entra-audit-investigationSkill
- entra-signin-investigationSkill
- backup-assuranceSkill
- critical-service-mappingSkill
- ransomware-recoverySkill
- recovery-exerciseSkill
- cloud-exposure-reviewSkill
- cloud-incident-responseSkill
- cloud-logging-baselineSkill
- cloud-posture-assessmentSkill
- audit-evidence-packageSkill
- continuous-control-monitoringSkill
- control-mappingSkill
- control-testing-samplingSkill
- container-incidentSkill
- dockerfile-hardeningSkill
- image-scanningSkill
- runtime-detection-falcoSkill
- db-audit-loggingSkill
- db-exfiltration-investigationSkill
- db-hardeningSkill
- data-classificationSkill
- data-discoverySkill
- The first 60 shown.
The file
Files
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
| Finding | Risk |
App account with superuser/sysadmin/db_owner/DDL | SQL injection → full DB/host compromise (e.g. xp_cmdshell, COPY ... PROGRAM) |
Accounts with host % (MySQL) or 0.0.0.0/0 in pg_hba | Login from anywhere |
FILE/pg_read_server_files/pg_execute_server_program grants | Server file access / command execution |
| Shared DBA logins | No accountability |
| PUBLIC grants on sensitive objects | Everyone can read |
| Password auth for humans instead of IAM/Kerberos/SSO | Credential 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
- PostgreSQL privileges: https://www.postgresql.org/docs/current/ddl-priv.html
- PostgreSQL predefined roles: https://www.postgresql.org/docs/current/predefined-roles.html
- SQL Server security best practices: https://learn.microsoft.com/en-us/sql/relational-databases/security/sql-server-security-best-practices
- CIS Benchmarks (databases): https://www.cisecurity.org/cis-benchmarks
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
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.

