Skip to content

fix(slack): strip SSRF dispatcher from media fetch to prevent undici version conflict - #64022

Closed
mjamiv wants to merge 2 commits into
openclaw:mainfrom
mjamiv:fix/slack-media-dispatcher-conflict
Closed

mjamiv wants to merge 2 commits into
openclaw:mainfrom
mjamiv:fix/slack-media-dispatcher-conflict

Conversation

@mjamiv

@mjamiv mjamiv commented Apr 10, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes #63905 — Slack inbound attachments silently fail with invalid onRequestStart method in container/sandbox deployments.

Root cause: fetchWithSsrFGuard injects a pinned undici 8.x dispatcher into the init object, then delegates to createSlackMediaFetch(). That function spreads ...init (including the dispatcher) into fetchWithRuntimeDispatcher, which creates its own dispatcher. The two dispatchers from different undici major versions (bundled 8.x vs Node's built-in 7.x) collide, throwing the error. Every Slack attachment download silently fails and the agent only sees placeholder text.

Fix: Use the presence of dispatcher in init as a routing signal (runtime fetch vs global fetch) but strip the dispatcher itself before forwarding. Same pattern as #63984 (BlueBubbles).

Changes

  • extensions/slack/src/monitor/media.ts — Destructure dispatcher out of init in createSlackMediaFetch before delegating
  • extensions/slack/src/monitor/media.test.ts — Update assertion: dispatcher should NOT be forwarded to runtime fetch

Verification

Tested on a production OpenClaw v2026.4.9 instance running in an OpenShell sandbox with Slack channel integration. Before the fix, all inbound PDF/image attachments produced only placeholder text. After applying the equivalent patch to the dist bundle (actions-BsuJQp72.js), attachments download and the agent analyzes full file content with zero fetch errors.

@greptile-apps

greptile-apps Bot commented Apr 10, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR fixes a silent failure in Slack inbound attachment downloads caused by two undici dispatcher instances from different major versions colliding. The fix in createSlackMediaFetch now destructures and discards the upstream SSRF guard's dispatcher from init before forwarding to fetchWithRuntimeDispatcher, while still using its presence as the routing signal. The accompanying test assertion is correctly updated to verify the dispatcher is absent in the forwarded call.

Confidence Score: 5/5

Safe to merge — targeted two-line logic change with a matching test update and no side effects on other code paths.

The fix is minimal and correct: it strips the upstream dispatcher before delegating (preventing the undici collision) while preserving the routing signal. Both the happy path and the fallback (mocked fetch in tests) remain correct. No other files are affected.

No files require special attention.

Reviews (1): Last reviewed commit: "fix(slack): strip SSRF dispatcher from S..." | Re-trigger Greptile

@mjamiv

mjamiv commented Apr 10, 2026

Copy link
Copy Markdown
Contributor Author

Note: this fix also covers the code path addressed by #63401 (stripping dispatcher before globalThis.fetch). Since we destructure dispatcher out before choosing the fetch impl, both the fetchWithRuntimeDispatcher and globalThis.fetch branches receive clean init. These two PRs are complementary but this one is the broader fix.

cc @martingarramon — your confirmation of the root cause on #63905 matches exactly. The #62551 / #62530 / #62239 lineage you mentioned is helpful context.

@mjamiv

mjamiv commented Apr 11, 2026

Copy link
Copy Markdown
Contributor Author

Cross-link for reviewer context: PR #64766 was merged on 2026-04-11 and touches the same fetchWithSsrFGuard surface this PR modifies — it disables the pinned DNS dispatcher on the FormData transcription code path and tightens hostname validation on the pinDns: false branch. The two changes are complementary (#64766 covers multipart FormData; this PR covers the Slack inbound media onRequestStart case), but they live in the same file, so reviewing them together may be efficient. Happy to rebase if there's a conflict after #64766 landed.

Molt added 2 commits April 13, 2026 11:48
…ndici version conflict

When `fetchWithSsrFGuard` delegates to `createSlackMediaFetch`, it injects a
pinned undici 8.x dispatcher into the `init` object. `createSlackMediaFetch`
then spreads `...init` (including that dispatcher) into
`fetchWithRuntimeDispatcher`, which creates its own dispatcher. The two
dispatchers from different undici versions collide, causing "invalid
onRequestStart method" errors that silently drop all inbound Slack attachments.

Fix: use the presence of `dispatcher` in `init` as a routing signal (runtime
fetch vs global fetch) but strip it before forwarding. This matches the
approach taken in openclaw#63984 (BlueBubbles) for the same root cause.

Fixes openclaw#63905
The dispatcher-strip fix added 7 lines to createSlackMediaFetch, shifting
the three pre-existing fetch() callsites in fetchWithSlackAuth from lines
96/115/120 to 103/122/127.
@mjamiv
mjamiv force-pushed the fix/slack-media-dispatcher-conflict branch from ff59c9c to b6cdc58 Compare April 13, 2026 11:51
@openclaw-barnacle openclaw-barnacle Bot added the scripts Repository scripts label Apr 13, 2026
@clawsweeper

clawsweeper Bot commented Apr 27, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge.

Summary
The PR strips the SSRF guard dispatcher from Slack media fetch init before delegating, updates the focused Slack media test expectation, and adjusts raw-fetch allowlist line numbers.

Reproducibility: yes. at source level. The linked issue at #63905 gives Slack container steps and invalid onRequestStart method logs, and current main still forwards the guard-created dispatcher through createSlackMediaFetch; I did not run a live Slack workspace.

Real behavior proof
Needs real behavior proof before merge: The PR body claims production validation, but no inspectable after-fix proof is attached; the contributor should add redacted logs, terminal output, screenshot, recording, or linked artifact and update the PR body to trigger re-review.

Next step before merge
Human review is needed for the Slack SSRF transport decision, contributor-provided real behavior proof, and a branch refresh; this should not be sent to an automated repair lane first.

Security
Needs attention: The diff strips the SSRF guard's pinned dispatcher from Slack media's final fetch path, changing enforcement unless maintainers approve that contract.

Review findings

  • [P2] Preserve guarded dispatcher enforcement — extensions/slack/src/monitor/media.ts:88-96
  • [P2] Drop the stale raw-fetch allowlist update — scripts/check-no-raw-channel-fetch.mjs:60-62
Review details

Best possible solution:

Land a refreshed Slack media fix that removes the Undici dispatcher conflict while preserving Slack URL validation, auth headers, redirect behavior, and an approved SSRF enforcement contract.

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

Yes, at source level. The linked issue at #63905 gives Slack container steps and invalid onRequestStart method logs, and current main still forwards the guard-created dispatcher through createSlackMediaFetch; I did not run a live Slack workspace.

Is this the best way to solve the issue?

No, not as currently proposed. Stripping the dispatcher matches the observed failure mode, but this patch needs an approved Slack SSRF transport contract or an enforcement-preserving fix, plus a refreshed allowlist update and real behavior proof.

Full review comments:

  • [P2] Preserve guarded dispatcher enforcement — extensions/slack/src/monitor/media.ts:88-96
    This strips the dispatcher that fetchWithSsrFGuard attached before the actual Slack media request. That dispatcher is the pinned-DNS enforcement path; fetchWithRuntimeDispatcher only forwards init and does not rebuild equivalent enforcement, so this should preserve guarded transport or carry an explicit maintainer/security decision for a Slack preflight-only contract.
    Confidence: 0.86
  • [P2] Drop the stale raw-fetch allowlist update — scripts/check-no-raw-channel-fetch.mjs:60-62
    The branch rewrites Slack raw-fetch allowlist entries to line numbers from an old base, while current main's Slack allowlist entries are lines 106, 125, and 130. A refreshed branch should keep or regenerate current main's allowlist entries instead of carrying these stale values.
    Confidence: 0.85

Overall correctness: patch is incorrect
Overall confidence: 0.87

Security concerns:

  • [medium] Pinned DNS dispatcher stripped — extensions/slack/src/monitor/media.ts:88
    Removing the guard-created dispatcher before fetching Slack media changes the request from dispatcher-enforced SSRF protection to preflight-only validation unless maintainers explicitly approve that trade-off or replace it with an enforcement-preserving transport fix.
    Confidence: 0.86

Acceptance criteria:

  • node scripts/run-vitest.mjs extensions/slack/src/monitor/media.test.ts
  • pnpm exec oxfmt --check --threads=1 extensions/slack/src/monitor/media.ts extensions/slack/src/monitor/media.test.ts scripts/check-no-raw-channel-fetch.mjs
  • node scripts/crabbox-wrapper.mjs run ... --shell -- "pnpm check:changed"
  • Redacted real Slack/container attachment proof showing after-fix materialization without invalid onRequestStart method

What I checked:

  • Current Slack wrapper forwards the guarded dispatcher: Current main still routes dispatcher-backed Slack media requests to fetchWithRuntimeDispatcher and forwards { ...init, redirect: "manual" }, preserving the upstream dispatcher in the delegated request. (extensions/slack/src/monitor/media.ts:94, b9921e21b93d)
  • Current test expects dispatcher forwarding: The current Slack media regression test asserts that the runtime fetch init still contains dispatcher, so the PR reverses an existing guarded-transport expectation. (extensions/slack/src/monitor/media.test.ts:924, b9921e21b93d)
  • SSRF guard attaches dispatcher before delegation: fetchWithSsrFGuard builds request init with dispatcher before calling the selected fetch implementation; stripping it in Slack changes the final transport enforcement shape. (src/infra/net/fetch-guard.ts:456, b9921e21b93d)
  • Runtime fetch does not recreate a stripped pinned dispatcher: fetchWithRuntimeDispatcher loads the Undici runtime fetch and forwards normalized init; it does not rebuild equivalent pinned-DNS enforcement after Slack removes the guard dispatcher. (src/infra/net/runtime-fetch.ts:86, b9921e21b93d)
  • PR head strips dispatcher from final Slack media fetch: The PR destructures dispatcher out of init before forwarding to the selected fetch implementation, which matches the reported Undici conflict but changes the guarded transport contract. (extensions/slack/src/monitor/media.ts:88, b6cdc58c7338)
  • Raw-fetch allowlist update is stale against current main: Current main's Slack allowlist entries are lines 106, 125, and 130, while the PR changes old-base entries to 103, 122, and 127. (scripts/check-no-raw-channel-fetch.mjs:59, b9921e21b93d)

Likely related people:

  • steipete: Recent GitHub history shows repeated current-main Slack media and bounded-download work in the same file this PR changes. (role: recent area contributor; confidence: high; commits: 8859e89e075e, e71ef41c95b9, 5a1ff1347dfa; files: extensions/slack/src/monitor/media.ts, extensions/slack/src/monitor/media.test.ts)
  • vincentkoc: Recent history credits this handle with Slack media redirect/auth handling and malformed redirect work in the affected files. (role: adjacent Slack media contributor; confidence: high; commits: 55cbcd829d38, d41907a5cb2c; files: extensions/slack/src/monitor/media.ts, extensions/slack/src/monitor/media.test.ts)
  • openperf: The merged guarded Slack media transport work in the same dispatcher/fetch path was credited to this handle. (role: adjacent behavior contributor; confidence: high; commits: 6e4861999d46, e8fb14064207; files: extensions/slack/src/monitor/media.ts, extensions/slack/src/monitor/media.test.ts)
  • obviyus: History and PR metadata show this handle landing the prior guarded Slack transport fix and adjacent pinDns/fetch-guard work. (role: merger and adjacent transport refiner; confidence: medium; commits: e8fb14064207, 43bd5545f839; files: extensions/slack/src/monitor/media.ts, src/infra/net/fetch-guard.ts)
  • GodsBoy: Authored merged work around pinDns=false and SSRF hostname validation in the same fetch-guard contract implicated by this PR. (role: adjacent fetch-guard contributor; confidence: medium; commits: c159d22b34fa, 43bd5545f839; files: src/infra/net/fetch-guard.ts, src/media-understanding/openai-compatible-audio.ts)

Remaining risk / open question:

  • The proposed dispatcher strip changes Slack media from dispatcher-enforced SSRF transport to a preflight-only final request unless maintainers explicitly approve that contract or choose an enforcement-preserving alternative.
  • The branch is conflicting/stale against current main, and its raw-fetch allowlist update no longer matches the current Slack callsite lines.
  • The PR body describes production validation, but no inspectable redacted logs, terminal output, screenshot, recording, or linked artifact is attached.

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

@mjamiv

mjamiv commented May 1, 2026

Copy link
Copy Markdown
Contributor Author

Conflict review update:

  • The branch currently has no merge-base with current main, so GitHub's CONFLICTING state is not a small ordinary merge conflict. The clean refresh path is to rebuild from current main.
  • Cherry-picking 757635ac55 (fix(slack): strip SSRF dispatcher from Slack media fetch to prevent undici version conflict) onto current main applies cleanly.
  • Cherry-picking b6cdc58c73 conflicts only in scripts/check-no-raw-channel-fetch.mjs.
  • For that script conflict, current main appears to be the right side to keep: Slack allowlist lines are now 106, 125, and 130. The PR side has stale Slack line numbers 103, 122, and 127, plus stale Tlon entries. I did not find raw fetch( calls under extensions/tlon/src on current main, so the Tlon additions do not look needed.
  • In a temporary worktree, keeping current main's allowlist entries left no conflict markers and git diff --check passed.

I am not pushing a refresh from automation because the security decision is still the blocker: this patch strips the SSRF guard's pinned dispatcher from the actual Slack media request. That may be acceptable only if maintainers explicitly approve a Slack-specific preflight-only contract. Otherwise the safer direction is to preserve pinned dispatcher enforcement while fixing the Undici version collision.

Recommended next step: maintainer decides the Slack transport contract first; after that, rebuild the PR on current main, keep the Slack source/test change if approved, drop/regenerate the stale allowlist commit, then run:

  • pnpm test extensions/slack/src/monitor/media.test.ts
  • pnpm exec oxfmt --check --threads=1 extensions/slack/src/monitor/media.ts extensions/slack/src/monitor/media.test.ts scripts/check-no-raw-channel-fetch.mjs
  • pnpm check:changed

@mjamiv

mjamiv commented May 16, 2026

Copy link
Copy Markdown
Contributor Author

Closing this from my side rather than keeping a stale, conflicting, security-sensitive PR open. The underlying Slack media / Undici dispatcher issue still looks real, but this branch strips the SSRF guard dispatcher from the final Slack media request and now conflicts with current main. If maintainers want the Slack-specific preflight-only contract, the clean path is to rebuild from current main with the raw-fetch allowlist regenerated; otherwise the safer replacement should preserve pinned-dispatcher enforcement while fixing the Undici version collision.

@mjamiv mjamiv closed this May 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: slack Channel integration: slack scripts Repository scripts size: XS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(slack): inbound attachments in container sandbox fail with placeholder-only turn and fetch error 'invalid onRequestStart method'

1 participant