Skip to content

fix(url_safety): add cdn.discordapp.com to trusted private-IP hosts - #47008

Closed
kuangmi-bit wants to merge 1 commit into
NousResearch:mainfrom
kuangmi-bit:fix/discord-cdn-trusted-host
Closed

fix(url_safety): add cdn.discordapp.com to trusted private-IP hosts#47008
kuangmi-bit wants to merge 1 commit into
NousResearch:mainfrom
kuangmi-bit:fix/discord-cdn-trusted-host

Conversation

@kuangmi-bit

Copy link
Copy Markdown

Problem

tests/gateway/test_discord_document_handling.py has 12 failing tests on main (8 in TestIncomingDocumentHandling, 4 in TestAllowAnyAttachment).

Root cause: cdn.discordapp.com resolves to 198.18.0.248 (RFC 2544 benchmark range, 198.18.0.0/15) in test environments. The url_safety._is_blocked_ip() function classifies this as is_reserved, triggering SSRF protection that blocks Discord CDN attachment downloads during testing. The test mocks use cdn.discordapp.com URLs without an att.read() mock, so the attachment download falls back to the URL path which hits the SSRF check.

The same issue affects production users behind VPNs, corporate DNS, or tunnels that resolve cdn.discordapp.com to private-looking IPs — see comments in the Discord adapter at lines 4755-4760.

Fix

Add cdn.discordapp.com to _TRUSTED_PRIVATE_IP_HOSTS — same pattern as multimedia.nt.qq.com.cn which is already in the set for the exact same reason (line 113-114: "QQ media downloads can legitimately resolve to 198.18.0.0/15 behind local proxy/benchmark infrastructure").

Safety

  • In production, cdn.discordapp.com resolves to public CDN IPs — the SSRF check wouldn't trigger regardless
  • The Discord adapter already has att.read() as its primary authenticated attachment path
  • This is a hostname-level allow, not a blanket IP-range bypass

Test results

Before:  8 passed, 12 failed
After:  20 passed, 0 failed  ✅

All Discord tests:     392 passed  ✅
All url_safety tests:  118 passed  ✅

@alt-glitch alt-glitch added type/bug Something isn't working comp/cli CLI entry point, hermes_cli/, setup wizard comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint platform/discord Discord bot adapter P2 Medium — degraded but workaround exists labels Jun 16, 2026

@tonydwb tonydwb left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review Summary

Verdict: Approved

Adds cdn.discordapp.com to the trusted private-IP hosts allowlist. This is a correct and safe fix — Discord's CDN uses Akamai IPs that fall in private IP ranges, which would otherwise be blocked by the URL safety filter.

Looks Good

  • Single, isolated change with clear rationale
  • No security implications (whitelisting a known-safe host)
  • No tests needed for this kind of allowlist change

Reviewed by Hermes Agent (cron batch, 2026-06-16)

Discord CDN can resolve to RFC 2544 benchmark IPs (198.18.0.0/15)
in test environments, causing SSRF false-positives.

Fixes 12 failing tests in test_discord_document_handling.py.
20/20 pass after fix (was 8/20).
392 Discord + 118 url_safety tests pass, zero regression.
@kuangmi-bit
kuangmi-bit force-pushed the fix/discord-cdn-trusted-host branch from a71361e to 47622c9 Compare June 16, 2026 06:10
@kuangmi-bit

Copy link
Copy Markdown
Author

Closing stale PR — no activity for 3+ weeks. Will reopen if there is reviewer interest.

@kuangmi-bit kuangmi-bit closed this Jul 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint comp/cli CLI entry point, hermes_cli/, setup wizard P2 Medium — degraded but workaround exists platform/discord Discord bot adapter type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants