You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(security): prevent SSRF in read_file URL fetching
The readFileFromUrl() helper passed user-supplied URLs directly to
fetch() without any validation, enabling Server-Side Request Forgery:
an AI agent could be prompted to call read_file with an internal URL
(e.g. http://169.254.169.254/latest/meta-data/) to exfiltrate cloud
metadata, reach internal APIs, or probe the private network.
Fixes:
1. Add validateFetchUrl() — called before every fetch — that rejects:
- Non-HTTP(S) schemes (file://, ftp://, data://, etc.)
- Loopback addresses (127.x.x.x, ::1)
- Private IPv4 ranges (10.x, 172.16-31.x, 192.168.x)
- Link-local / cloud metadata range (169.254.x.x)
- Known internal hostnames (localhost, host.docker.internal,
metadata.google.internal, *.local mDNS names)
2. Set redirect: 'error' on the fetch call to prevent open-redirect
chains that could route to internal resources after an initial
public URL is validated.
3. Improve error message when a redirect is blocked.
Closes: wonderwhy-er#410
0 commit comments