Skip to content

fix(api): reject private IP literals before proxy dispatch - #4273

Open
ibondarenko1 wants to merge 3 commits into
firecrawl:mainfrom
ibondarenko1:fix/proxy-private-ip-literals
Open

fix(api): reject private IP literals before proxy dispatch#4273
ibondarenko1 wants to merge 3 commits into
firecrawl:mainfrom
ibondarenko1:fix/proxy-private-ip-literals

Conversation

@ibondarenko1

@ibondarenko1 ibondarenko1 commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

Problem

When PROXY_SERVER is configured, the safeFetch connection check sees the
proxy socket's remoteAddress, not the requested destination. A private IP
literal is blocked without a proxy but can reach the dispatcher when the proxy
itself has a public address.

The controlled API reproduction used the same
http://127.0.0.1:9911/secret target in both cases. The direct request was
blocked and did not reach the target. Through a restricted researcher-owned
proxy, the request reached the target and returned its marker.

Change

Add a destination interceptor before ProxyAgent dispatch. It rejects private
IPv4 and IPv6 literals on the initial request and redirects, using the existing
InsecureConnectionError. ALLOW_LOCAL_WEBHOOKS=true remains the explicit
opt-in for local destinations.

The interceptor does not resolve hostnames locally. A proxy can use a different
DNS view, so proxy-side DNS and rebinding protection are still required.

Validation

  • git diff --check
  • Prettier on the changed source and test
  • Vitest: 5/5 passing
    • IPv4 loopback rejected
    • bracketed IPv6 loopback rejected
    • public IP literal allowed
    • ALLOW_LOCAL_WEBHOOKS=true allowed
    • composed 302 redirect to a private IP literal rejected with zero target hits

This is a defense-in-depth change and does not replace the documented
requirement for a proxy that blocks private and link-local destinations.


Summary by cubic

Block private IP literal targets in safeFetch before ProxyAgent dispatch to close a proxy bypass gap, including during redirects. ALLOW_LOCAL_WEBHOOKS=true still allows local targets.

  • Bug Fixes
    • Added rejectPrivateIPLiteralTargets undici interceptor to reject private IPv4/IPv6 literals with InsecureConnectionError.
    • Composed before the redirect interceptor so checks re-run on each redirect; does not resolve hostnames locally (proxy must still filter hostnames).
    • Added tests for IPv4/IPv6 loopback rejection, public IP acceptance, ALLOW_LOCAL_WEBHOOKS opt-in, and blocking redirects to private targets without reaching them.

Written for commit c38f8ab. Summary will update on new commits.

Review in cubic

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

All reported issues were addressed across 2 files

Reply with feedback, questions, or to request a fix.

Fix all with cubic | Re-trigger cubic

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

0 issues found across 2 files (changes from recent commits).

Re-trigger cubic

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