Skip to content

fix(parallel): redact x-api-key reflected in web search error bodies - #120205

Merged
jalehman merged 3 commits into
openclaw:mainfrom
zenglingbiao:fix/parallel-web-search-redact-error-body
Aug 17, 2026
Merged

jalehman merged 3 commits into
openclaw:mainfrom
zenglingbiao:fix/parallel-web-search-redact-error-body

Conversation

@zenglingbiao

@zenglingbiao zenglingbiao commented Aug 7, 2026 •

Copy link
Copy Markdown
Contributor

Summary

The Parallel web_search provider (extensions/parallel/src/parallel-web-search-provider.runtime.ts) posts with an x-api-key header and, on a non-2xx response, splices server-controlled error text — the bounded body, or the statusText reason phrase when the body is empty — into the thrown error message. Any proxy/edge error page that reflects request material then leaks the API key into user-facing error text. The composed detail is now redacted in two layers: a tools-mode pass that masks header-shaped reflections, then the canonical redactToolPayloadText so configured logging.redactPatterns apply on top of the built-in credential patterns.

What Problem This Solves

  • runParallelSearch() sends x-api-key: params.apiKey and, on !res.ok, throws `Parallel API error (${res.status}): ${detail || res.statusText}` with the raw text (extensions/parallel/src/parallel-web-search-provider.runtime.ts:163).
  • The Parallel endpoint is operator-configurable (plugins.entries.parallel.config.webSearch.baseUrl), so deployments routinely front it with corporate proxies or gateways — exactly the class of intermediary whose error responses echo request material, including x-api-key.
  • The leak has two channels: the HTML error body, and the HTTP reason phrase. Undici surfaces the upstream reason phrase as response data, so an empty-body 502 with a reason phrase like Bad Gateway reflected x-api-key: <key> exposes the key through the statusText fallback even when there is no body.
  • The reflected key lands verbatim in the thrown Error message, and from there into tool results, transcripts, and logs.

代码证据: on main, pointing baseUrl at a local server that answers 502 with the request's x-api-key reflected in the page produces Error: Parallel API error (502): …x-api-key: par-live-4c9d2e7ab1f0c9d2e7ab1f0c9d2e7…; an empty-body 502 with the key in the reason phrase leaks it through the fallback the same way.

Same defect class as the merged #117304 (voice-call) and #119536 (discord) fixes, and the sibling web-search-provider-common fix in #120200.

Root Cause

The error path was written for diagnostics (status + bounded body snippet) before credential redaction became the house standard for tool-facing text. The violated invariant: text derived from the response to an authenticated request — body and reason phrase alike — must be treated as potentially containing the request's credentials and may only reach user-facing surfaces after redaction. The body read is already bounded (PARALLEL_ERROR_BODY_LIMIT_BYTES = 8 KiB, with a .catch(() => "")), so only the redaction pass was missing.

Why This Fix

  • Redact the composed detail (body with statusText fallback) so neither server-controlled channel can carry credential material into the message: redactToolPayloadText(redactSensitiveText(detail || res.statusText, { mode: "tools" })).
  • Why two layers: redactSensitiveText(…, { mode: "tools" }) masks header-shaped reflections (x-api-key: <key> → x-api-key: par-li…d2e7) via the structured auth-header matcher, and keeps redaction on regardless of the operator's log-redaction config. redactToolPayloadText (the canonical openclaw/plugin-sdk/logging-core surface) then applies configured logging.redactPatterns merged with the built-in defaults, so organization-specific secrets are stripped too.
  • The layering order matters: a configured field-name pattern such as api[_-]?key rewrites the header name to x-*** before the structured matcher can recognize the shape, so running the canonical redactor alone (or first) leaves x-***: <value still visible>; running the tools-mode pass first preserves the shape for the structured matcher, and the canonical pass then handles configured patterns. Verified with both pattern classes configured at once.
  • Both redactors return "" for empty input, so the || fallback semantics are preserved exactly: non-empty body → redacted body; empty/unreadable body → redacted reason phrase.
  • The body is still bounded to 8 KiB exactly as before; only credential material is masked.
  • Alternative considered: masking only the configured API key — rejected, because error pages can also reflect other credential material (proxy auth, cookies), which the central patterns already cover.

User Impact

  • Users of the Parallel web_search provider no longer expose their PARALLEL_API_KEY in error text when a proxy or the provider edge reflects request material — in the error page or in the reason phrase.
  • Error messages keep the provider label, HTTP status, and the non-secret portion of the detail; diagnostics are unaffected.

Evidence

  • Before: real local HTTP server reflecting the request's x-api-key (1) into a 502 HTML page and (2) into the reason phrase of an empty-body 502; the real executeParallelWebSearchProviderTool() entry point ran end to end through the SSRF-guarded fetch → both messages contain the full key → FAIL ×2.
  • After: same setup on this branch → the key is masked on both paths (x-api-key: par-li…d2e7), status and label intact → PASS ×2.
  • After (configured patterns): with logging.redactPatterns: ["acme-internal-[a-z0-9-]+", "api[_-]?key"], a 502 page reflecting both an org-specific secret and the key masks both (edge failure for acme-i…-042 on request with x-***: par-li…d2e7) → PASS. (The api[_-]?key case proves the layering: the header name gets rewritten by the configured pattern, and the value stays masked because the tools-mode pass ran first.)

Real Behavior Proof

Before (on main)

$ node --import tsx proof.mjs
case 1 (body reflection):   Error: Parallel API error (502): <html><head><title>502 Bad Gateway</title></head><body>edge failure for request with x-api-key: par-live-4c9d2e7ab1f0c9d2e7ab1f0c9d2e7</body></html>
case 2 (reason reflection): Error: Parallel API error (502): Bad Gateway reflected x-api-key: par-live-4c9d2e7ab1f0c9d2e7ab1f0c9d2e7
FAIL: API key reflected via the body path leaks into the error message
FAIL: API key reflected via the reason path leaks into the error message

After (with fix)

$ node --import tsx proof.mjs
case 1 (body reflection):   Error: Parallel API error (502): <html><head><title>502 Bad Gateway</title></head><body>edge failure for request with x-api-key: par-li…tml>
case 2 (reason reflection): Error: Parallel API error (502): Bad Gateway reflected x-api-key: par-li…d2e7
PASS: credential material redacted from the body path
PASS: credential material redacted from the reason path

(Real node:http server bound to 198.18.0.1 — the RFC 2544 benchmark range the trusted-endpoint SSRF policy explicitly allows, since loopback is blocked — with baseUrl pointed at it; the full guarded fetch, header injection, and error path execute for real. The proof key contains no dictionary words, so only credential-aware redaction can mask it.)

Tests and Validation

  • node scripts/check.mjs passed
  • npx vitest run extensions/parallel/src/parallel-web-search-provider.test.ts passed (54 tests, incl. regression tests: a 502 page echoing the configured key surfaces with the key masked — using a dictionary-word-free key so only credential-aware redaction catches it — an empty-body 502 with the key in the reason phrase is masked through the statusText fallback, and a 502 page reflecting an organization-specific secret plus the key under configured logging.redactPatterns (including a header-name-mangling pattern) masks both, while the label and status stay intact)

@zenglingbiao
zenglingbiao force-pushed the fix/parallel-web-search-redact-error-body branch from f2e9cbf to ffda110 Compare August 7, 2026 10:20
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. labels Aug 7, 2026
@clawsweeper

clawsweeper Bot commented Aug 7, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 9, 2026, 6:49 AM ET / 10:49 UTC.

ClawSweeper review

What this changes

The PR redacts credentials reflected in Parallel web-search HTTP failure bodies and empty-body reason phrases before they reach tool-visible errors.

Merge readiness

⚠️ Ready for maintainer review - 1 item remains

This PR remains necessary: current main still inserts a Parallel response body or reason phrase directly into an error after sending an API key. The exact-head patch repairs that plugin-owned boundary with the public SDK redactors and covers the configured-pattern ordering case; no blocking finding was identified.

Priority: P1
Reviewed head: 272793ca5a0899eb4ad5d00d480772e1984af369

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) A focused, contract-consistent security repair with direct before/after transport evidence and targeted regressions.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): The PR supplies before/after terminal output from the real Parallel tool path against a controlled HTTP server, covering reflected body text, reason phrases, and configured-pattern layering.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The PR supplies before/after terminal output from the real Parallel tool path against a controlled HTTP server, covering reflected body text, reason phrases, and configured-pattern layering.
Evidence reviewed 5 items Current main remains vulnerable: The authenticated request sends x-api-key and the non-OK path interpolates the bounded response detail or statusText directly into Error.message.
Exact-head owner-boundary repair: The PR redacts the composed body-or-statusText value before constructing the Parallel error while retaining the existing response-size limit and status diagnostics.
SDK redaction contract: Tools-mode redaction applies built-in header masking before the canonical tool-payload redactor applies configured logging.redactPatterns and defaults; this makes the two-pass order necessary for a header-name-mangling pattern.
Findings None None.
Security None None.

How this fits together

The Parallel plugin makes authenticated web-search requests and translates failed HTTP responses into agent-visible errors. This change filters untrusted provider or proxy response text before it enters diagnostics, logs, or tool results.

flowchart LR
  A[Authenticated Parallel search] --> B[Provider or proxy]
  B --> C[Failure body or reason phrase]
  C --> D[Parallel error boundary]
  D --> E[SDK redaction layers]
  E --> F[Tool-visible diagnostic]
Loading

Before merge

  • Complete next step (P2) - No repair lane is needed: the submitted exact-head patch is the bounded owner-boundary fix and has no actionable review finding.
Agent review details

Security

None.

PR surface

Source +12, Tests +83. Total +95 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 13 1 +12
Tests 1 83 0 +83
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 96 1 +95

Review metrics

Metric Value Why it matters
Production vs test LOC production +13/-1 (net +12), tests +83/-0 The production growth is justified by the credential-redaction security invariant and is backed by focused boundary regressions.

Technical review

Best possible solution:

Merge the focused plugin-local repair after normal exact-head merge gating; retain the separate shared-helper work in #120200 for bearer-auth web-search providers.

Do we have a high-confidence way to reproduce the issue?

Yes—an authenticated controlled endpoint that reflects x-api-key in a 502 body or reason phrase reaches the raw current-main error construction; the PR includes before/after real transport output for both paths.

Is this the best way to solve the issue?

Yes—the Parallel runtime owns its distinct x-api-key request and error boundary, while bearer-auth shared web-search helpers are separately covered by #120200.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 8b501c1c1343.

Labels

Label changes:

  • add rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.

Label justifications:

  • P1: The current authenticated provider error path can expose an API key through user-visible diagnostics when an upstream response reflects request material.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The PR supplies before/after terminal output from the real Parallel tool path against a controlled HTTP server, covering reflected body text, reason phrases, and configured-pattern layering.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR supplies before/after terminal output from the real Parallel tool path against a controlled HTTP server, covering reflected body text, reason phrases, and configured-pattern layering.

Evidence

What I checked:

Likely related people:

  • Vincent Koc: History associates this area with the bounded provider-error response work that the current error path builds on. (role: recent area contributor; confidence: medium; files: extensions/parallel/src/parallel-web-search-provider.runtime.ts)
  • Matt H: History associates this contributor with introducing the Parallel provider surface and its initial runtime structure. (role: feature introducer; confidence: medium; files: extensions/parallel/src/parallel-web-search-provider.runtime.ts, extensions/parallel/index.ts)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (4 earlier review cycles)
  • reviewed 2026-08-07T11:40:52.451Z sha ffda11035f1da8c16969d2300d837083c7d32e78 :: needs real behavior proof before merge. :: [P1] Redact the fallback reason phrase too
  • reviewed 2026-08-07T15:39:07.737Z sha a2bf4b8 :: found issues before merge. :: [P1] Use the tool-payload redactor at this error boundary
  • reviewed 2026-08-07T15:45:34.930Z sha a2bf4b8 :: needs changes before merge. :: [P1] Use the tool-payload redactor at this error boundary
  • reviewed 2026-08-09T07:53:55.292Z sha 272793c :: needs maintainer review before merge. :: none

@zenglingbiao
zenglingbiao force-pushed the fix/parallel-web-search-redact-error-body branch from ffda110 to a2bf4b8 Compare August 7, 2026 14:51
@zenglingbiao

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 7, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Aug 7, 2026
@zenglingbiao

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review — the P1 finding is addressed at head 272793c: the error boundary now runs the canonical redactToolPayloadText (configured logging.redactPatterns + defaults) layered over the tools-mode pass that keeps header-shaped value masking intact; a regression test with both an org-secret pattern and a header-name-mangling pattern (api[_-]?key) proves neither secret survives. Note: running redactToolPayloadText alone regresses the header-shaped case — a configured field-name pattern rewrites x-api-key to x-*** before the structured matcher sees it; the two-layer order is load-bearing and covered by the new test.

@clawsweeper

clawsweeper Bot commented Aug 9, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Aug 9, 2026
@clawsweeper clawsweeper Bot added the rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. label Aug 9, 2026
@jalehman
jalehman merged commit 37ca2c6 into openclaw:main Aug 17, 2026
152 checks passed
@jalehman

Copy link
Copy Markdown
Contributor

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 18, 2026
…penclaw#120205)

* fix(parallel): redact x-api-key reflected in web search error bodies

* fix(parallel): use canonical tool-payload redactor for reflected error bodies

* fix(parallel): layer configured redactPatterns over header-shape redaction
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

extensions: parallel P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants