fix(security): avoid logging raw AI CLI stderr - #1608
Conversation
|
Superagent didn't find any vulnerabilities or security issues in this PR. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1608 +/- ##
=======================================
Coverage 95.51% 95.51%
=======================================
Files 204 204
Lines 22042 22050 +8
Branches 7964 7971 +7
=======================================
+ Hits 21053 21061 +8
Misses 413 413
Partials 576 576
🚀 New features to boost your workflow:
|
|
Caution 🟥🟥🟥🟥🟥🟥🟥🟥🟥🟥🟥🟥 🛑 Gittensory review — blocked
🛑 Blocked Review summary
Nits — 5 non-blocking
Review context
Contributor next steps
Signal definitions
Review detailsGenerated from public PR metadata and the diff. Advisory only; deterministic signals remain authoritative. Clean, well-scoped security fix that replaces arbitrary-length redacted stderr with a bounded allowlisted classifier. The core approach is correct: `redactSecrets` runs before pattern matching so the regex never sees raw credentials; the five-category plus two-fallback design preserves operational diagnosability (#26) without copying untrusted text into Sentry-forwarded error fields. All updated test assertions trace correctly to real code paths — no fabricated scenarios, and the integration test using a real script stub still exercises the `defaultSpawn` path end-to-end. Nits (5)
🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed 💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →. Checked by Gittensory, a quiet PR intelligence layer for OSS maintainers.
|
|
Closing: the raw-stderr leak this addresses is already fixed on main — |
Motivation
claude/codexstderr was being appended into thrown errors and emitted at error level, and the existingredactSecrets()only covered a small set of known shapes, leaving a risk of free-text credential leakage into logs/Sentry.Description
summarizeCliStderr()to convert untrusted CLI stderr into a bounded, allowlisted summary (e.g.auth_error,rate_limit,model_not_supported,timeout,permission_denied,stderr_captured,no_stderr) while applyingredactSecrets()first. (file:src/selfhost/ai.ts).summarizeCliStderr()so thrown errors carry a safe summary instead of arbitrary text. (file:src/selfhost/ai.ts).test/unit/selfhost-ai.test.ts).Testing
npx vitest run test/unit/selfhost-ai.test.ts, and the modified unit suite passed (tests coveringsummarizeCliStderrand the updated error behavior succeeded).npm run typecheckandgit diff --check, both succeeded locally.npm run test:coverage, but the run failed in this environment due to unrelated long-running/timeouts in other suites and a Vitest coverage provider error (TypeError: jsTokens is not a function); the failure appears unrelated to these changes.Codex Task