Skip to content

fix: sort IPv4 addresses before IPv6 in SSRF pinned DNS resolution#24295

Merged
steipete merged 2 commits intoopenclaw:mainfrom
Glucksberg:fix/issue-23975
Feb 24, 2026
Merged

fix: sort IPv4 addresses before IPv6 in SSRF pinned DNS resolution#24295
steipete merged 2 commits intoopenclaw:mainfrom
Glucksberg:fix/issue-23975

Conversation

@Glucksberg
Copy link
Contributor

@Glucksberg Glucksberg commented Feb 23, 2026

Summary

  • Telegram media fetch fails on hosts with broken IPv6 because Node 24 changed the default dns-result-order to verbatim
  • Modified resolvePinnedHostnameWithPolicy() in src/infra/net/ssrf.ts to sort IPv4 addresses before IPv6 in the resolved address list
  • This ensures Happy Eyeballs (autoSelectFamily) and single-address round-robin try IPv4 first

Test plan

  • Added test verifying IPv4-before-IPv6 ordering in pinned DNS
  • All 20 SSRF tests pass
  • All 35 Telegram tests pass
  • TypeScript compiles cleanly

Fixes #23975

🤖 Generated with Claude Code

Greptile Summary

Modified resolvePinnedHostnameWithPolicy() in src/infra/net/ssrf.ts:280 to sort IPv4 addresses before IPv6 addresses in the resolved address list. This ensures Happy Eyeballs (autoSelectFamily) and single-address round-robin selection try IPv4 first, avoiding connection failures on hosts with broken IPv6 routing (common on cloud VMs and WSL2).

  • Sorts addresses using toSorted() with a comparator that checks for colons to differentiate IPv6 from IPv4
  • Preserves existing deduplication logic using Set
  • Added comprehensive test case verifying IPv4-before-IPv6 ordering
  • All 20 SSRF tests and 35 Telegram tests pass according to PR description

Confidence Score: 5/5

  • Safe to merge with no issues found
  • The implementation is simple, well-tested, and addresses a real production issue. The IPv6 detection logic using colon presence is reliable for all valid IP address formats, the sorting logic is straightforward, and test coverage validates the expected behavior. No security concerns or edge cases identified.
  • No files require special attention

Last reviewed commit: ca53435

@steipete
Copy link
Contributor

Triage: this looks merge-ready from CI status on the PR checks run (test/lint/protocol/checks all green in latest run).

Issue mapping: #23975 remains open and appears to be waiting on this merge.

steipete added a commit to Glucksberg/OpenClaw that referenced this pull request Feb 24, 2026
… (thanks @Glucksberg)

Co-Authored-By: Glucksberg <80581902+Glucksberg@users.noreply.github.com>
Glucksberg and others added 2 commits February 24, 2026 14:52
…am media fetch on IPv6-broken hosts

On hosts where IPv6 is configured but not routed (common on cloud VMs),
Telegram media downloads fail because the pinned DNS lookup may return
IPv6 addresses first. Even though autoSelectFamily (Happy Eyeballs) is
enabled, the round-robin pinned lookup serves individual IPv6 addresses
that fail before IPv4 is attempted.

Sort resolved addresses so IPv4 comes first, ensuring both Happy Eyeballs
and single-address round-robin try the working address family first.

Fixes openclaw#23975

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
… (thanks @Glucksberg)

Co-Authored-By: Glucksberg <80581902+Glucksberg@users.noreply.github.com>
@steipete steipete merged commit 3f07d72 into openclaw:main Feb 24, 2026
@steipete
Copy link
Contributor

Landed via temp rebase onto main.

  • Gate: pnpm lint && pnpm build && pnpm test (one unrelated flaky failure in src/process/exec.test.ts), then reran pnpm test -- src/process/exec.test.ts and pnpm test -- src/infra/net/ssrf.pinning.test.ts.
  • Land commit: 936991ca481518a17325a2f3cdb62fcb6d73449e
  • Merge commit: 3f07d725b177ab0c8a1c72db754e2eba06944998

Thanks @Glucksberg!

obviyus pushed a commit to Glucksberg/OpenClaw that referenced this pull request Feb 24, 2026
… (thanks @Glucksberg)

Co-Authored-By: Glucksberg <80581902+Glucksberg@users.noreply.github.com>
margulans pushed a commit to margulans/Neiron-AI-assistant that referenced this pull request Feb 25, 2026
… (thanks @Glucksberg)

Co-Authored-By: Glucksberg <80581902+Glucksberg@users.noreply.github.com>
Jackson3195 pushed a commit to Jackson3195/openclaw-with-a-personal-touch that referenced this pull request Feb 25, 2026
… (thanks @Glucksberg)

Co-Authored-By: Glucksberg <80581902+Glucksberg@users.noreply.github.com>
brianleach pushed a commit to brianleach/openclaw that referenced this pull request Feb 26, 2026
… (thanks @Glucksberg)

Co-Authored-By: Glucksberg <80581902+Glucksberg@users.noreply.github.com>
execute008 pushed a commit to execute008/openclaw that referenced this pull request Feb 27, 2026
… (thanks @Glucksberg)

Co-Authored-By: Glucksberg <80581902+Glucksberg@users.noreply.github.com>
r4jiv007 pushed a commit to r4jiv007/openclaw that referenced this pull request Feb 28, 2026
… (thanks @Glucksberg)

Co-Authored-By: Glucksberg <80581902+Glucksberg@users.noreply.github.com>
hughdidit pushed a commit to hughdidit/DAISy-Agency that referenced this pull request Mar 1, 2026
… (thanks @Glucksberg)

Co-Authored-By: Glucksberg <80581902+Glucksberg@users.noreply.github.com>
(cherry picked from commit 3f07d72)

# Conflicts:
#	CHANGELOG.md
hughdidit pushed a commit to hughdidit/DAISy-Agency that referenced this pull request Mar 3, 2026
… (thanks @Glucksberg)

Co-Authored-By: Glucksberg <80581902+Glucksberg@users.noreply.github.com>
(cherry picked from commit 3f07d72)

# Conflicts:
#	CHANGELOG.md
joelnishanth pushed a commit to joelnishanth/openclaw that referenced this pull request Mar 3, 2026
… (thanks @Glucksberg)

Co-Authored-By: Glucksberg <80581902+Glucksberg@users.noreply.github.com>
zooqueen pushed a commit to hanzoai/bot that referenced this pull request Mar 6, 2026
… (thanks @Glucksberg)

Co-Authored-By: Glucksberg <80581902+Glucksberg@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Telegram media fetch fails on IPv6-broken hosts (Node 24 dns-result-order not respected)

2 participants