Skip to content

feat: OWASP APTS audit — tamper-evident hash chain for trace logs (APTS-AR-012)#813

Draft
cursor[bot] wants to merge 1 commit into
canaryfrom
cursor/apex-apts-audit-6334
Draft

feat: OWASP APTS audit — tamper-evident hash chain for trace logs (APTS-AR-012)#813
cursor[bot] wants to merge 1 commit into
canaryfrom
cursor/apex-apts-audit-6334

Conversation

@cursor
Copy link
Copy Markdown

@cursor cursor Bot commented Jun 1, 2026

What does this PR do?

Audits the Apex codebase against the OWASP Autonomous Penetration Testing Standard (APTS) and fixes one concrete gap: APTS-AR-012 — Tamper-Evident Logging with Hash Chains (Tier 1 MUST).

The fix: Every trace.jsonl record now carries a SHA-256 hash chain envelope (seq, previousHash, hash). This makes the engagement audit trail tamper-evident — modification, deletion, or reordering of records is cryptographically detectable. A verifyTraceHashChain() utility implements the APTS-AR-012 Chain Verification Algorithm.

Files changed (3):

  • src/core/agents/offSecAgent/trace.ts — Added HashChainEnvelope type, hash-chain computation in appendRecord(), and verifyTraceHashChain() verification function
  • src/core/agents/offSecAgent/trace.test.ts — 9 new tests for hash chain integrity
  • src/core/agents/offSecAgent/index.ts — Re-export new types and verification function

How did you verify your code works?

  • All 36 trace tests pass (27 existing + 9 new hash chain tests)
  • Full test suite: 1087 passed, 15 skipped (pre-existing integration test skips)
  • tsc --noEmit passes
  • Tests verify: field presence, monotonic seq, chain linkage, tamper detection (modification/deletion/reordering), empty trace edge case
Open in Web View Automation 

Implement SHA-256 hash chain on trace.jsonl per OWASP APTS requirement
APTS-AR-012 (Tier 1 MUST: Tamper-Evident Logging with Hash Chains).

Every trace record now includes:
- seq: monotonically increasing counter across all record types
- previousHash: SHA-256 hex of the preceding record (empty for first)
- hash: SHA-256(JSON(record-without-hash) + previousHash)

Adds verifyTraceHashChain() utility that implements the APTS-AR-012
Chain Verification Algorithm — detects modification, deletion, and
reordering of trace records.

9 new tests covering:
- Hash chain field presence on all record types
- Monotonic seq across init/step/checkpoint/task records
- Chain linkage (previousHash matches prior hash)
- Full verification of intact traces
- Tamper detection: modification, deletion, reordering
- Empty trace edge case

Co-authored-by: Jorge Alejandro Raad <jorge@pensar.dev>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant