agentleFS
kaandgnshkaandgnsh/Claude-Blue/skills/database-security/db-audit-logging/SKILL.md

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.

The file

Files
SKILL.md

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

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.