AI agent index: /llms.txtFull content index for AI agents: /llms-full.txt
Business

Per-field audit trails: what "defensible to an auditor" means in a database

Capture enough evidence to explain a sensitive change, including who acted, what committed and where the trail ends.

Two Words/9 October 2026/7 min read/Database audit trails
Review packet diagram showing BEFORE → AFTER, with actor and transaction connected to BEFORE, and approval and committed evidence connected to AFTER.

Suppose a reviewer asks why a customer's risk status changed. You produce the old value, the new value and a pooled database account name. The remaining work is the consequential part: identifying the responsible actor, finding the approval and establishing whether the change committed.

Design the field-level audit trail around that review question. Decide what evidence to capture when the change happens, which system boundary supplies it and who will retrieve and explain it. Keep any claim of defensibility within those boundaries.

Define what the evidence must establish

The Open Worldwide Application Security Project (OWASP) describes a Payment Card Industry Data Security Standard (PCI DSS) audit log as a chronological, independently verifiable trail for reconstructing attributable transactions. Use that as a qualified benchmark: it is a specific audit-log example, not a universal schema or assurance of auditor acceptance.

  • For the change under review, assess five properties:
  • Reconstructable: recover the relevant before-and-after state, sequence and outcome.
  • Attributable: connect the action to trustworthy actor and service context.
  • Scoped: name the workflows, write paths and outcomes covered, including exclusions.
  • Protected: identify who can alter evidence and how interference would be detected.
  • Retrievable: assemble a readable account with its supporting references.

For operations that dispense value, change permissions or move money, OWASP recommends logging the authenticated user, target, action, outcome, request context and business context. It also recommends tamper-evident logs separated from general application logs. This guidance has a defined scope; it does not establish jurisdiction-specific legal duties or a compliance outcome.

One field change, reconstructed

Consider a hypothetical workflow: an authenticated operations analyst changes a customer's risk_status from “pending_review” to “approved”, following a recorded approval. Use this single change to define the evidence contract. The recommendations below are design choices for this example, not an OWASP-prescribed field schema.

Two Words / process
Evidence for the hypothetical change
01
Authority

Authenticated analyst, executing service and approval reference.

02
Changepending_review → approved

Logical customer identity and risk_status field path.

03
Result

Event identity, transaction context and explicit outcome.

Recommended evidence links for this workflow, not a universal schema.

Connect the authority to act, the field transition and the recorded result.
  • Specify what each part of the record means:
  • Identity: a stable event ID, logical entity identifier and field path.
  • Values: typed before-and-after values, or masked references sufficient for the review question.
  • Attribution: trusted business-actor and executing-service context.
  • Time: event time and recorded time, with the source and meaning of each documented.
  • Linkage: transaction ID for the database unit of work and correlation ID for the wider request, where applicable.
  • Outcome: an explicit result, with a reason or approval reference when the workflow requires one.

Preserve null, an absent field and an empty string as distinct states rather than displaying all three as blank. Retain enough schema or vocabulary context to interpret the event after a field rename or a change in allowed statuses. The retrieval test should check meaning, not merely whether an old record still opens.

Avoid copying secrets or sensitive full values into the trail. Prefer masked values or protected references where they answer the review question. Specify who may resolve a reference and test whether a reviewer can understand the change without unnecessary access to the underlying value.

Attribute the action above the pooled account

PostgreSQL distinguishes session_user, normally the identity that initiated the database connection, from current_user, the identity used for permission checks. The latter can change through SET ROLE or SECURITY DEFINER execution; superusers can also change session authorization. These database-role identities do not necessarily identify an application's end user.

For the hypothetical risk-status change, require attribution to the authenticated analyst as well as the executing service. Capture the business actor at the application boundary, carry that context through a controlled path and retain the database role as supporting evidence. This separates business accountability from database permission context.

Ask the implementation team to demonstrate where actor identity originates and which components may set or replace it. Reject a caller-supplied user name as a substitute for authenticated context. For service-initiated work, identify the service explicitly and preserve any initiating human context separately, without inventing a human actor.

Choose the capture boundary deliberately

Evaluate application events, database triggers and change data capture (CDC) against the same evidence contract. For this workflow, require both the business justification and the committed outcome. If those come from different boundaries, make their linkage an acceptance condition.

Two Words / comparison
Capture-boundary decisions
01
Application eventsRequire business context

Capture trusted actor and approval references. Test bypass paths and distinguish attempts from commits.

02
Database triggersRequire write-path coverage

Test covered writes, actor-context transfer, rollback and privileged bypasses.

03
PostgreSQL logical decodingRequire downstream reconciliation

Link changes to business context. Test export gaps, delays and recovery.

Selection criteria and test obligations, not guarantees supplied by a mechanism.

Compare mechanisms by what you require them to supply and what remains to be tested.

PostgreSQL documents logical decoding as extracting persistent table changes into a coherent format. A logical replication slot streams changes in their origin-server order. That establishes a capture capability, not the completeness, access controls or independent protection of a downstream audit store.

Join the evidence using logical identity. PostgreSQL advises using a primary key rather than ctid, which changes when a row is updated or moved by VACUUM FULL. Keep historical values and actor context separately; the primary key identifies the logical row, not its history.

For the committed-change trail, consider writing the business change and audit record in the same transaction. Set the acceptance condition explicitly: both persist on commit, and neither survives as a committed change after rollback. Test audit-write failure as well as business-write failure. If failed attempts must be retained, give them a separate recording path and outcome label rather than relying on the record subject to rollback.

For asynchronous export, distinguish local commit from downstream availability. Require stable event identity, a documented export position, reconciliation and a recovery procedure. Test delays, duplicate delivery and missing events. Assign responsibility for investigating gaps and deciding when the exported evidence is sufficiently complete for the review in hand.

Bound the protection claim

For the sensitive operations it specifies, OWASP recommends tamper-evident logs separated from general application logs. Translate that objective into an authority review: identify who can append records, alter existing evidence, control exports and administer the systems used to verify them.

Do not accept append-only application privileges as proof against database-owner modification. Assess privileged access separately. If the design uses hashes, require independently protected checkpoints and a demonstration of detection under the privileged-access scenarios in scope. Include control of those checkpoints in the assessment.

Keep the assurance statement narrow. Do not treat a matching hash as proof that the recorded actor, value or approval was truthful, or as proof of compliance. State the assumptions tested and the access paths outside the protection boundary instead of accepting an unqualified “immutable” label.

Test the trail as a review packet

  • Before accepting the design, run the hypothetical risk-status change through these tests:
  • Commit: retrieve the exact transition with actor, transaction and approval context.
  • Rollback: confirm that the proposed transition is not presented as committed.
  • Failed attempt: retrieve the failure through its designated path without implying a state change.
  • Export delay or gap: demonstrate detection, investigation ownership, reconciliation and recovery.
  • Sensitive values: produce a useful account under the approved masking or reference policy.
  • Schema change: interpret an older event correctly after the field definition changes.
Two Words / process
From request to readable evidence
01
Locate

Find the event by logical entity, field and relevant time.

02
Connect

Join actor, service, outcome, transaction, correlation and approval evidence.

03
Explain

Present the transition, value meanings, coverage and protection limits.

Name an accountable owner who can retrieve and explain the packet.

Include retrieval and explanation in the acceptance test.

Have that owner produce the packet through the documented retrieval process. Require a readable explanation, not raw database output that leaves business meaning to the reviewer. Use any failure to decide what needs funding or ownership: missing context, incomplete capture, weak protection or an unusable retrieval path. Resolve those gaps before extending the design to more fields.

Could your accountable owner explain one sensitive change from the evidence alone?

Keep reading

All posts
Start here

Some of our best projects started with a two-line email.

Most of our work starts with a conversation. No deck required.

Start yours