Repository navigation
fix(agents): redact reflected credentials from provider error detail and reason phrase - #120200
Conversation
e42faf6 to
982ec71
Compare
|
Codex review: needs maintainer review before merge. Reviewed August 27, 2026, 5:40 PM ET / 21:40 UTC. ClawSweeper reviewWhat this changesThis PR redacts credentials reflected in Perplexity, Tavily, and xAI web-search HTTP error bodies or reason phrases while retaining bounded non-sensitive diagnostics. Regression provenancePossible regression — probable (reproduction; reviewed change). No predecessor PR is attributed. Merge readinessKeep open. The rewritten head repairs a current-main credential-reflection path at the authenticated request owner, keeps the prior global-prose regression out of scope, and has sufficient real-behavior evidence; no blocking correctness finding remains. Exact-head hosted checks were still running in the supplied state. Priority: P1 Review scores
Verification
Live VerificationCommand: Result: FAIL (failed) — step 1 Assertions:
How this fits togetherBundled web-search plugins send authenticated HTTP requests through shared SDK helpers and return failures to agent tool callers. This change sanitizes provider-controlled failure text before it reaches those agent-facing error details. flowchart LR
A[Web search plugin request] --> B[Authenticated request headers]
B --> C[Shared HTTP helper]
B --> D[Perplexity request]
C --> E[Failed provider response]
D --> E
E --> F[Request-aware credential redaction]
F --> G[Agent-facing error details]
Before merge
Agent review detailsSecurityNone. PR surfaceSource -18, Tests 0, Docs +4. Total -14 across 12 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Land the request-local redaction after exact-head checks are green, retaining the existing two-argument helper contract and the shared redactor boundary. Do we have a high-confidence way to reproduce the issue? Yes. Current main visibly interpolates raw provider failure detail, and the PR documents a loopback before/after reproduction through the shared request path; this read-only review did not rerun contributor code. Is this the best way to solve the issue? Yes. Passing the actual outgoing headers into the existing request-aware redactor fixes the producer-side error boundary, covers shared-helper consumers, and keeps short-Bearer handling local to provider-controlled failures. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 7b000dba9dab. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (8 earlier review cycles)
|
982ec71 to
f9d8cf7
Compare
|
@clawsweeper re-review — exact-head CI is now green (the only remaining before-merge item). Thanks! |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
f9d8cf7 to
2cc97f6
Compare
|
@clawsweeper re-review — the P1 short-Bearer finding is addressed at the forced tools-redaction boundary as recommended:
|
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
steipete
left a comment
There was a problem hiding this comment.
Keep credential redaction at the provider request boundary
Thanks for covering both the response body and the reason-phrase fallback. This is a real gap that remains on current main, but this version both misses active credentials and broadens unrelated tool-diagnostic redaction.
Production LOC: +30/-5 (net +25) | Tests: +147/-0 | Total: +177/-5 (net +172).
Findings
-
[P1] Redact the credential actually sent, including truncated reflections.
postTrustedWebToolsJsonalready knowsparams.apiKey, but the new sanitizer receives only response text. A short/custom credential such asabcde, reflected asupstream refused abcdein either the body or an empty-bodystatusText, is neither a Bearer expression nor a recognizable vendor token. The process registry deliberately ignores values shorter than six characters (src/logging/secret-redaction-registry.ts:27), so it cannot close this gap. The patch also discards thetruncatedfact returned byreadResponseText; a credential cut atmaxErrorByteswill not match its registered full value. The request owner needs to carry the active credential and truncation context into error sanitization, rather than rely on generic pattern recognition. -
[P2] Do not apply short-Bearer guessing to unrelated tool diagnostics. The new pass in
redactToolPayloadTextWithConfigapplies to every caller, not just authenticated provider failures. The regex matches ordinary prose such asOAuth Bearer tokens are supported, replacingtokenswith***. Existing callers include compact tool displays (src/agents/tool-display-common.ts:128) and MCP diagnostics (src/agents/mcp-error.ts:22). Keep provider-error handling scoped to that boundary. Current main also separates model-visible source text from diagnostic redaction; the older shared-policy shape in this diff should not undo that distinction when refreshed.
Best-fix verdict: too broad in logging, too narrow at the credential owner. Reuse createProviderErrorTextRedactor in src/agents/provider-http-errors.ts:42, which already removes active request credentials and handles a truncated credential suffix. Consolidate the two web-search error paths and carry the same request context through both Perplexity call sites (extensions/perplexity/src/perplexity-web-search-provider.runtime.ts:250,298). The native PDF and MiniMax VLM paths from #125499 demonstrate that existing boundary. A global short-token heuristic is not necessary to connect web search to it, and registry-only matching cannot cover short values or partial reflections.
Please retain focused owner-boundary proof for complete and partial bare credentials, body/status fallback, ordinary Bearer prose, and both Perplexity transports. Collapse the duplicate error handling and repeated test setup into the existing owners, targeting a non-positive total diff; I have not demonstrated that final rewrite or its LOC count yet.
Evidence and limits: Reviewed head 2cc97f683f6cfc481b943e577d5b347fc23b3f4c, the shared request/error owners, Tavily and xAI callers, both Perplexity transports, the bounded body reader, generic redaction/registry, and PDF/VLM siblings. The raw web-search error branches remain unchanged on main 53380e5ca735dd8d6a42fc74d4f441068d629f89 and stable tag v2026.7.1-2; this is not an already-fixed close. Original introduction was not independently established because local blame stops at a shallow-history boundary. These findings are source-derived: I have not executed this PR or independently reproduced its reported HTTP run.
Bind bounded error diagnostics to the actual outgoing request headers for shared web tools and both Perplexity transports. Preserve caller cancellation and replace case-insensitive owned headers without combining credentials. Reuse the provider error redactor and remove duplicate xAI parser-only test paths while retaining real HTTP and sibling coverage. Production -18 lines; total -14 lines including regression tests and documentation. Refs openclaw#120200, openclaw#117304, openclaw#119536. Co-authored-by: zenglingbiao <[email protected]>
2cc97f6 to
c853f36
Compare
|
Rewrote this PR at c853f369b47ea95feb8e410cc6a29ba2d20dc0bb, preserving @zenglingbiao's co-authorship. The short-credential policy is now request-local and reuses the existing provider-error redactor; global payload text is untouched. Both Perplexity transports carry their actual headers. Review also caught combined mixed-case Authorization values, fixed at request construction, and the regression suite protects caller cancellation during error-body reads. The updated PR body records the failing/passing HTTP reproductions, 230 passing focused/sibling tests, green full build and changed gates, and real authenticated Perplexity plus built-Gateway success/error proof. Production is −18 lines and the complete PR is −14 including tests/docs. Exact-head hosted CI is running; native landing remains pending. @clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
Prevent early SIGTERM from orphaning a detached compiler before its supervisor registers the child. Retain shared handlers for concurrent commands and clean them up after synchronous or asynchronous spawn failure. Reproduce the race at the real process boundary and consolidate stale type comments and one-use registration wrappers.
|
The takeover is now at b66c19a. The twelve web-fix files are unchanged from the preceding built, live-tested head. The first hosted run exposed a real existing startup race in the shared process supervisor: the detached compiler could publish readiness before the supervisor installed its OS signal handlers. An early SIGTERM then killed the supervisor without reaping its compiler. The fix moves handler installation to before spawn and retains correct cleanup for concurrent commands and spawn failures. A deterministic real-process probe and the tracked regression fail with the old ordering and pass after the repair; no timeout was increased. The additional 91 tooling/helper tests, local changed-file gate, and fresh isolated Codex P0 review passed. The complete PR is now production −92, tests +55, docs +4, total −33 lines. Contributor credit is retained. Exact-head CI is running; native landing remains held until it is green. The PR body includes the earlier authenticated provider/Gateway proof and the distinct unproven process-owner follow-up. @clawsweeper re-review |
|
🦞👀 Re-review progress:
|
There was a problem hiding this comment.
The earlier change request on 2cc97f is addressed by the maintainer rewrite at b66c19a.
The shared authenticated request owner now passes actual outgoing headers and truncation context to the existing provider-error redactor. Short and partial credential reflections are covered without changing global tool-prose redaction. Perplexity's native and Sonar/OpenRouter paths carry the same context. Mixed-case Authorization replacement and post-header cancellation are regression-tested. The request-local design and removal of duplicate xAI test-only surface are the appropriate owner-boundary fix.
The first hosted run exposed a separate real managed-process startup race. Installing signal handlers before spawning repairs it without increased timeouts; the real-process regression fails with the old ordering and passes after the repair. Shared-listener and failed-spawn cleanup are covered.
Verification: 230 web/provider/sibling tests, 91 tooling/helper tests, complete local changed gates, full build, final-head CLI help, authenticated Perplexity Search/Sonar, real invalid-key Perplexity/Tavily, and isolated built-Gateway success/error flows. The final assembled 15-file isolated Codex review has no actionable P0 findings; maintainer and independent source review separately cover lower-priority correctness. Exact-head CI33121764838 passed: 185 jobs succeeded and 17 were skipped, with no failures; the formerly failing small-47 job and ci-gate both succeeded. All application file blobs are unchanged from the built/live-tested rewrite.
Production −92, tests +55, docs +4: total −33 lines. Contributor credit is preserved. No authenticated Tavily success or xAI live call is claimed; named Exa/Parallel and separate process-owner follow-ups remain outside this repair. Native artifact validation and prepare completed successfully without rebasing; the prepared source stayed exact b66c19a. Hosted CI33121764838 and Workflow Sanity33121764858 satisfied the native gate; no additional Testbox was needed. Native merge completed as 213804d7. All 15 landed file blobs independently match the reviewed head; main ancestry, native worktree/ref/lock cleanup and preservation of unrelated checkouts were verified.
|
Merged via squash.
|
…and reason phrase (openclaw#120200) * fix(web): redact request credentials from provider errors Bind bounded error diagnostics to the actual outgoing request headers for shared web tools and both Perplexity transports. Preserve caller cancellation and replace case-insensitive owned headers without combining credentials. Reuse the provider error redactor and remove duplicate xAI parser-only test paths while retaining real HTTP and sibling coverage. Production -18 lines; total -14 lines including regression tests and documentation. Refs openclaw#120200, openclaw#117304, openclaw#119536. Co-authored-by: zenglingbiao <[email protected]> * fix(tooling): install managed signals before spawning children Prevent early SIGTERM from orphaning a detached compiler before its supervisor registers the child. Retain shared handlers for concurrent commands and clean them up after synchronous or asynchronous spawn failure. Reproduce the race at the real process boundary and consolidate stale type comments and one-use registration wrappers. --------- Co-authored-by: Peter Steinberger <[email protected]>
What Problem This Solves
Fixes an issue where web-search users could expose their request credential in an error when a provider or proxy reflected it in the response body or HTTP reason phrase. Short keys and credentials cut by the diagnostic byte limit also need protection.
Related: #117304, #119536.
Why This Change Was Made
The maintainer rewrite keeps this policy at the authenticated request owner. The shared web helper now passes the actual outgoing headers to the existing request-aware provider-error redactor. Perplexity's native Search and Sonar/OpenRouter paths carry the same context. General tool-payload redaction is unchanged, so ordinary text such as
Bearer tokensremains intact.Request construction now uses
Headers.setfor owned fields: differently cased caller headers cannot combine two Authorization values. Error-body cancellation retains the caller's original reason. The existing two-argument SDK error helper remains usable; request context is an optional third argument.Removed copied xAI HTTP mocks, duplicate parser-only checks, and test-only parser exports. Retained tests now exercise the shared HTTP owner and the production citation parser caller.
The first hosted CI run exposed an existing process-supervisor race: a detached compiler could become ready before its supervisor installed signal handlers. An early SIGTERM could then orphan the compiler. The shared managed-process owner now installs handlers before spawning, retains them for concurrent commands, and removes idle handlers after either synchronous or asynchronous spawn failure. The regression exercises the real process boundary; no timeout was increased.
User Impact
Perplexity, Tavily, and the xAI web/X-search/code-execution family retain provider labels, HTTP status, and bounded diagnostics while removing recognized reflected credentials. Successful responses and ordinary chat/tool prose are unchanged. No new configuration, dependencies, schema, or persistent-state design.
Thanks @zenglingbiao for the report, initial fix, and reflection reproductions; contributor co-authorship is preserved.
Evidence
Rewritten head:
b66c19aee848087f612d6745f3ec8b2dea015217. Exact-head CI passed at 22:29:17 UTC on August 27, 2026. Native validation, prepare and merge completed successfully; merged as 213804d77046ce5d0e3cae84fa0fc4742625f064 at 23:17:31 UTC. All 15 landed file blobs independently match the reviewed head, and the merge is an ancestor of freshly fetched main. The previous run failed the compiler-reaping regression described below, not the web-provider tests./tools/invokeproof passed with real Perplexity: valid auth returned HTTP 200 with a normalized search result; invalid auth returned the documented sanitized HTTP 500 while recording the provider's 401 diagnostic without the synthetic credential. Both isolated instances and their temporary state were removed.unknownannotation in a test catch callback; it is fixed and all eight shared-owner tests passed again. Application production bytes are unchanged from the successful build/live proof. Exact-head hosted CI remains required before landing.pnpm openclaw --helpinvocation completed successfully after the normal git-head-triggered rebuild. ClawSweeper's separate build-plus-help probe timed out before its build completed; that timeout is not reported as a successful probe. The completed local build, help invocation, and authenticated provider/Gateway flows above provide the actual evidence.Commands run:
node scripts/run-vitest.mjs src/agents/tools/web-search-provider-common.test.ts src/agents/tools/web-shared.test.ts src/agents/tools/web-guarded-fetch.test.ts src/agents/provider-http-errors.test.ts extensions/perplexity/src/perplexity-web-search-provider.test.ts extensions/tavily/src/tavily-client.test.ts extensions/tavily/src/tavily-tools.test.ts extensions/xai/web-search.test.ts extensions/xai/src/responses-tool-shared.test.ts extensions/xai/x-search.test.ts extensions/xai/code-execution.test.ts node scripts/run-vitest.mjs test/scripts/managed-child-process.test.ts test/scripts/run-tsgo.test.ts test/scripts/direct-run-entrypoints.test.ts test/helpers/process-wait.test.ts git diff --name-only -z | xargs -0 env -u OPENCLAW_TESTBOX node scripts/check-changed.mjs -- env -u OPENCLAW_TESTBOX pnpm build env -u OPENCLAW_TESTBOX pnpm docs:list env -u OPENCLAW_TESTBOX pnpm openclaw --helpJudged LOC: application production −18, tooling production −74 (combined −92), tests +55, docs +4; total −33. No generated, lockfile, or snapshot churn.
Latest ClawSweeper review at 21:40 UTC reports no blocking correctness findings and retains exact-head hosted checks as the remaining gate. Those checks are now green. Earlier rank-up moves are addressed: request-local short-credential redaction, preserved global ordinary-prose behavior, current-main owner comparison, and real HTTP proof. A fresh review was requested after the additional CI process-owner repair.
Provenance: the raw-error helper was already present in 3de973ffff2e6803b85906ba94ed8ace77f3618d, authored and committed by @Takhoffman on March 18, 2026. This establishes an earlier occurrence, not the first introduction; no associated PR was returned. The local shallow boundary cannot establish the header-construction defect's original author.
Named follow-up: Exa and Parallel have separately owned
x-api-keyerror paths that do not carry request-aware redaction context. This PR does not claim to cover those paths or every possible encoding of sensitive response data.Separate process-owner follow-up:
scripts/run-with-env.mtsalso installs handlers after spawning. That distinct path has not been reproduced here and is not claimed fixed by this PR.