Описание
Label Studio SSRF on Import Bypassing SSRF_PROTECTION_ENABLED Protections
Introduction
This write-up describes a vulnerability found in Label Studio, a popular open source data labeling tool. The vulnerability affects all versions of Label Studio prior to 1.11.0 and was tested on version 1.8.2.
Overview
Label Studio's SSRF protections that can be enabled by setting the SSRF_PROTECTION_ENABLED environment variable can be bypassed to access internal web servers. This is because the current SSRF validation is done by executing a single DNS lookup to verify that the IP address is not in an excluded subnet range. This protection can be bypassed by either using HTTP redirection or performing a DNS rebinding attack.
Description
The following tasks_from_url method in label_studio/data_import/uploader.py performs the SSRF validation (validate_upload_url) before sending the request.
The validate_upload_url code in label_studio/core/utils/io.py is shown below.
The issue here is the SSRF validation is only performed before the request is sent, and does not validate the destination IP address. Therefore, an attacker can either redirect the request or perform a DNS rebinding attack to bypass this protection.
Proof of Concept
Both the HTTP redirection and DNS rebinding methods for bypassing Label Studio's SSRF protections are explained below.
HTTP Redirection
The python requests module automatically follows HTTP redirects (eg. response code 301 and 302). Therefore, an attacker could use a URL shortener (eg. https://www.shorturl.at/) or host the following Python code on an external server to redirect request from a Label Studio server to an internal web server.
DNS Rebinding Attack
DNS rebinding can bypass SSRF protections by resolving to an external IP address for the first resolution, but when the request is sent resolves to an internal IP address that is blocked. For an example, the domain 7f000001.030d1fd6.rbndr.us will randomly switch between the IP address 3.13.31.214 that is not blocked to 127.0.0.1 which is not allowed.
Impact
SSRF vulnerabilities pose a significant risk on cloud environments, since instance credentials are managed by internal web APIs. An attacker can bypass Label Studio's SSRF protections to access internal web servers and partially compromise the confidentiality of those internal servers.
Remediation Advice
- Before saving any responses, validate the destination IP address is not in the deny list.
- Consider blocking internal cloud API IP ranges to mitigate the risk of compromising cloud credentials.
Discovered
- August 2023, Alex Brown, elttam
Ссылки
- https://github.com/HumanSignal/label-studio/security/advisories/GHSA-p59w-9gqw-wj8r
- https://nvd.nist.gov/vuln/detail/CVE-2023-47116
- https://github.com/HumanSignal/label-studio/commit/55dd6af4716b92f2bb213fe461d1ffbc380c6a64
- https://en.wikipedia.org/wiki/DNS_rebinding
- https://github.com/HumanSignal/label-studio/blob/1.8.2/label_studio/core/utils/io.py#L174-L209
- https://github.com/HumanSignal/label-studio/blob/1.8.2/label_studio/data_import/uploader.py#L127-L155
- https://github.com/HumanSignal/label-studio/releases/tag/1.11.0
- https://github.com/pypa/advisory-database/tree/main/vulns/label-studio/PYSEC-2024-127.yaml
Пакеты
label-studio
< 1.11.0
1.11.0
Связанные уязвимости
Label Studio is a popular open source data labeling tool. The vulnerability affects all versions of Label Studio prior to 1.11.0 and was tested on version 1.8.2. Label Studio's SSRF protections that can be enabled by setting the `SSRF_PROTECTION_ENABLED` environment variable can be bypassed to access internal web servers. This is because the current SSRF validation is done by executing a single DNS lookup to verify that the IP address is not in an excluded subnet range. This protection can be bypassed by either using HTTP redirection or performing a DNS rebinding attack.
Label Studio is a popular open source data labeling tool. The vulnerab ...