dify - ✅(Solved) Fix [Proposal] Harden Docker Compose SSRF proxy defaults [1 pull requests, 1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
langgenius/dify#36400Fetched 2026-05-20 04:00:12
View on GitHub
Comments
0
Participants
1
Timeline
3
Reactions
1
Author
Participants
Assignees
Timeline (top)
assigned ×1cross-referenced ×1labeled ×1

Root Cause

The hardening in #36332 intentionally blocks private-network targets. That can regress local Docker deployments when a Dify-signed /files/... URL is passed back into Dify as a remote URL, because FILES_URL or INTERNAL_FILES_URL may resolve to localhost, a Docker-internal hostname, or another private address.

Fix Action

Fixed

PR fix notes

PR #36332: fix(docker): harden default SSRF proxy egress

Description (problem / solution / changelog)

Summary

Closes #36400.

  • Harden the Docker Compose SSRF proxy defaults by denying loopback, private, CGN, link-local, ULA, multicast, reserved, and cloud metadata target networks before general egress is allowed.
  • Stop relying on the Ubuntu Squid image's packaged conf.d access rules so allow localnet cannot bypass Dify's policy.
  • Preserve the sandbox reverse proxy path and add explicit SSRF_PROXY_ALLOW_PRIVATE_IPS / SSRF_PROXY_ALLOW_PRIVATE_DOMAINS escape hatches for trusted private-network deployments.

Note: this PR should remain draft until #36397 is resolved, so Dify-owned signed file URLs can be handled through internal file retrieval instead of the SSRF proxy.

Screenshots

N/A

Checklist

  • This change requires a documentation update, included: Dify Document
  • I understand that this PR may be closed in case there was no previous discussion or issues. (This doesn't apply to typos!)
  • I've updated the documentation accordingly.

Changed files

  • docker/.env.example (modified, +1/-0)
  • docker/docker-compose-template.yaml (modified, +2/-0)
  • docker/docker-compose.middleware.yaml (modified, +2/-0)
  • docker/docker-compose.yaml (modified, +2/-0)
  • docker/envs/infrastructure/ssrf-proxy.env.example (modified, +2/-0)
  • docker/envs/middleware.env.example (modified, +3/-1)
  • docker/ssrf_proxy/docker-entrypoint.sh (modified, +28/-0)
  • docker/ssrf_proxy/squid.conf.template (modified, +31/-16)
  • docker/ssrf_proxy/test_ssrf_proxy_config.sh (added, +143/-0)
RAW_BUFFERClick to expand / collapse

Self Checks

  • I have read the Contributing Guide and Language Policy.
  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit this report, otherwise it will be closed.
  • Please do not modify this template :) and fill in all the required fields.

1. Is this request related to a challenge you're experiencing? Tell me about your story.

Dify's Docker Compose deployment currently routes API, worker, sandbox, and related network features through the bundled Squid-based ssrf_proxy. The intended goal is to make network features work out of the box while reducing SSRF risk.

However, the current Squid configuration includes the Ubuntu Squid image's default /etc/squid/conf.d/*.conf. That packaged configuration allows localnet clients. In Docker Compose, Dify services connect from Docker private-network source addresses, so this effectively allows the proxy clients to reach arbitrary destinations, including loopback, RFC1918 private networks, link-local addresses, and cloud metadata endpoints.

This creates recurring SSRF concerns for community self-hosted deployments. At the same time, switching to a strict domain allowlist would break the expected out-of-the-box behavior for HTTP nodes, remote file ingestion, crawlers, tools, and other user-configured public network calls.

The proposed behavior is:

  • Keep public outbound access working by default.
  • Block loopback, private, CGN, link-local, ULA, multicast/reserved, and cloud metadata target networks by default.
  • Preserve the existing sandbox reverse proxy path.
  • Provide explicit opt-in allowlists for trusted private-network deployments that intentionally need private egress.

A draft implementation is available in #36332.

2. Additional context or comments

This proposal should be coordinated with #36397 before #36332 is moved forward.

The hardening in #36332 intentionally blocks private-network targets. That can regress local Docker deployments when a Dify-signed /files/... URL is passed back into Dify as a remote URL, because FILES_URL or INTERNAL_FILES_URL may resolve to localhost, a Docker-internal hostname, or another private address.

#36397 should centralize handling for Dify-owned signed file URLs so they are verified and resolved through an internal file/storage path instead of being treated as arbitrary external remote URLs through the SSRF proxy. After that path is in place, the SSRF proxy hardening can proceed without breaking local signed-file flows.

Related PR: #36332 Blocked by: #36397

3. Can you help us with this feature?

  • I am interested in contributing to this feature.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING