PS Product SecurityKnowledge Base

๐Ÿ—„๏ธ Database Activity Monitoring, Immutable Logging, and Privileged Session Management

Intro: Strong database security is not only about encryption and backups. It is also about being able to answer three uncomfortable questions fast: who touched sensitive data, who used privileged access, and can that evidence still be trusted after an incident? This page translates those questions into a control design for Product Security, platform engineering, and audit-friendly operations.

What this page includes

  • a control model for database activity monitoring (DAM)
  • immutable logging patterns for cloud and self-managed environments
  • privileged session management patterns for DBAs, SREs, and break-glass operators
  • a short vendor map across open-source-friendly and commercial options
  • evidence examples and rollout guidance

The operating problem

A modern engineering stack usually has all of these failure modes at once:

  • database administrators can run dangerous statements directly in production;
  • application service accounts have broader rights than developers think;
  • logs can be changed, truncated, or deleted by the same people they are meant to monitor;
  • incident responders cannot easily prove whether data was queried, changed, exported, or dropped;
  • access paths go around the expected bastion or approval workflow.

That is why this domain should be designed as three linked controls, not three unrelated products.

flowchart LR A[Privileged Access Request] --> B[Privileged Session Manager] B --> C[Database / Admin Endpoint] C --> D[Database Activity Monitoring] C --> E[Native Audit Logs] D --> F[Central Log / SIEM] E --> F F --> G[Immutable Storage / WORM] G --> H[Investigation / Audit Evidence]

1) Database activity monitoring

Definition

Database activity monitoring is the set of controls used to observe, record, and alert on:

  • login and authentication events;
  • privileged actions;
  • schema changes;
  • reads against sensitive tables or columns;
  • bulk export or unusual query patterns;
  • policy violations such as access from unexpected paths, users, or time windows.

What DAM should answer

Question Why it matters
Who connected? establishes identity and path of access
What object did they touch? table, view, procedure, schema, admin API
What kind of action happened? read, write, grant, drop, config change, export
Was the action expected? ties to approval, ticket, maintenance window, change record
Can the evidence be trusted? prevents attackers or insiders from erasing their own trail

Event classes worth collecting

Class Examples
Authentication login success/failure, MFA bypass, password auth use, cert auth use
Authorization grants, role changes, privilege escalation, break-glass role assumption
Sensitive data access reads from PII/payment/security tables, admin secrets tables, audit tables
Administrative changes schema changes, parameter changes, replication changes, audit config changes
Data destruction / exfiltration clues bulk SELECT, dump/export tools, DROP/TRUNCATE, disable binlog/audit

Design choices

  1. Use native audit where available for reliable baseline coverage.
  2. Add DAM analytics when native logs are too noisy, incomplete, or fragmented across many data stores.
  3. Separate collection from storage so the same admin cannot both perform the action and erase the record.
  4. Alert on high-value actions instead of trying to alert on every query.

2) Immutable logging

Why immutable logging matters

A perfect audit trail that an admin can delete is not really an audit trail.

Immutable logging means that once important security and audit evidence is written, it cannot be silently modified or deleted during the retention period. In practice, this usually means:

  • WORM or object-lock storage for exported audit logs;
  • append-only pipelines from audit source to central storage;
  • separate write and admin permissions for log buckets and archives;
  • retention and legal hold patterns for incident or compliance evidence.

Common architecture

flowchart LR A[DB Native Audit / DAM Sensor] --> B[Log Forwarder / Event Bus] B --> C[SIEM / Search Layer] B --> D[Immutable Archive] D --> E[Retention / Legal Hold / Object Lock] C --> F[Detections / Dashboards] D --> G[Forensics / External Audit]

Practical control patterns

Pattern What it does
S3 Object Lock / Azure immutable blob WORM-style retention for exported logs and snapshots
Separate security archive account keeps storage outside the immediate blast radius of operators
Dual path storage searchable SIEM + immutable raw archive
Legal hold / incident hold prevents retention jobs from deleting active-case evidence
Digest / integrity validation proves log sequences were not altered in transit

Baseline requirements

  • privileged users who manage the database must not own the immutable archive;
  • lifecycle and deletion rules must be reviewed separately from runtime DB admin permissions;
  • raw log export must include timestamp, actor, source, object, action, and result where possible;
  • time synchronization must be enforced.

3) Privileged session management

Definition

Privileged session management is the control layer that governs how privileged humans reach production systems, how those sessions are approved and recorded, and how misuse is interrupted.

The goals

  • eliminate shared root/DBA passwords where possible;
  • force access through a managed path;
  • require approval, ticket, or change reference for sensitive access;
  • record session activity;
  • allow rapid termination of dangerous sessions;
  • reduce standing privilege with JIT and time-bound access.

What should be protected

Access type Typical examples
OS / shell SSH to DB host, node shell, container host access
Database admin mysql, psql, redis-cli, kafka-configs, rabbitmqctl
Kubernetes admin kubectl exec, port-forward, secret reads, CRD edits
Cloud admin console sessions, emergency IAM assumption, managed DB admin APIs

Strong pattern

flowchart LR A[Engineer / DBA] --> B[Approval / Ticket / JIT Grant] B --> C[Privileged Session Broker] C --> D[Target Host / DB / Cluster] C --> E[Session Recording] E --> F[Immutable Archive] D --> G[Native Audit / DAM] G --> H[SIEM / Investigation]

Control set by maturity

Minimum viable control set

  • native DB audit enabled on crown-jewel systems;
  • admin access only through named accounts;
  • central log export enabled;
  • backup and audit storage separated from routine admin accounts;
  • alerts on role changes, schema changes, and destructive statements.

Stronger production-grade set

  • JIT privileged access;
  • session recording for SSH / Kubernetes / DB admin access;
  • immutable archive for audit exports;
  • independent security-admin ownership of archive policies;
  • detections for sensitive-table reads and unusual exports;
  • quarterly review of privileged access paths and service accounts.

High-assurance set

  • PAM or access-proxy enforced for all production admin access;
  • command or query recording where feasible;
  • dual-control for destructive maintenance in crown-jewel environments;
  • privileged session termination capability;
  • dedicated security archive account with WORM retention;
  • integration with incident and audit workflows.

Native controls vs overlay platforms

Layer Native examples Overlay examples
Database audit MySQL Enterprise Audit, MariaDB Audit Plugin, PostgreSQL pgaudit, cloud DB audit logs Guardium, Imperva, Oracle AVDF, DataSunrise
Session control bastions, cloud session logs, SSH CA + forced commands CyberArk, Delinea, BeyondTrust, Teleport
Immutable storage S3 Object Lock, Azure immutable blob archive vaults, log lake with external retention governance

Product / solution map

Open-source-friendly building blocks

Solution Where it fits Notes
pgAudit PostgreSQL audit coverage strong native option for PostgreSQL estates
MariaDB Audit Plugin / server_audit MariaDB audit trail practical for auth, query, and admin events
Teleport session recording / access proxy records SSH, Kubernetes, and DB sessions; can encrypt recordings
OpenSearch / ELK + WORM storage searchable log layer useful only if archive immutability is designed separately

Commercial platforms often used here

Product Primary fit Notes
IBM Guardium DAM, data security, compliance reporting broad enterprise DAM and monitoring coverage
Imperva database security / DAM long-standing DB security and monitoring focus
CyberArk privileged session monitoring / recording strong PAM + session monitoring and tamper-resistant recording story
Delinea / BeyondTrust PAM / session governance strong for admin path governance and least privilege

Example findings this control set should catch

Example 1 โ€” destructive DBA session without independent evidence

A senior DBA used a shared administrative credential to connect directly to a production database host and ran emergency maintenance that included truncating staging tables and changing audit configuration. The organization retained shell logs locally on the same host, but they were rotated and no immutable export existed. The incident could not be reconstructed with sufficient confidence.

What failed

  • shared or weakly governed privileged path;
  • no independent session record;
  • no immutable audit archive.

Example 2 โ€” bulk sensitive data read looked like a normal query

A support engineer used a privileged read role to export a large volume of customer records for troubleshooting. The query technically succeeded within policy, but the access volume and object combination should have triggered review. No DAM policy existed for sensitive-table bulk reads.

What failed

  • access path may have been legitimate, but monitoring policy was too shallow;
  • no content-aware or table-aware alerting.

Evidence auditors or internal reviewers will ask for

  • database audit policy screenshots or config;
  • sample raw audit records for privileged actions;
  • privilege matrix for DB admins, SREs, and service accounts;
  • proof that log archive storage is immutable / WORM-protected;
  • PAM or proxy configuration showing session recording and retention;
  • sample session playback or audit export;
  • periodic privileged-access review results;
  • alert runbooks for destructive SQL, config changes, and bulk export.

Anti-patterns to avoid

  1. shared DBA accounts
  2. audit logs stored only on the system being administered
  3. searchable SIEM with no immutable raw archive
  4. assuming cloud-native DB logs alone are enough without sensitive-object policies
  5. privileged break-glass accounts with no recording path
  6. same team owns database, archive bucket, and retention policies

Practical rollout sequence

  1. identify crown-jewel databases and admin paths;
  2. enable or improve native audit on those systems;
  3. route audit exports to centralized storage;
  4. add immutable archive controls;
  5. move human privileged access through an access broker or managed bastion;
  6. enable session recording for high-risk paths;
  7. add detections for destructive actions, role changes, and sensitive-table bulk reads;
  8. test evidence retrieval in a tabletop.