Skip to content

fix(security): respect global ssrf_protection_enabled flag in gateway test endpoint#5023

Open
bogdanmariusc10 wants to merge 1 commit into
mainfrom
5022-bug-gateway-test-endpoint-bypasses-global-ssrf-protection-flag
Open

fix(security): respect global ssrf_protection_enabled flag in gateway test endpoint#5023
bogdanmariusc10 wants to merge 1 commit into
mainfrom
5022-bug-gateway-test-endpoint-bypasses-global-ssrf-protection-flag

Conversation

@bogdanmariusc10
Copy link
Copy Markdown
Collaborator

🔗 Related Issue

Closes #5022


📝 Summary

Fixed an inconsistency where the /admin/gateways/test endpoint was unconditionally blocking private IPs regardless of the global ssrf_protection_enabled configuration flag. This prevented testing internal services even when SSRF protection was intentionally disabled for development/testing purposes.

The Problem:

  • The gateway test endpoint applied its own SSRF checks that ignored the global ssrf_protection_enabled flag
  • Other endpoints (gateway creation, tool registration) respected this flag, creating inconsistent behavior
  • Operators couldn't test internal services even with SSRF protection explicitly disabled

The Solution:

  • Modified validate_gateway_test_url() to check settings.ssrf_protection_enabled before applying private IP blocking
  • Applied the check to both direct IP validation and DNS-resolved IP validation
  • Maintained allowlist enforcement regardless of SSRF flag for defense in depth
  • Added comprehensive test suite with 18 tests covering all scenarios

Security Impact:

  • When ssrf_protection_enabled=true (default): Behavior unchanged - private IPs are blocked
  • When ssrf_protection_enabled=false: Private IPs are allowed (consistent with other endpoints)
  • Allowlist enforcement remains active in both cases (layered security)

🏷️ Type of Change

  • Bug fix
  • Feature / Enhancement
  • Documentation
  • Refactor
  • Chore (deps, CI, tooling)
  • Other (describe below)

🧪 Verification

Check Command Status
Lint suite make lint ✅ Pass
Unit tests make test ✅ Pass
Coverage ≥ 80% make coverage ✅ Pass

Tests Cover:

  • Private IP blocking when SSRF enabled/disabled
  • Loopback, link-local, and carrier-grade NAT handling
  • Public IP allowance with allowlist
  • Hostname resolution to private IPs
  • Allowlist enforcement (independent of SSRF flag)
  • IPv6 address handling
  • DNS rebinding protection
  • FQDN normalization
  • Wildcard subdomain matching

✅ Checklist

  • Code formatted (make black isort pre-commit)
  • Tests added/updated for changes (18 new tests)
  • Documentation updated (bug report created)
  • No secrets or credentials committed

📓 Notes

Files Changed:

Design Decision:
Implemented Option 1 from the bug analysis: Respect the global SSRF flag for consistency. This was chosen over creating a separate gateway-test-specific flag because:

  1. Maintains consistency with other endpoints
  2. Simpler configuration (one flag to rule them all)
  3. Allowlist enforcement provides adequate protection when SSRF is disabled

Integration Tests:
Three tests are marked as @pytest.mark.integration because they perform real DNS resolution (mocking async executor DNS calls is complex). These tests validate wildcard matching, DNS rebinding protection, and FQDN normalization with actual network calls.

Security Considerations:

  • Default behavior unchanged (ssrf_protection_enabled=true by default)
  • Allowlist enforcement cannot be disabled (defense in depth)
  • Private IPs still blocked by default
  • Only affects behavior when SSRF protection is explicitly disabled

…oint

The /admin/gateways/test endpoint was unconditionally blocking private IPs
regardless of the global ssrf_protection_enabled configuration flag. This
created inconsistency with other endpoints and prevented testing internal
services even when SSRF protection was intentionally disabled.

Changes:
- Modified validate_gateway_test_url() to check ssrf_protection_enabled
  before applying private IP blocking (both direct and DNS-resolved IPs)
- Allowlist enforcement remains active regardless of SSRF flag (defense in depth)
- Added comprehensive test suite with 18 tests covering all scenarios
- Created bug report documenting the issue and fix

This ensures consistent behavior across all endpoints while maintaining
security through layered protections (SSRF + allowlist enforcement).

Fixes: Gateway test endpoint SSRF flag bypass
Signed-off-by: Bogdan-Marius-Catanus <bogdan-marius.catanus@ibm.com>
@bogdanmariusc10 bogdanmariusc10 added bug Something isn't working security Improves security labels Jun 3, 2026
@bogdanmariusc10 bogdanmariusc10 linked an issue Jun 3, 2026 that may be closed by this pull request
7 tasks
@bogdanmariusc10 bogdanmariusc10 added ica ICA related issues MUST P1: Non-negotiable, critical requirements without which the product is non-functional or unsafe api REST API Related item labels Jun 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api REST API Related item bug Something isn't working ica ICA related issues MUST P1: Non-negotiable, critical requirements without which the product is non-functional or unsafe security Improves security

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG]: Gateway test endpoint bypasses global SSRF protection flag

1 participant