Skip to content

refactor(agent): reject non-global destinations - #20461

Merged
yuzhichang merged 1 commit into
infiniflow:mainfrom
6ba3i:refactor/agent-tool-ssrf-s3
Sep 30, 2026
Merged

yuzhichang merged 1 commit into
infiniflow:mainfrom
6ba3i:refactor/agent-tool-ssrf-s3

Conversation

@6ba3i

@6ba3i 6ba3i commented Sep 30, 2026

Copy link
Copy Markdown
Collaborator

Tool connections allowed special-use addresses rejected by the shared safety check. This change uses the shared policy while preserving pinned destinations and existing error handling.

Constraint: Preserve pinned public destinations and existing tool error handling.

Rejected: Maintain a separate range list | Shared host validation is the repository policy.

Confidence: high

Scope-risk: narrow

Directive: Keep every tool destination behind the shared safety policy.

Tested: SSRF unit tests, race tests, build, Compose, live ExeSQL API.

Not-tested: GPU runtime.
@coderabbitai

coderabbitai Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

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: e9860cd6-390c-460b-9831-7e91059dcdfb

📥 Commits

Reviewing files that changed from the base of the PR and between eb100d1 and 0ac21a2.

📒 Files selected for processing (3)
  • internal/agent/tool/exesql_ssrf_test.go
  • internal/agent/tool/ssrf.go
  • internal/agent/tool/ssrf_test.go

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 6 remain after this review.


📝 Walkthrough

Walkthrough

SSRF host validation now uses common.AssertHostSafe for literal and DNS-resolved addresses. Tests cover additional non-global IPv4 and IPv6 ranges, mixed DNS results, and rejection before dialing.

Changes

SSRF address validation

Layer / File(s) Summary
Shared host address checks
internal/agent/tool/ssrf.go
ResolveAndValidate and ValidateDBHost now use isNonGlobalIP for literal and resolved addresses. The helper delegates address checks to common.AssertHostSafe and treats nil IPs as non-global.
Non-global address rejection tests
internal/agent/tool/ssrf_test.go, internal/agent/tool/exesql_ssrf_test.go
Tests add coverage for additional non-global IPv4 and IPv6 addresses, mixed DNS results, and rejection without dialing.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~12 minutes

Change: Bug fix

Suggested reviewers: jinhai-cn

Merge Risk: ⚪ Minimal · up to 0ac21

The change broadens destination blocking while preserving existing rejection behavior. No actionable merge-blocking issue is established; merge after normal checks pass.

Security Architecture Review

Security architecture risk: ⚪ Minimal · up to 0ac21

The change strengthens destination filtering while preserving validation before connection, DNS destination pinning, and existing error handling. The reviewed change introduces no material security regression, and no verified security findings remain.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The affected authority is server-side outbound connectivity governed by the URL and database-host validators. A node author controls the configured database destination, but the reviewed change narrows the destinations that can reach the existing connection sink rather than adding a new sink or privilege.

Security Findings and Attack Paths

  • observed — The regression-test source asserts that a public DNS answer followed by a benchmarking-range answer produces ErrSSRFBlocked with zero ExeSQL dialer calls. URL-validator tests likewise assert rejection with no returned host or pinned IP. These assertions target mixed-answer bypasses; they are not evidence of tests executed during this review.

Trust Boundaries and Controls

  • observed — Database destination validation precedes connection-string construction and dialing. Only the validated IP replaces the configured host; the connection builder continues to consume the existing username, password, database, and port. Classification therefore strengthens the destination boundary without changing credential ownership.

Resilience and Maintainability Implications

  • observed — Normal validation keeps candidate destinations local until the complete answer set passes. Lookup, parse, empty-result, and prohibited-address failures return without an authorized destination. ExeSQL retains deferred connection cleanup after successful dialer return and its existing timeout and error paths; the policy substitution adds no shared mutable destination state.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 55.56% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 9 functions across 3 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: rejecting non-global destinations in the agent.
Description check ✅ Passed The description states the purpose and key behavior of the change. It omits the template's "### Summary" heading and provides limited background, but the required intent is mostly covered.
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.
  • Fix all pre-merge checks with AI

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 on the trail,
“This range is blocked,” goes the quiet call.
Public and private answers arrive,
Yet no database dial can start.
The burrow stays safe beneath the moon.

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

@6ba3i
6ba3i requested a review from wangq8 September 30, 2026 08:35
@6ba3i 6ba3i added the ci Continue Integration label Sep 30, 2026
@6ba3i
6ba3i requested a review from yuzhichang September 30, 2026 10:43
@yuzhichang
yuzhichang merged commit 3c0d02f into infiniflow:main Sep 30, 2026
6 checks passed
@6ba3i
6ba3i deleted the refactor/agent-tool-ssrf-s3 branch October 14, 2026 03:12
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