fix: Gemini 40-level audit pass 2 — 8 hardening fixes#35
Merged
Conversation
Fixes 8 findings from second Gemini slop audit (11% FP rate, down from 77%): - L3: Replace deterministic std::rand() jitter with std::mt19937 (agent retry) - L5: Fix sandbox-level help text default (said "standard", code uses "unrestricted") - L7: JSON large integer silent wrapping → fall back to double for >INT32 range - L9: Sanitize file paths in audit log (consistency with PR #34 telemetry fix) - L31: Port Windows generation-counter pattern to POSIX timer cancel - L36a: RAII fd guard in bounded_read (exception safety) - L36b: Add ROLLBACK on error path in block_search_index buildIndex() - L37: Range-check NaabVal::toInt() double cast (was UB for out-of-range values) Tests: 396/396, security leak check: 738/738 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
NAAb Governance Report
All governance checks passed! Generated by NAAb Governance Engine v4.0 |
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.
Summary
std::rand()jitter withstd::mt19937seeded fromstd::random_devicein agent retry loop--sandbox-levelhelp text — claimed "standard" default but code initializes to "unrestricted"logAuditEvent()— consistency with PR fix: telemetry path leak + REPL hardcoded block count #34 telemetry path sanitizationreadFileBounded()— exception-safe cleanupROLLBACKon error path inbuildIndex()— SQLite transaction leakNaabVal::toInt()double-to-int cast — was UB for out-of-range values, now clamps to INT_MIN/INT_MAXAudit Stats
Test plan
--helpshows(default: unrestricted)for sandbox-levelint(99999999999.0)→ 2147483647 (INT_MAX), not crash/garbagejson.parse('{"n":9999999999}')→ float, not garbage int🤖 Generated with Claude Code