Skip to content

fix(ssrf): unwrap IPv6 transition addresses in the URL guard - #19517

Merged
JinHai-CN merged 2 commits into
infiniflow:mainfrom
aroh3006:fix-ssrf-ipv6-transition
Sep 11, 2026
Merged

JinHai-CN merged 2 commits into
infiniflow:mainfrom
aroh3006:fix-ssrf-ipv6-transition

Conversation

@aroh3006

Copy link
Copy Markdown
Contributor

Summary

The shared SSRF guard (common/ssrf_guard.py and its Go mirror internal/utility/ssrf.go) resolves the target hostname and rejects it if any resolved address is not globally routable. The routability check looks at the address as-is but never unwraps the IPv4 address embedded in an IPv6 transition address, so a hostname whose AAAA record is something like 64:ff9b::a9fe:a9fe (NAT64 well-known prefix wrapping 169.254.169.254) or 2002:7f00:1::1 (6to4 wrapping 127.0.0.1) passes the guard. In a deployment that has NAT64/DNS64 (common for IPv6-only clusters) that address routes to the embedded IPv4, so a user-supplied URL fed to the crawler, the Invoke component, the markdown image loader, the data-source connectors, etc. can still reach the cloud metadata endpoint or a loopback service.

This unwraps 6to4, NAT64 (well-known and local-use prefixes), Teredo and the deprecated IPv4-compatible form and re-checks the embedded address in both implementations. A NAT64 address that wraps a public IPv4 stays allowed so IPv6-only egress keeps working. On the Go side I also added a 0.0.0.0/8 check, which Python's is_global already covered. This is the same class as CVE-2026-73087 (Dozzle) and GHSA-4q5r-r938-8xr2 (eKuiper).

The other Go guards (internal/agent/tool/ssrf.go, internal/parser/parser/markdown_parser.go, internal/syncer/connector/rest_api.go) have the same gap and could get the same treatment in a follow-up; internal/service/agent_dbcheck.go already blocks these prefixes.

Testing

go test ./internal/utility/ and the new test/unit_test/common/test_ssrf_guard.py pass. I confirmed fail-before/pass-after for each new case (the transition-address URLs are accepted by the current guard and rejected after the change), and the existing guard test cases still pass. Ran gofmt, go vet and ruff on the touched files.

The shared SSRF guard checked the resolved address with is_global /
IsLoopback|IsPrivate but never looked at the IPv4 address embedded in an
IPv6 transition address. An AAAA record like 64:ff9b::a9fe:a9fe (NAT64
wrapping 169.254.169.254) or 2002:7f00:1::1 (6to4 wrapping 127.0.0.1)
passed the check, so a caller could still reach cloud metadata or a
loopback service.

Unwrap 6to4, NAT64, Teredo and the deprecated IPv4-compatible form and
re-check the embedded address, in the Go guard and its Python mirror. A
NAT64 address wrapping a public IPv4 stays allowed. Same class as
CVE-2026-73087 (Dozzle).
@coderabbitai

coderabbitai Bot commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: 0eba80b8-d377-4139-aed2-7f73ee6c2521

📥 Commits

Reviewing files that changed from the base of the PR and between 3e30a47 and c608bec.

📒 Files selected for processing (4)
  • common/ssrf_guard.py
  • internal/utility/ssrf.go
  • internal/utility/ssrf_test.go
  • test/unit_test/common/test_ssrf_guard.py

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.


📝 Walkthrough

Walkthrough

The SSRF guards now normalize IPv6 addresses that contain IPv4 values and reject non-global embedded destinations. Tests cover zero-network IPv4, 6to4, NAT64, Teredo, IPv4-compatible addresses, and public NAT64 targets.

Changes

SSRF validation

Layer / File(s) Summary
IPv6 address normalization and Python coverage
common/ssrf_guard.py, test/unit_test/common/test_ssrf_guard.py
The shared guard unwraps IPv4-mapped, NAT64, and IPv4-compatible IPv6 addresses. Tests verify allowed public addresses and rejected non-public targets.
Transition-address checks and Go coverage
internal/utility/ssrf.go, internal/utility/ssrf_test.go
The Go guard rejects 0.0.0.0/8 and checks embedded IPv4 values in 6to4, NAT64, Teredo, and IPv4-compatible addresses. Tests cover these representations.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Merge Risk: ⚪ Minimal · up to 6f42c

The guards now reject embedded private, loopback, and metadata-service addresses while allowing public NAT64 destinations. The added coverage and reported checks support merging with no concrete blocking risk identified.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 12 functions across 4 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: unwrapping IPv6 transition addresses in the SSRF URL guard.
Description check ✅ Passed The description includes the required Summary section and provides clear background, affected components, implementation details, security impact, follow-up scope, and testing information.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

A rabbit checks each address bright
Through tunnels hidden out of sight
NAT64 paths now meet the gate
Private hops can no longer wait
Public roads remain in flight
Safe packets thump into the night

Comment @coderabbitai help to get the list of available commands.

@JinHai-CN JinHai-CN self-assigned this Sep 11, 2026
@JinHai-CN JinHai-CN added the ci Continue Integration label Sep 11, 2026
@codecov

codecov Bot commented Sep 11, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 37.37%. Comparing base (2e6003c) to head (6f42c96).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #19517   +/-   ##
=======================================
  Coverage   37.37%   37.37%           
=======================================
  Files          54       54           
  Lines       15374    15374           
  Branches      125      125           
=======================================
  Hits         5746     5746           
  Misses       9601     9601           
  Partials       27       27           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@JinHai-CN
JinHai-CN merged commit ea2ce6d into infiniflow:main Sep 11, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci Continue Integration

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants