Skip to content

Conversation

laipz8200
Copy link
Member

@laipz8200 laipz8200 commented Aug 23, 2025

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

@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. 💪 enhancement New feature or request 📚 documentation Improvements or additions to documentation labels Aug 23, 2025
@laipz8200 laipz8200 marked this pull request as draft August 23, 2025 19:56
@laipz8200 laipz8200 requested a review from Yeuoly August 23, 2025 21:36
@laipz8200 laipz8200 marked this pull request as ready for review August 23, 2025 21:36
@DavideDelbianco
Copy link
Contributor

DavideDelbianco commented Aug 24, 2025

Will this new configuration block MCP server functionality where google.com is used to retrieve favicon?
Or Github to retrieve latest version / stars count / manual install of plugin from repositories ?

@laipz8200
Copy link
Member Author

@DavideDelbianco Our goal is to block all access to the internal network environment by default-without blocking access to internet resources. Before this PR is merged, we encourage you to try the new configuration and report any issues you encounter.

crazywoola
crazywoola previously approved these changes Aug 24, 2025
@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Aug 24, 2025
@laipz8200 laipz8200 force-pushed the chore/ssrf-config branch 2 times, most recently from e09adc6 to 3e77099 Compare August 25, 2025 15:45
@dosubot dosubot bot added size:XXL This PR changes 1000+ lines, ignoring generated files. and removed size:L This PR changes 100-499 lines, ignoring generated files. labels Sep 1, 2025
laipz8200 and others added 10 commits September 1, 2025 13:45
- Block all private/internal networks by default to prevent SSRF attacks
- Restrict allowed ports to only HTTP (80) and HTTPS (443)
- Remove default domain allowlists (e.g., marketplace.dify.ai)
- Implement deny-all-by-default policy with explicit whitelisting
- Add example configuration files for common customization scenarios
- Provide comprehensive documentation for security configuration

Fixes #24392
- Block all private/internal networks by default to prevent SSRF attacks
- Restrict ports to only HTTP (80) and HTTPS (443)
- Deny all requests by default unless explicitly whitelisted
- Add customization support via conf.d directory for local overrides
- Provide example configurations for common use cases
- Add CI/testing setup script to ensure tests pass with strict config
- Update docker-compose files to support custom config mounting
- Add comprehensive documentation with security warnings
- Add marketplace.dify.ai to default allowed domains in squid.conf
- Remove separate marketplace configuration example as it's no longer needed
- Update documentation to reflect marketplace is allowed by default
- Rename example configs to maintain sequential numbering (10, 20, 30)
- Update README to reflect new file numbering
- Keep testing config as 00 since it's a special case
- Move docker/ssrf_proxy/conf.d/ ignore rule to root .gitignore
- Remove redundant docker/ssrf_proxy/.gitignore file
- Keep all gitignore rules in a single location for better maintainability
crazywoola
crazywoola previously approved these changes Sep 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📚 documentation Improvements or additions to documentation 💪 enhancement New feature or request lgtm This PR has been approved by a maintainer size:XXL This PR changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Strengthen SSRF proxy default configuration to prevent security vulnerabilities
4 participants