Skip to content

fix: validate navigation URLs to prevent SSRF and local resource access#167

Open
xr843 wants to merge 1 commit intogarrytan:mainfrom
xr843:fix/ssrf-url-validation
Open

fix: validate navigation URLs to prevent SSRF and local resource access#167
xr843 wants to merge 1 commit intogarrytan:mainfrom
xr843:fix/ssrf-url-validation

Conversation

@xr843
Copy link
Contributor

@xr843 xr843 commented Mar 18, 2026

Summary

Closes #17.

  • Add URL validation before all page.goto() calls to prevent SSRF and local resource access
  • Only allow http: and https: schemes (blocks file:, data:, javascript:, etc.)
  • Block private/internal IPs: 127.0.0.0/8, 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16, 169.254.0.0/16 (cloud metadata), 0.0.0.0
  • Block localhost hostname
  • Provide BROWSE_ALLOW_PRIVATE=1 env var to bypass the private-IP check for local development

Changes

File Change
browse/src/url-validation.ts New: validateNavigationUrl() with scheme + private IP checks
browse/src/write-commands.ts Add validation before page.goto() in goto command
browse/src/browser-manager.ts Add validation before page.goto() in newTab() (covers newtab command)
browse/src/meta-commands.ts Add validation for both URLs in diff command

Test plan

  • All 173 tests in browse/test/commands.test.ts pass (with BROWSE_ALLOW_PRIVATE=1)
  • Pre-existing gstack-config failure confirmed on main (not related)
  • Verify file:///etc/passwd is blocked by goto
  • Verify http://169.254.169.254/ is blocked by goto
  • Verify BROWSE_ALLOW_PRIVATE=1 allows http://127.0.0.1

🤖 Generated with Claude Code

Block file:/data:/javascript: schemes and private/internal IPs
(127.0.0.0/8, 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16, 169.254.0.0/16)
in goto, newtab, newTab(), and diff commands. The BROWSE_ALLOW_PRIVATE=1
env var bypasses the private-IP check for local development.

Closes garrytan#17

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.

[Security] SSRF and local resource access via unrestricted URL handling

1 participant