db-audit-logging
Skill0 starsChanged 11 days agoMITView on GitHub
Configure and use database audit logging for security — PostgreSQL pgaudit, MySQL/MariaDB audit plugins, SQL Server Audit, Oracle Unified Auditing, cloud database audit (RDS, Azure SQL, Cloud SQL), MongoDB auditing — capturing logins, privilege changes, schema changes and sensitive-table access without crippling performance. Use when enabling database monitoring, meeting audit requirements, or preparing to investigate database access.
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-exfiltration-investigationSkill
- db-hardeningSkill
- db-privilege-reviewSkill
- data-classificationSkill
- data-discoverySkill
- The first 60 shown.
The file
Files
Database Audit Logging
What to capture
Successful and failed logins (with client host/app), privilege and role changes (GRANT/REVOKE/CREATE USER), schema changes (DDL), configuration changes, access to sensitive tables (SELECT on PII/financial tables), bulk exports (COPY TO, bcp, SELECT INTO OUTFILE), admin/superuser sessions. Avoid logging full statement text for high-volume app queries unless needed (cost, and statements can contain PII).
Engines
PostgreSQL (pgaudit):
-- postgresql.conf: shared_preload_libraries = 'pgaudit'
ALTER SYSTEM SET pgaudit.log = 'role, ddl, write'; -- session-level classes
ALTER SYSTEM SET log_connections = on; ALTER SYSTEM SET log_disconnections = on;
-- object-level auditing for a sensitive table via an audit role
CREATE ROLE auditor NOLOGIN; ALTER SYSTEM SET pgaudit.role = 'auditor';
GRANT SELECT ON customers TO auditor; -- SELECTs on customers now audited
SELECT pg_reload_conf();SQL Server:
CREATE SERVER AUDIT SecAudit TO FILE (FILEPATH = 'D:\Audit\'); ALTER SERVER AUDIT SecAudit WITH (STATE = ON);
CREATE SERVER AUDIT SPECIFICATION SecSpec FOR SERVER AUDIT SecAudit
ADD (FAILED_LOGIN_GROUP), ADD (SUCCESSFUL_LOGIN_GROUP), ADD (SERVER_ROLE_MEMBER_CHANGE_GROUP), ADD (DATABASE_PERMISSION_CHANGE_GROUP)
WITH (STATE = ON);MySQL: Enterprise Audit, Percona Audit Log plugin, or MariaDB server_audit (server_audit_events='CONNECT,QUERY_DDL,QUERY_DCL'). Oracle: Unified Auditing policies (CREATE AUDIT POLICY ... ; AUDIT POLICY ...). MongoDB Enterprise/Atlas: auditLog with filters.
Cloud: RDS/Aurora parameter groups (pgaudit / MariaDB audit plugin) + export to CloudWatch; Azure SQL Auditing to Log Analytics; Cloud SQL cloudsql.enable_pgaudit + Data Access logs; Database Activity Streams (Aurora) for tamper-resistant streams.
Integrity
Send to SIEM promptly; DBAs should not be able to alter audit trails without detection (separate storage, alert on audit disable events — e.g., SQL Server AUDIT_CHANGE_GROUP, PostgreSQL config changes).
Related skills
db-exfiltration-investigation, db-privilege-review, log-source-onboarding
References
- pgaudit: https://github.com/pgaudit/pgaudit
- SQL Server Audit: https://learn.microsoft.com/en-us/sql/relational-databases/security/auditing/sql-server-audit-database-engine
- Oracle Unified Auditing: https://docs.oracle.com/en/database/oracle/oracle-database/19/dbseg/introduction-to-auditing.html
- MariaDB Audit Plugin: https://mariadb.com/kb/en/mariadb-audit-plugin/
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.

