fix(core): resolve 6 deferred security/correctness findings#12
Merged
Conversation
Critical: DEFAULT_RULES now used as fallback when no policy file exists (or policy file is empty/corrupt), ensuring budget enforcement in all modes including dry-run. High: PII detection extended with secret patterns (API keys incl. Stripe sk_, AWS AKIA, GitHub tokens, Bearer tokens, JWTs, PEM private keys, npm tokens, generic secrets). Audit writes now redact PII in warn/redact mode — both success and failure paths, including error strings that may echo request content. High: TOCTOU budget commit gap fixed — inFlightHoldTotal and budgetSpent mutations now re-acquire the async mutex, preventing transient budget miscalculation under concurrent calls. Medium: Proxy settlement failures now emit settlement_ambiguous audit events (matching the TigerBeetle path). Degraded audit receipts return "AUDIT_DEGRADED" sentinel instead of a misleading synthetic hash. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Contributor
Author
Codex Review (gpt-5.3-codex)No issues found. PR is clean. |
Contributor
Author
Codex Remediation Summary
Deliberations: 0 of 2 used |
Contributor
Author
CI Results (Final)
Commit: |
Contributor
Author
Ship Pipeline CompleteBranch: ship/deferred-findings Audit Trail
Deferred from internal reviews (pre-existing, not in scope)
Summary
|
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
Fixes all 6 deferred findings from the code review and security review of #10 (governAction). These are pre-existing issues in the
interceptCall()LLM path that apply to both old and new governance paths.Critical
DEFAULT_RULES(block-zero-budget, block-budget-exhausted, warn-high-cost) now used as fallback when no policy file exists OR when the file is empty/corrupt. Previously,policyRulesdefaulted to[], meaning zero budget enforcement in dry-run mode.High
warn/redactmode before writing to the append-only chain. Applied to success paths, failure paths (error strings that may echo request content), and action params.sk-, Anthropicsk-ant-, Stripesk_live_/sk_test_), AWS keys (AKIA), GitHub tokens (ghp_/gho_/ghs_/ghr_/github_pat_), Bearer tokens, JWTs, PEM private keys, npm tokens, and generic secrets (Slackxox, SendGridSG., GitLabglpat-, long hex).inFlightHoldTotalandbudgetSpentmutations now re-acquire the async mutex, preventing transient budget miscalculation under concurrent calls. Applied to all 5 budget mutation sites (streaming success, streaming error, non-streaming success, non-streaming failure, governActionImpl).Medium
settlement_ambiguousaudit events (matching the TigerBeetle path). Applied to bothinterceptCallandgovernActionImpl."AUDIT_DEGRADED"sentinel instead of a synthetic SHA-256 hash. Applied to all 4 receipt construction sites including the streaming estimated receipt.Also includes (from internal review remediation)
redactPII()utility for deep-cloning data with PII replaced by[REDACTED:<type>]placeholdersllm_call_failedandstream_partial_deliveryaudit events now redacted when PII mode is activeisGenericSecretno longer double-fires withisApiKeyonsk-prefixed keysTest plan
npx vitest run— 1146/1155 pass (9 pre-existing@clack/promptsCLI failures)[REDACTED:email]not raw emails in warn modesk-,AKIA,ghp_,Bearer, JWT, PEM all detectedsettlement_ambiguousevent emitted when proxy settle failssk-key tagged asapi_keyonly, notgeneric_secretFiles changed (6 files, +785/-54)
packages/core/src/govern.tspackages/core/src/policy/pii.tsredactPII()function, JWT/PEM/npm detectionpackages/core/tests/govern/govern.test.tspackages/core/tests/govern/failure-modes.test.tspackages/core/tests/govern/action-governance.test.tspackages/core/tests/policy/pii.test.ts🤖 Generated with Claude Code