Skip to content

Fix outbound metadata leaking through reply normalization - #39894

Closed
JuncongHe wants to merge 4 commits into
openclaw:mainfrom
JuncongHe:fix/39847-strip-outbound-metadata
Closed

JuncongHe wants to merge 4 commits into
openclaw:mainfrom
JuncongHe:fix/39847-strip-outbound-metadata

Conversation

@JuncongHe

Copy link
Copy Markdown
Contributor

Closes #39847

Summary

  • strip echoed inbound metadata before outbound reply directive parsing
  • keep MEDIA directive parsing intact after metadata removal
  • add a regression test for metadata + MEDIA payloads

Reproduction

  • parseReplyDirectives(payload.text) preserved Conversation info (untrusted metadata) blocks in outbound text on origin/main
  • the added test covers the same normalization path used before delivery

Validation

  • pnpm exec vitest --run src/infra/outbound/outbound.test.ts
  • pnpm exec vitest run src/infra/outbound/outbound.test.ts src/auto-reply/reply/strip-inbound-meta.test.ts --reporter=verbose

@JuncongHe
JuncongHe force-pushed the fix/39847-strip-outbound-metadata branch from 1598c05 to 63b8404 Compare March 8, 2026 14:02
@openclaw-barnacle openclaw-barnacle Bot added app: macos App: macos size: L scripts Repository scripts and removed size: XS labels Mar 8, 2026
@JuncongHe
JuncongHe force-pushed the fix/39847-strip-outbound-metadata branch from 7750d4d to 7524147 Compare March 8, 2026 14:35
@openclaw-barnacle openclaw-barnacle Bot added size: S and removed app: macos App: macos size: L labels Mar 8, 2026
@openclaw-barnacle openclaw-barnacle Bot added the app: macos App: macos label Mar 8, 2026
@openclaw-barnacle

Copy link
Copy Markdown

This pull request has been automatically marked as stale due to inactivity.
Please add updates or it will be closed.

@openclaw-barnacle openclaw-barnacle Bot added the stale Marked as stale due to inactivity label Apr 25, 2026
@clawsweeper

clawsweeper Bot commented Apr 26, 2026 •

Copy link
Copy Markdown
Contributor

Thanks for the context here. I swept through the related work, and this is now duplicate or superseded.

This stale draft PR should close as superseded: the underlying outbound metadata leak is still valid, but #50520 is the fresher canonical fix path, while this branch patches an obsolete loop and also carries unrelated security-sensitive CI/macOS/test-runner changes.

So I’m closing this here and keeping the remaining discussion on the canonical linked item.

Review details

Best possible solution:

Review and land #50520 or an equivalent focused replacement that fixes the shared outbound payload plan without carrying this PR's unrelated CI/macOS/test-runner changes.

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

Yes. Source inspection shows a payload beginning with OpenClaw inbound metadata still reaches createOutboundPayloadPlanEntry, which calls parseReplyDirectives on raw payload.text before stripping.

Is this the best way to solve the issue?

No. This PR is not the best fix as-is because it patches an obsolete normalization loop, applies the broader timestamp-stripping helper, and mixes in unrelated CI/macOS changes; the narrower current-main solution is the open canonical PR's stripLeadingInboundMetadata call at the payload-plan boundary.

Security review:

Security review needs attention: The outbound fix idea reduces a privacy leak, but this PR adds an unrelated CI path that exposes GITHUB_TOKEN to contributor-controlled JavaScript.

  • [medium] PR-controlled helper receives GITHUB_TOKEN — .github/workflows/ci.yml:304
    The Detect secrets step adds GITHUB_TOKEN and then invokes scripts/ci-list-pr-files.mjs from the checked-out PR branch, allowing contributor-controlled code in the same PR to read the workflow token.
    Confidence: 0.87

What I checked:

  • Live PR state: The current PR is open, draft, dirty, and its head is fc793d2; the live comments already include a prior ClawSweeper review with blocking correctness and security findings. (fc793d26b532)
  • Current main parse point: Current main still parses raw payload text in createOutboundPayloadPlanEntry before any inbound metadata stripping; normalizeReplyPayloadsForDelivery is now only a wrapper around createOutboundPayloadPlan, so the PR's old-loop patch is stale against the active boundary. (src/infra/outbound/payloads.ts:145, ac323020c5c2)
  • Unsafe broad helper for this call site: stripInboundMetadata removes a leading OpenClaw timestamp even on the no-sentinel fast path, while current main also has stripLeadingInboundMetadata for narrower leading metadata cleanup. (src/auto-reply/reply/strip-inbound-meta.ts:188, ac323020c5c2)
  • Security-sensitive unrelated diff: The PR adds GITHUB_TOKEN to the Detect secrets step and then runs scripts/ci-list-pr-files.mjs from the contributor-controlled PR checkout, unrelated to the outbound metadata leak fix. (.github/workflows/ci.yml:304, fc793d26b532)
  • Superseding canonical PR: The linked issue discussion identifies fix(outbound): strip inbound metadata before delivery #50520 as the canonical fix; that PR is open, non-draft, scoped to the outbound payload plan and sanitizer tests, and its latest reviewed head is 94781b4ef093d23d3d3bf469258d879f455c8728. (94781b4ef093)
  • Feature history: Remote commit history for the central files ties the active payload-plan boundary to c476409 and the metadata stripper to a4e7e95, with repeated recent outbound/metadata work by steipete. (src/infra/outbound/payloads.ts:138, c4764095f859)

Likely related people:

  • joshavant: Authored the commit that centralized outbound payload normalization in src/infra/outbound/payloads.ts, the current parse boundary implicated by this bug. (role: introduced outbound plan boundary; confidence: high; commits: c4764095f859; files: src/infra/outbound/payloads.ts, src/infra/outbound/payloads.test.ts)
  • Mellowambience: Introduced strip-inbound-meta.ts and its original user-visible inbound metadata stripping tests, which define the sanitizer behavior reused by the canonical fix path. (role: introduced metadata stripping utility; confidence: high; commits: a4e7e952e143; files: src/auto-reply/reply/strip-inbound-meta.ts, src/auto-reply/reply/strip-inbound-meta.test.ts)
  • steipete: Remote history shows repeated recent work around outbound payload handling, delivery, and inbound metadata hardening near the affected boundary. (role: recent adjacent contributor; confidence: high; commits: a4b17d65a8ff, aac84372abd5, b99666a47aef; files: src/infra/outbound/payloads.ts, src/infra/outbound/deliver.ts, src/auto-reply/reply/strip-inbound-meta.ts)

Codex review notes: model gpt-5.5, reasoning high; reviewed against ac323020c5c2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: macos App: macos scripts Repository scripts size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Echo contamination: stripInboundMetadata not called in outbound delivery pipeline

1 participant