SafeURL-Python hostname blocklist FQDN bypass

Severity: info · Published 2023-06-29

SafeURL-Python is a library designed to prevent Server-Side Request Forgery (SSRF) attacks by blocking requests to internal and private IP addresses. The library's hostname blocklist can be bypassed by adding a trailing dot to convert a hostname into a Fully Qualified Domain Name (FQDN), allowing attackers to circumvent custom hostname restrictions set by developers.

Technologies: safeurl-python (PyPI). Vendors: PyPI.

Quick answers

Is This vulnerability exploited in the wild?
No. Junglewise Threat Intelligence has no report of This vulnerability being exploited in the wild.
How severe is This vulnerability?
Informational severity, published 29 June 2023.
Which products and versions are affected?
safeurl-python (PyPI) ECOSYSTEM:introduced=0,fixed=1.3.
Is there a fix for This vulnerability?
Yes. safeurl-python (PyPI): upgrade to 1.3 or later. Junglewise finds every place you run it, drafts the upgrade and applies it once you approve.
How is This vulnerability attacked?
It is attacked over the network, in a software library.
Am I affected?
Check whether you run safeurl-python (PyPI) at an affected version. Junglewise does that check for you around the clock: connect your code, cloud and domains, and it matches new vulnerabilities like this one against what you actually run and tells you when one reaches you.

How to fix

  • safeurl-python (PyPI): upgrade to 1.3 or later
    pip install "safeurl-python>=1.3"

Technical details

The vulnerability is a hostname matching bypass in SafeURL-Python's blocklist validation logic. When a hostname is blacklisted, an attacker can bypass the check by appending a trailing dot (e.g., "example.com" becomes "example.com."), which converts the hostname to FQDN format that the regex or string comparison fails to match. The vulnerability requires the application to have explicitly configured custom hostname blocklists; the library's built-in protections against internal/private IP addresses are not affected. This enables SSRF attacks against specifically-blocked internal services. The vulnerability was patched in version 1.3 via pull request #6.

Affected products

  • IncludeSecurity SafeURL-Python <1.3

Timeline

  • 2023-06-29: disclosed
  • 2023-06-23: patched: Fix merged in pull request #6

References

This page as Markdown. Free to reuse under CC BY 4.0 with a link back.