Skip to content

security: fix SSRF in AutoGen Studio fetch_webpage tool#7706

Open
hoangperry wants to merge 1 commit into
microsoft:mainfrom
hoangperry:fix/ssrf-fetch-webpage
Open

security: fix SSRF in AutoGen Studio fetch_webpage tool#7706
hoangperry wants to merge 1 commit into
microsoft:mainfrom
hoangperry:fix/ssrf-fetch-webpage

Conversation

@hoangperry
Copy link
Copy Markdown

Summary

fetch_webpage() in autogenstudio/gallery/tools/fetch_webpage.py calls httpx.get(url) with no URL validation and follow_redirects=True (httpx default). When deployed as a server-side agent, this allows any agent user to cause the server to fetch internal network addresses.

Vulnerable code (before)

async with httpx.AsyncClient() as client:
    response = await client.get(url, headers=headers, timeout=10)

No IP range check. follow_redirects=True means an attacker-controlled server returning 302 to an internal address bypasses future URL-based filtering.

Fix

  • _validate_url(): resolves hostname to IP and blocks RFC 1918, loopback, and link-local (169.254.x.x) ranges before making any request.
  • Switch to follow_redirects=False and validate each redirect target before following.

Test plan

  • http://127.0.0.1/ → ValueError (loopback)
  • http://169.254.169.254/ → ValueError (cloud metadata)
  • http://10.0.0.1/ → ValueError (RFC 1918)
  • Redirect to private IP → ValueError (redirect guard)
  • Public URLs still work

fetch_webpage() called httpx.get(url) with follow_redirects=True and
no URL validation, allowing requests to private/internal network
addresses when the tool is used in a server-side agent deployment.

Changes:
- Add _validate_url() that resolves hostname to IP and blocks RFC 1918,
  loopback, and link-local ranges (including cloud metadata endpoints).
- Switch to follow_redirects=False and validate each redirect target
  before following, preventing redirect-chain bypass.
@hoangperry
Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

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.

1 participant