v5.7.1 — CodeQL Security Fixes
All 3,136 tests pass. Zero TypeScript errors.
All 3,136 tests pass. Zero TypeScript errors.
Security / Bug Fixes
compactWAL() race condition — CWE-367 (High)
lib/locked-blackboard.ts — Replaced the existsSync + writeFileSync pattern with a single atomic file-descriptor operation:
// Before (TOCTOU — file could be replaced between check and write):
if (existsSync(this.walPath)) {
writeFileSync(this.walPath, '', { encoding: 'utf-8', mode: 0o600 });
}
// After (atomic — openSync 'w' = O_WRONLY | O_CREAT | O_TRUNC):
const fd = openSync(this.walPath, 'w', 0o600);
closeSync(fd);openSync('w') atomically truncates an existing WAL or creates a new empty one — no intermediate existence check that could be exploited in a race. Resolves CodeQL js/file-system-race #160.
Unused imports removed — test-phase11.ts
CircuitOpenErrorimport removed (CodeQLjs/unused-local-variable#161)existsSyncimport removed (CodeQLjs/unused-local-variable#162)
Both were dead code from Phase 11 development that were never referenced after final test implementation.
Useless assignment removed — test-phase11.ts:384
c = await hookMgr.runAfter(c) reassigned c but the returned context was never read. Changed to await hookMgr.runAfter(c). Resolves CodeQL js/useless-assignment-to-local #163.
Zero functional changes — all 3,136 tests continue to pass unchanged.