/** * TOCTOU Causal Integrity Verification (Red Team Fix #11 / Bonus). * * Detects Time-of-Check-to-Time-of-Use violations in proof bundles. * * Attack vector: Agent reads auth.ts, gets a tool_receipt with * result_hash_b64u of the safe version. While the LLM is thinking, * an attacker modifies auth.ts on disk. The agent commits the * malicious version. * * Defense: For each side_effect_receipt of type filesystem_write that * references files, verify that each file's hash matches the * result_hash_b64u of the most recent preceding tool_receipt that * read that file. * * This is a WARNING-tier finding, not a hard FAIL. */ import type { EventChainEntry } from './types.js'; interface ToolReceipt { receipt_id: string; tool_name: string; tool_version?: string; args_hash_b64u?: string; args_digest?: string; result_hash_b64u?: string; result_digest?: string; result_status?: string; timestamp: string; binding?: Record; } interface SideEffectReceipt { receipt_id: string; effect_class: string; timestamp: string; binding?: Record; } export interface CausalIntegrityBundleInput { event_chain?: EventChainEntry[]; tool_receipts?: ToolReceipt[]; side_effect_receipts?: SideEffectReceipt[]; } export type CausalIntegritySeverity = 'warning' | 'info'; export interface CausalIntegrityFinding { severity: CausalIntegritySeverity; code: 'TOCTOU_INTEGRITY_VIOLATION' | 'TOCTOU_UNVERIFIABLE'; message: string; file_path?: string; read_hash_b64u?: string; commit_hash_b64u?: string; read_receipt_id?: string; commit_receipt_id?: string; } export interface CausalIntegrityResult { has_violations: boolean; files_checked: number; files_passed: number; findings: CausalIntegrityFinding[]; } /** * Verify causal integrity of a proof bundle. * * Checks that files referenced in side_effect_receipts of type * filesystem_write match the result_hash_b64u of the most recent * preceding tool_receipt that read those files. */ export declare function verifyCausalIntegrity(bundle: CausalIntegrityBundleInput): CausalIntegrityResult; export {}; //# sourceMappingURL=verify-causal-integrity.d.ts.map