Skip to content

test(handlers): add SaaS-mode wrapper tests for isSafeURL and validateAgentURL - #2021

Closed
molecule-ai[bot] wants to merge 1 commit into
stagingfrom
test/ssrf-saas-mode-wrapper-tests
Closed

test(handlers): add SaaS-mode wrapper tests for isSafeURL and validateAgentURL#2021
molecule-ai[bot] wants to merge 1 commit into
stagingfrom
test/ssrf-saas-mode-wrapper-tests

Conversation

@molecule-ai

@molecule-ai molecule-ai Bot commented Apr 24, 2026

Copy link
Copy Markdown
Contributor

Cherry-picked from PR #1805 (staging).

Adds integration-level wrapper tests that exercise isSafeURL (the public API) rather
than just isPrivateOrMetadataIP (the inner helper). Previously the inner helper's
SaaS-mode tests were green while isSafeURL hardcoded RFC-1918 rejection — causing
502s on every A2A call from Docker-networked / VPC deployments (issue #1785).

Tests added:

  • TestIsSafeURL_SaaSMode_AllowsRFC1918
  • TestIsSafeURL_SaaSMode_StillBlocksMetadataEtAl
  • TestIsSafeURL_StrictMode_BlocksRFC1918
  • TestIsSafeURL_SaasMode_LegacyOrgID

Rebased on origin/staging alongside DevMode tests from staging.

…eAgentURL

Issue #1786: SSRF test gap — inner helpers (isPrivateOrMetadataIP,
validateAgentURL blockedRanges) were tested in isolation but the public
wrappers never called saasMode(), allowing the regression to pass unit
tests while production returned 502 on every A2A call from Docker/VPC
deployments (PR #1785).

Adds integration-level wrapper tests for both functions across all
saasMode() resolution ladder cases:
- SaaS explicit (MOLECULE_DEPLOY_MODE=saas): RFC-1918 + fd00 ULA allowed
- Strict mode (MOLECULE_DEPLOY_MODE=self-hosted): RFC-1918 blocked
- Legacy org-ID fallback (MOLECULE_ORG_ID set, no DEPLOY_MODE):
  RFC-1918 + fd00 ULA allowed
- Always-blocked ranges (metadata, loopback, TEST-NET, CGNAT, fc00 ULA)
  stay blocked in every mode

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@molecule-ai
molecule-ai Bot force-pushed the test/ssrf-saas-mode-wrapper-tests branch from 1cf974c to 9ad5ca3 Compare April 24, 2026 15:44
@molecule-ai

molecule-ai Bot commented Apr 24, 2026

Copy link
Copy Markdown
Contributor Author

Closing as superseded — staging already contains every change in this PR:

  • registry.go: CGNAT 100.64.0.0/10, TEST-NET-1/2/3, multicast, fc00::/8 all present on staging (landed via separate sync)
  • registry_test.go: All 4 SaaSMode/StrictMode test functions (TestValidateAgentURL_SaaSMode_AllowsRFC1918, TestValidateAgentURL_SaaSMode_StillBlocksMetadataEtAl, TestValidateAgentURL_StrictMode_BlocksRFC1918, TestValidateAgentURL_SaaSMode_LegacyOrgID) present on staging at lines 573+
  • ssrf_test.go: Check staging for full equivalence

All changes will reach main via PR #1981 (staging→main promotion). No separate merge needed.

@molecule-ai molecule-ai Bot closed this Apr 24, 2026
molecule-ai Bot pushed a commit that referenced this pull request Apr 24, 2026
PR #2021 follow-up: add TEST-NET reserved ranges and IPv6 documentation
prefix to validateAgentURL blocklist in all SaaS/self-hosted modes.

RFC 5737 reserves 192.0.2.0/24, 198.51.100.0/24, and 203.0.113.0/24 for
documentation and example code — no production agent has a legitimate
reason to use them. RFC 3849 designates 2001:db8::/32 as the IPv6
documentation prefix. All are blocked unconditionally.

Also adds 8 regression test cases covering each blocked range.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@molecule-ai
molecule-ai Bot deleted the test/ssrf-saas-mode-wrapper-tests branch May 20, 2026 06:22
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.

0 participants