Skip to content

fix(discord): add SSRF policy for Discord CDN to unblock Clash TUN fake-ip#27581

Open
white-rm wants to merge 2 commits intoopenclaw:mainfrom
white-rm:fix/27534-discord-image-clash-tun
Open

fix(discord): add SSRF policy for Discord CDN to unblock Clash TUN fake-ip#27581
white-rm wants to merge 2 commits intoopenclaw:mainfrom
white-rm:fix/27534-discord-image-clash-tun

Conversation

@white-rm
Copy link
Copy Markdown

@white-rm white-rm commented Feb 26, 2026

Summary

Fixes #27534

Discord image attachments fail to download when running behind Clash TUN mode (fake-ip enabled). The Clash fake-ip range (198.18.0.0/15, RFC 2544 benchmark) is correctly blocked by OpenClaw's SSRF protection, but this also blocks legitimate Discord CDN downloads when DNS resolves to fake-ip addresses.

  • Add DISCORD_MEDIA_SSRF_POLICY that trusts cdn.discordapp.com and media.discordapp.net, and allows the RFC 2544 benchmark IP range
  • Apply the policy to both attachment and sticker downloads in fetchRemoteMedia calls
  • This follows the same pattern already used by the Telegram channel (TELEGRAM_MEDIA_SSRF_POLICY in src/telegram/bot/delivery.ts)

Test plan

  • Existing message-utils.test.ts tests updated and passing (20/20)
  • Manual test: send image via Discord DM behind Clash TUN mode → image should be downloaded and passed to model correctly

@openclaw-barnacle openclaw-barnacle bot added channel: discord Channel integration: discord size: XS labels Feb 26, 2026
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Feb 26, 2026

Greptile Summary

Added DISCORD_MEDIA_SSRF_POLICY to allow Discord CDN downloads when running behind Clash TUN mode (fake-ip enabled). The policy trusts cdn.discordapp.com and media.discordapp.net, and allows the RFC 2544 benchmark IP range (198.18.0.0/15) used by Clash fake-ip.

  • Applied the policy to both attachment and sticker downloads in fetchRemoteMedia calls
  • Follows the same pattern as the existing TELEGRAM_MEDIA_SSRF_POLICY
  • All 20 tests updated and passing

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • The implementation is straightforward, follows an established pattern (Telegram media SSRF policy), and properly addresses the issue. The changes are minimal, well-tested, and security implications are correctly handled by scoping the allowlist to specific Discord CDN hostnames.
  • No files require special attention

Last reviewed commit: 6442ff9

@bmendonca3
Copy link
Copy Markdown
Contributor

Security review note:

Good fix direction for Discord CDN under fake-IP/TUN setups.

Evidence I checked:

  • src/discord/monitor/message-utils.ts now sets:
    • allowedHostnames: ["cdn.discordapp.com", "media.discordapp.net"]
    • allowRfc2544BenchmarkRange: true
  • Tests were updated to assert that policy is passed.

One security follow-up I’d like:

  • Add a negative test showing non-Discord hostnames in RFC2544 ranges are still blocked (to confirm the hostname allowlist remains authoritative and this range exception does not widen trust accidentally).

CI failures currently look baseline-related (protocol drift + shared Windows loader test), not obviously from this diff.

@thewilloftheshadow
Copy link
Copy Markdown
Member

Superseded by #33275: #33275

@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 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: discord Channel integration: discord size: XS stale Marked as stale due to inactivity

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Discord images incorrectly passed to model behind Clash TUN (fake-ip SSRF block + stale image after fix)

4 participants