GebSecure Docs v0.1.0

Guides · Security

Audit log

The tamper-evident audit log — what it records, how the hash chain works, searching, tailing, exporting, verifying and streaming to a SIEM.

Every decision, execution, approval, credential use and administrative change is recorded in the audit log in the same database transaction as the change itself, then chained per organization with SHA-256 (ADR 0005).

Events#

Field Meaning
id, seq, occurredAt identity and position in the organization's chain
category, action, outcome e.g. authz / authz.decision, execution / execution.complete, mcp / mcp.tool.call; outcome success, failure, denied, pending or error
actorType, actorId, onBehalfOf, agentId, sessionId who acted, and for whom
projectId, environmentId, resourceType, resourceId where and on what
decision, policyIds, riskScore, approvalId, executionId, argsHash decision context
requestId, traceId, ip, userAgent correlation with logs and traces
details event-specific data, with secrets redacted
prevHash, hash the chain

The hash chain#

Writes go to an ingest table in the same transaction; the worker moves them into audit_events, assigning the next seq per organization and computing hash = sha256(prevHash + canonical({orgId, seq, id, occurredAt, …event})), starting from 64 zeros. The table rejects UPDATE, DELETE and TRUNCATE. Events become visible shortly after the change (the worker chains every few hundred milliseconds).

POST /v1/audit/verify ({fromSeq?, toSeq?}, permission audit:read) recomputes the chain and returns {valid, checked, firstSeq, lastSeq, headMatches, errors: [{seq, id, problem}]} with problems such as gap: expected seq N, prev_hash mismatch or content hash mismatch (record altered). Every verification is itself audited (audit.verify).

docs/site/snippets/ts/audit-tail.ts
const check = await gs.verifyAudit(); // the whole chain; pass { fromSeq, toSeq } for a range
console.log(`chain ${check.valid ? 'valid' : 'BROKEN'}: ${check.checked} events (${check.firstSeq}…${check.lastSeq})`);
for (const e of check.errors ?? []) console.log(`  seq ${e.seq}: ${e.problem}`);

Search and tail#

GET /v1/audit/events (permission audit:read) filters by from, to, category, action (a trailing * is a prefix match), outcome, actorId, agentId, resourceType, resourceId, projectId, environmentId, decision, traceId, approvalId, executionId, minRisk and q (free text over action, resource and details), newest first, with limit (1–1000, default 100) and cursor. With afterSeq the order is oldest first — use it to tail:

docs/site/snippets/ts/audit-tail.ts
// Start after the newest event; afterSeq returns the following events oldest-first.
let after = (await gs.searchAudit({ limit: 1 })).data[0]?.seq ?? 0;
const rounds = Number(process.env.AUDIT_TAIL_ROUNDS ?? Infinity);
for (let i = 0; i < rounds; i++) {
  const page = await gs.searchAudit({ afterSeq: after, limit: 500 });
  for (const e of page.data) console.log(e.seq, e.occurredAt, e.category, e.action, e.outcome, e.actorId);
  after = page.data.at(-1)?.seq ?? after;
  if (i + 1 < rounds) await new Promise((r) => setTimeout(r, 2000));
}

From the CLI:

bash
gebsecure logs --since 24h --decision DENY
gebsecure logs --agent agt_… -f -o ndjson

Export#

GET /v1/audit/export (permission audit:export) takes the same filters and format — ndjson (default), csv or json — up to one million events; CSV cells are protected against formula injection. Every export is audited (audit.export).

bash
gebsecure logs export --since 7d --format csv --out audit.csv

Retention#

Audit events are kept auditRetentionDays (organization setting, default 365, at least 30). Old events are removed from the head of the chain only after a checkpoint is written, so the remaining chain still verifies; the removal is audited (audit.retention). Operational records have their own retention — see Compliance.

SIEM streaming#

POST /v1/siem/destinations (permission audit:configure) streams the audit log to splunk_hec, datadog, elastic or a webhook, in OCSF (default) or the native format, optionally filtered by categories. Each destination keeps its own cursor, so delivery is ordered and at least once; a failing destination backs off exponentially (up to an hour) and resumes where it stopped. backfill: true starts from the beginning of the chain instead of its current end.

Traces and session replay#

Requests carry W3C traceparent; the platform records spans for authorization, risk, approval, execution and broker calls, and agents add their own spans with POST {gateway}/v1/traces/spans (the SDKs' reportSpans and buildSpan). GET /v1/traces searches traces, GET /v1/traces/{traceId} returns the span tree with correlated audit records, and GET /v1/replay/{principalId} replays everything an agent or user did in a time window.