Skip to content

refactor(think): share the private-host policy with agents/webfetch - #2521

Merged
ben-reitz merged 1 commit into
web-fetch/toolfrom
web-fetch/think
Oct 8, 2026
Merged

ben-reitz merged 1 commit into
web-fetch/toolfrom
web-fetch/think

Conversation

@ben-reitz

@ben-reitz ben-reitz commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Summary

One SSRF list instead of two. Think's fetch_url drops its own isBlockedHost/isBlockedIpv4/isBlockedIpv6 and uses the policy from #2526, at the request and at every redirect hop. No new tool for Think in this stack.

 packages/think/src/tools/fetch.ts
-  isBlockedHost / isBlockedIpv4 / isBlockedIpv6      # ~60 lines, its own ranges
+  import { isPrivateOrLocalHost } from "agents/webfetch"
   fetchUrl(url)
-    if isBlockedHost(url.hostname) → disallowed_url
+    if isPrivateOrLocalHost(url.hostname) → disallowed_url
   onRedirect(next)
-    if isBlockedHost(next.hostname) → disallowed_redirect
+    if isPrivateOrLocalHost(next.hostname) → disallowed_redirect

fetch_url keeps every block it had and gains 192.0.0/24, 198.18/15, multicast, 240/4, ::/96, NAT64, 6to4, fec0::/10, ff00::/8 (none routable from Workers). Because Think now imports from agents/webfetch, the agents peer floor rises >=0.25.0 → >=0.28.0, the first release with that entry point (same move as 6c8f85a for websearch).

Evidence

  • Before: two hand-maintained range lists that already disagreed (agents blocked .local and 6to4, Think rejected all-digit hosts).
    After: packages/think/src/tests/fetch-tools.test.ts → 51 passed with no test changes: every blocked-host case (localhost, 127.0.0.1, 10.x, 169.254.169.254, [::1], [::ffff:…], redirect to a private host) still blocks. typecheck → 132 projects.

Merge Danger

Door: two-way

Blast Radius: small

Peer-dep floor bump: users on agents 0.25–0.27 get a peer warning when they upgrade @cloudflare/think. fetch_url blocks a few more reserved ranges than before.

@changeset-bot

changeset-bot Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 31c7348

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@ben-reitz
ben-reitz added this pull request to stack #2523 October 8, 2026 10:12
@agent-think

agent-think Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

✅ agents import sizes: no significant changes (64eac888 → 31c7348c, workflow run)

@pkg-pr-new

pkg-pr-new Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

agents

npm i https://pkg.pr.new/agents@2521

@cloudflare/ai-chat

npm i https://pkg.pr.new/@cloudflare/ai-chat@2521

@cloudflare/codemode

npm i https://pkg.pr.new/@cloudflare/codemode@2521

hono-agents

npm i https://pkg.pr.new/hono-agents@2521

@cloudflare/shell

npm i https://pkg.pr.new/@cloudflare/shell@2521

@cloudflare/think

npm i https://pkg.pr.new/@cloudflare/think@2521

@cloudflare/voice

npm i https://pkg.pr.new/@cloudflare/voice@2521

@cloudflare/worker-bundler

npm i https://pkg.pr.new/@cloudflare/worker-bundler@2521

commit: 31c7348

@ben-reitz
ben-reitz removed this pull request from stack #2523 October 8, 2026 11:55
@ben-reitz
ben-reitz added this pull request to stack #2528 October 8, 2026 11:55
@ben-reitz ben-reitz changed the title feat(think): add opt-in webFetch tool option refactor(think): share the private-host policy with agents/webfetch Oct 8, 2026
@ben-reitz
ben-reitz marked this pull request as ready for review October 8, 2026 13:28
devin-ai-integration[bot]

This comment was marked as resolved.

fetch_url and its redirect check now use isPrivateOrLocalHost from agents/webfetch instead of a local isBlockedHost list, so the SDK has one SSRF table. Raises the agents peer floor to >=0.28.0, the first release with agents/webfetch.
@ben-reitz
ben-reitz merged commit bb6b27a into main Oct 8, 2026
9 of 14 checks passed
@ben-reitz
ben-reitz deleted the web-fetch/think branch October 8, 2026 14:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant