Skip to content

fix: Gemini 40-level audit pass 2 — 8 hardening fixes#35

Merged
b-macker merged 1 commit into
masterfrom
fix/gemini-audit-pass2
Jun 14, 2026
Merged

fix: Gemini 40-level audit pass 2 — 8 hardening fixes#35
b-macker merged 1 commit into
masterfrom
fix/gemini-audit-pass2

Conversation

@b-macker

Copy link
Copy Markdown
Owner

Summary

  • L3: Replace deterministic std::rand() jitter with std::mt19937 seeded from std::random_device in agent retry loop
  • L5: Fix --sandbox-level help text — claimed "standard" default but code initializes to "unrestricted"
  • L7: JSON large integer silent wrapping → fall back to double for values outside INT32 range (JavaScript behavior)
  • L9: Sanitize file paths in logAuditEvent() — consistency with PR fix: telemetry path leak + REPL hardcoded block count #34 telemetry path sanitization
  • L31: Port Windows generation-counter pattern to POSIX timer cancel (eliminates shared-static fragility)
  • L36a: RAII fd guard in readFileBounded() — exception-safe cleanup
  • L36b: Add ROLLBACK on error path in buildIndex() — SQLite transaction leak
  • L37: Range-check NaabVal::toInt() double-to-int cast — was UB for out-of-range values, now clamps to INT_MIN/INT_MAX

Audit Stats

  • Pass 2 FP rate: 11% (1/9) — down from 77% in pass 1 (improved prompt worked)
  • 8 files changed, 34 insertions, 10 deletions

Test plan

  • Full test suite: 396/396, 0 unexpected failures
  • Security leak check: 738/738 passed
  • --help shows (default: unrestricted) for sandbox-level
  • int(99999999999.0) → 2147483647 (INT_MAX), not crash/garbage
  • json.parse('{"n":9999999999}') → float, not garbage int

🤖 Generated with Claude Code

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>
@github-actions

Copy link
Copy Markdown

NAAb Governance Report

Metric Count
Files checked 16
Passed 16
Failed 0

All governance checks passed!

Generated by NAAb Governance Engine v4.0

@b-macker b-macker merged commit edb3071 into master Jun 14, 2026
20 checks passed
@b-macker b-macker deleted the fix/gemini-audit-pass2 branch June 14, 2026 20:28
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