Skip to content

fix(web_handler): validate URLs and block private/loopback IPs to prevent SSRF - #6

Open
sifatyt20c-lang wants to merge 1 commit into
mindsdb:mainfrom
sifatyt20c-lang:patch-1
Open

sifatyt20c-lang wants to merge 1 commit into
mindsdb:mainfrom
sifatyt20c-lang:patch-1

Conversation

@sifatyt20c-lang

Copy link
Copy Markdown

Added a function to validate that URLs do not resolve to private or reserved IP addresses, preventing SSRF vulnerabilities.

Description

This PR fixes an unauthenticated Server-Side Request Forgery (SSRF) vulnerability in the Web Handler (web_handler.py). Previously, the crawler did not validate whether target URLs resolved to internal, loopback, or reserved IP ranges. I have added a _validate_no_private_ip helper function that resolves hostnames via socket.getaddrinfo and blocks any private, loopback, link-local, multicast, or reserved IP addresses unconditionally before crawling.

Fixes mindsdb/mindshub#12480

Type of change

  • 🐛 Bug fix (non-breaking change which fixes an issue)

Verification Process

To ensure the changes are working as expected:

  • Test Location: mindsdb/integrations/handlers/web_handler/web_handler.py
  • Verification Steps:
    1. Run a query targeting a loopback or private IP address, such as: SELECT * FROM web.crawler WHERE url = "http://127.0.0.1:8000" or SELECT * FROM web.crawler WHERE url = "http://localhost".
    2. Confirm that the query raises a ValueError blocking access to private/loopback IP ranges instead of making an outbound request.
    3. Run a query with a valid public URL (e.g., SELECT * FROM web.crawler WHERE url = "https://example.com") and verify it proceeds normally.

Additional Media:

  • I have attached a brief loom video or screenshots showcasing the new functionality or change.

Checklist:

  • My code follows the style guidelines(PEP 8) of MindsDB.
  • I have appropriately commented on my code, especially in complex areas.
  • Necessary documentation updates are either made or tracked in issues.
  • Relevant unit and integration tests are updated or added.

Added a function to validate that URLs do not resolve to private or reserved IP addresses, preventing SSRF vulnerabilities.
@github-actions

github-actions Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@sifatyt20c-lang

Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

github-actions Bot added a commit that referenced this pull request Nov 16, 2026
@sifatyt20c-lang

Copy link
Copy Markdown
Author

recheck

This branch has not been deployed

No deployments
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.

MindsDB: unauthenticated SSRF via the web crawler (default-open allowlist, no private-IP filter)

1 participant