Cybersecurity Engineering Handbook / Chapter 21
Secure Observability, Logging, and Audit Architecture
Design security telemetry that supports detection, investigation, audit evidence, and accountability without exposing sensitive data.
Preparing audio…
Audio edition
Secure Observability, Logging, and Audit Architecture
At 09:12, the refund queue stops moving. The application is healthy, the
consumer was disabled through an administrative API, and recent ledger rows
have changed. Responders find three records: an API access line containing a
service account name, a configuration message saying updated successfully,
and a database trace that includes a customer’s payment details. None can
answer whether the same actor made both changes. The third has made the
incident worse by copying protected data into a less protected system.
Recovery now depends on facts the platform did—or did not—record before the attack. Who obtained administrative authority? Which policy and approval permitted the call? What tenant and resource were affected? Did the change reach the queue before or after the ledger write? Can responders trust the timestamps and records when the production administrator is suspect?
Security telemetry is the path by which an action becomes evidence. That path must preserve identity, decision, scope, sequence, and integrity while refusing to collect the secrets and payloads it is meant to protect.
Decide what the system must remember
Begin with actions whose absence would prevent detection or leave a consequential decision unaccountable. For the refund path, the catalog includes authentication and session changes; authorization allows and denies; role, policy, feature-flag, and emergency-access changes; sensitive reads, exports, deletions, and restores; secret retrieval and rotation; artifact promotion, deployment, and rollback; edge blocks and rate-limit decisions; and the administrative calls that can stop or redirect work.
The catalog must also follow work after a request becomes asynchronous. A queue consumer should record the identity and tenant context it accepted, the action it attempted, and its bounded outcome. Otherwise a clean API record can lead into an anonymous background write.
AI-enabled and automated systems add decisions, not an excuse to retain every input. Record retrieval sources, tool calls, model or policy identifiers, refusals, approval decisions, and the human or workload authority behind an action. Store prompt or response content only under a deliberate data-handling rule. The fact needed for accountability is often that a classified source was consulted or a tool was approved, not a copy of the protected content.
Give every event in the catalog an owner and a declared use: immediate detection, later investigation, audit evidence, or safe debugging. One event may serve several uses, but each use changes its requirements. Disabling privileged MFA or changing a critical policy warrants a routed alert. A single failed login may be investigation context, while a cluster against privileged accounts may become a detection. A deployment approval may need long-lived audit integrity even when nobody should be paged.
Coverage includes failed and denied actions. If the system records only success, an attacker can probe object identifiers, tenant boundaries, administrative routes, and policy conditions without leaving the evidence that reveals the attempt. Denies need a stable reason category, but not an internal policy dump that teaches the attacker how to evade the rule.
Give an event a stable identity
The queue change should not produce the sentence configuration updated. It
should produce a structured event whose meaning survives collection and
normalization. A compact schema might look like this:
{
"event": {
"name": "queue.consumer.disabled",
"version": 2,
"time": "2026-07-19T06:12:04.381Z",
"outcome": "success",
"reason": "emergency_containment"
},
"actor": {
"type": "human",
"id": "usr_7f31",
"session_id": "ses_28c9",
"role": "payments-operator",
"elevated": true
},
"resource": {
"type": "queue-consumer",
"id": "refund-settlement-eu",
"tenant_id": "tnt_204"
},
"source": {
"workload": "admin-api",
"zone": "operations",
"region": "eu-west"
},
"request_id": "req_b882",
"trace_id": "trc_9a10",
"approval_id": "chg_4412",
"environment": "production"
}
The identifiers are safe references, not credentials. The event names the attempted action and outcome, the human or workload actor, the affected resource and tenant, the source, the privilege context, and the approval under which the action ran. A request or trace identifier carries the investigation through the gateway, application, queue, and data layer. A session identifier allows related activity to be found without storing the session token itself.
Use a synchronized wall-clock timestamp to construct an incident timeline, and preserve source sequence information where ordering matters. Clock synchronization has limits: two close events from different systems may remain ambiguous. A queue offset, database transaction identifier, monotonic counter, or causally propagated request identifier can establish order that timestamps alone cannot.
Stable event names and explicit schema versions let detections survive a service rewrite. Producers should not improvise names, severity, or field types. Define how a schema change is reviewed, how long old and new versions coexist, and how collectors reject or quarantine malformed security events. A parser that silently drops an unfamiliar field can erase the very tenant or privilege context the record was meant to preserve.
Control cardinality at the schema boundary. Full URLs, generated object names, user agents, arbitrary exception messages, and prompt text create unbounded dimensions and unpredictable storage costs. Keep a bounded category in the searchable schema; retain raw detail only when an investigation need, protected location, access policy, and expiry justify it.
Remove dangerous data before it spreads
Redaction at the dashboard is too late. By then the original value may exist in the application buffer, collector, retry queue, searchable store, archive, and support export. Sensitive routes should emit from field allow-lists or typed, classification-aware serializers. Collection should provide a second defensive check, but it cannot reliably repair a producer that serialized an entire request.
Never record raw passwords, bearer tokens, session cookies, private keys, recovery codes, or secret values. Payment and personal data need the handling required by their classification. Exception handlers must not turn request objects, headers, connection strings, or provider responses into accidental credential stores.
Preserve the decision without preserving the protected material. A data export event can name the actor, tenant, data class, filter category, row count, approval, destination class, and artifact hash. It does not need the exported rows. An AI retrieval event can retain document identifiers and classifications without copying document text. When investigators must join activity concerning an identifier, a stable token may be safer than the source value; its generation and lookup path still require access control.
Make leakage tests part of the telemetry contract. Seed test requests with recognizable canary credentials, tokens, cookies, personal fields, payment values, and prompt secrets. Exercise success, deny, validation, exception, timeout, worker retry, and debug paths. Search application output, collector buffers, dead-letter queues, stores, and exports for the canaries. The test passes only when required safe fields remain and forbidden values do not.
Temporary production debugging needs an owner, approval, narrow scope, sampling or volume bound, and automatic expiry. Confirm after expiry that the configuration reverted and the temporary records entered the correct retention class. A debug switch that depends on somebody remembering to turn it off is a latent disclosure.
Preserve meaning through the pipeline
The source is only the first trust boundary. Collectors authenticate producers, encrypt transport, buffer within a bound, and report loss or backpressure. The normalizer validates schema and preserves actor, tenant, correlation, and original-event identity. Storage separates current search needs from protected evidence retention. Detection consumes the stable event, case management records the response, and an evidence archive preserves material required for later review.
Each transition needs an observable failure mode. What happens when the collector is unavailable: does the application block a critical administrative action, write to a protected local buffer, or continue while emitting a health alarm? There is no universal answer. A failed debug message should not stop checkout, but a high-risk break-glass change may be unacceptable when its audit record cannot be durably accepted. State the policy per event class and bound any local queue so telemetry failure cannot exhaust the service it monitors.
Measure completeness as well as volume. Compare expected administrative actions with received events. Track producer silence, schema rejection, ingestion lag, dropped records, clock drift, and correlation-field loss. Send a known synthetic event through the whole route and verify that it reaches the expected detection and case owner. A dashboard full of events does not reveal the one critical producer that stopped reporting.
Separate audit authority from production authority
Operational logs optimize for near-term diagnosis and search. An audit trail for privileged changes, sensitive access, deployments, or recovery decisions may need stronger retention, integrity, and administrative separation. The required strength follows the system’s threat and assurance level; “immutable” is not a useful label unless the design names who can alter retention, keys, policies, and the archive itself.
For the compromised refund platform, the identity that changed the queue and ledger must not also be able to erase their authoritative records. Send high-value events promptly to an append-only or tamper-evident destination under separately protected administration. Restrict readers as well as writers: audit data can reveal employee activity, customer relationships, security controls, and the shape of an incident. Log access to the evidence system itself.
Set retention by use and obligation rather than one global duration. Detection may need searchable recent data; investigations need a window long enough to cover delayed discovery; audit evidence may have contractual or regulatory requirements. Document expiry and deletion instead of allowing product teams to remove inconvenient records ad hoc. Where a legal hold applies, authorized owners suspend ordinary disposal for the defined scope and record that decision; the engineering design should support this workflow without pretending to give legal advice.
Evidence export is another privileged action. Record the requester, purpose, approved scope, query or case reference, time range, destination, artifact hash, and custody transfers. Minimize the export, protect it in transit and at rest, and expire working copies. This record lets a later reviewer distinguish source evidence from an analyst’s selected or transformed view.
Turn records into a response
The altered queue now yields a chain instead of three fragments. Responders can follow the human’s step-up session to the policy allow decision, administrative request, queue change, worker shutdown, and subsequent ledger write. Tenant and resource fields bound the search. Sequence identifiers resolve the order that close timestamps could not. The approval reference is missing, so the policy allow is itself suspicious. A separately administered audit copy prevents the same production authority from quietly rewriting that account.
This chain becomes useful only if somebody is expected to act. Each detection needs a routed owner, severity and timing expectation, investigation query or runbook, safe containment options, and a review process for false positives and missed events. Tune with recorded outcomes; do not make a noisy rule quiet by discarding the fields needed to distinguish ordinary work from abuse.
Before approving a telemetry design, ask the system to prove its claims:
- Can the event catalog account for authentication, authorization, administration, sensitive data and secret access, build and deploy, edge controls, background work, and AI or automation decisions—including denies and failures?
- Does a sample record identify time and order, actor, action, resource, result, source, request or trace, tenant, session, privilege, environment, and approval wherever those fields apply?
- Do canary tests show that credentials, protected payloads, unsafe exceptions, and temporary debug data cannot leak through any producer or pipeline branch?
- Can an investigator correlate a consequential action across services without guessing at identity or tenant scope?
- Do loss, lag, schema rejection, producer silence, and clock health alert an owner before an incident exposes the gap?
- Can a production administrator perform the action and erase or alter its audit record through the same authority?
- Are retention, evidence access, export, expiry, and legal-hold workflows owned, exercised, and recorded?
- Has each paging rule reached its owner in a test, and can that owner explain what evidence would confirm or disprove the alert?
Chapter 20’s recovery path required protected telemetry to choose a trusted recovery point and explain the return to service. That evidence begins in the code paths of the next chapter: validation, authorization, side effects, and safe errors must emit the facts the architecture promises. If those paths do not produce a trustworthy record, no collector or archive can reconstruct one later.
Continue reading
Full table of contents