feat: OWASP APTS audit — tamper-evident hash chain for trace logs (APTS-AR-012)#813
Draft
cursor[bot] wants to merge 1 commit into
Draft
feat: OWASP APTS audit — tamper-evident hash chain for trace logs (APTS-AR-012)#813cursor[bot] wants to merge 1 commit into
cursor[bot] wants to merge 1 commit into
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.jsonlrecord 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. AverifyTraceHashChain()utility implements the APTS-AR-012 Chain Verification Algorithm.Files changed (3):
src/core/agents/offSecAgent/trace.ts— AddedHashChainEnvelopetype, hash-chain computation inappendRecord(), andverifyTraceHashChain()verification functionsrc/core/agents/offSecAgent/trace.test.ts— 9 new tests for hash chain integritysrc/core/agents/offSecAgent/index.ts— Re-export new types and verification functionHow did you verify your code works?
tsc --noEmitpasses