[PR #24393] chore: strengthen SSRF proxy default configuration #30609

Open
opened 2026-02-21 20:47:52 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/langgenius/dify/pull/24393

State: open
Merged: No


Summary

This PR implements a "secure by default" configuration for the SSRF proxy to address security vulnerability reports. The current configuration is too permissive, allowing access to internal networks and high port ranges that can be exploited for SSRF attacks.

Changes Made:

  • Block all private/internal networks (RFC 1918, loopback, link-local, multicast, etc.)
  • Restrict to HTTP/HTTPS only - removed FTP, Gopher, and high port ranges (1025-65535)
  • Deny-all-by-default policy - requires explicit whitelisting via config files
  • Added customization support - users can override via /etc/squid/conf.d/ configs
  • Comprehensive documentation - README and example configurations provided

Security Improvements:

Before After
Allows ports 1025-65535 Only ports 80 and 443
Allows access to localhost Blocks all private networks
Default allows marketplace.dify.ai No default allowlists
Permissive by default Deny-all by default
ssrf_test ssrf_result

User Impact:

  • Production: More secure by default, prevents SSRF attacks
  • Development: Can easily customize via config overrides
  • Migration: Existing deployments may need to add custom configs for specific domains

Fixes #24392

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 added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.
  • I've updated the documentation accordingly.
  • I ran dev/reformat(backend) and cd web && npx lint-staged(frontend) to appease the lint gods
**Original Pull Request:** https://github.com/langgenius/dify/pull/24393 **State:** open **Merged:** No --- ## Summary This PR implements a "secure by default" configuration for the SSRF proxy to address security vulnerability reports. The current configuration is too permissive, allowing access to internal networks and high port ranges that can be exploited for SSRF attacks. ### Changes Made: - **Block all private/internal networks** (RFC 1918, loopback, link-local, multicast, etc.) - **Restrict to HTTP/HTTPS only** - removed FTP, Gopher, and high port ranges (1025-65535) - **Deny-all-by-default policy** - requires explicit whitelisting via config files - **Added customization support** - users can override via `/etc/squid/conf.d/` configs - **Comprehensive documentation** - README and example configurations provided ### Security Improvements: | Before | After | |--------|-------| | Allows ports 1025-65535 | Only ports 80 and 443 | | Allows access to localhost | Blocks all private networks | | Default allows marketplace.dify.ai | No default allowlists | | Permissive by default | Deny-all by default | <img width="396" height="223" alt="ssrf_test" src="https://github.com/user-attachments/assets/3457d3c1-8d6a-4e60-a67d-7a1cbcdac024" /> <img width="396" height="245" alt="ssrf_result" src="https://github.com/user-attachments/assets/f923317d-dfcc-4760-a828-8946e834d73d" /> ### User Impact: - **Production**: More secure by default, prevents SSRF attacks - **Development**: Can easily customize via config overrides - **Migration**: Existing deployments may need to add custom configs for specific domains Fixes #24392 ## Checklist - [ ] This change requires a documentation update, included: [Dify Document](https://github.com/langgenius/dify-docs) - [x] I understand that this PR may be closed in case there was no previous discussion or issues. (This doesn't apply to typos!) - [x] I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change. - [x] I've updated the documentation accordingly. - [x] I ran `dev/reformat`(backend) and `cd web && npx lint-staged`(frontend) to appease the lint gods
yindo added the pull-request label 2026-02-21 20:47:52 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#30609