Label Studio SSRF on Import Bypassing `SSRF_PROTECTION_ENABLED` Protections
Medium5.3CVE-2023-47116 · Published Jan 31, 2024 · updated Sep 10, 2026
# Introduction This write-up describes a vulnerability found in [Label Studio](https://github.com/HumanSignal/label-studio), a popular open source data labeling tool. The vulnerability affects all versions of Label Studio prior to [`1.11.0`](https://github.com/HumanSignal/label-studio/releases/tag/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](https://en.wikipedia.org/wiki/DNS_rebinding). # Description The following `tasks_from_url` method in [`label_studio/data_import/uploader.py`](https://github.com/HumanSignal/label-studio/blob/1.8.2/label_studio/data_import/uploader.py#L127-L155) performs the SSRF validation (`validate_upload_url`) before sending the request. ```python def tasks_from_url(file_upload_ids, project, user, url, could_be_tasks_list): """Dow...
Affected versions
| Package | Affected | Fixed in |
|---|---|---|
| label-studio PyPI | < 1.11.0 | 1.11.0 |
Details and references
# Introduction This write-up describes a vulnerability found in [Label Studio](https://github.com/HumanSignal/label-studio), a popular open source data labeling tool. The vulnerability affects all versions of Label Studio prior to [`1.11.0`](https://github.com/HumanSignal/label-studio/releases/tag/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](https://en.wikipedia.org/wiki/DNS_rebinding). # Description The following `tasks_from_url` method in [`label_studio/data_import/uploader.py`](https://github.com/HumanSignal/label-studio/blob/1.8.2/label_studio/data_import/uploader.py#L127-L155) performs the SSRF validation (`validate_upload_url`) before sending the request. ```python def tasks_from_url(file_upload_ids, project, user, url, could_be_tasks_list): """Download file using URL and read tasks from it""" # process URL with tasks try: filename = url.rsplit('/', 1)[-1] validate_upload_url(url, block_local_urls=settings.SSRF_PROTECTION_ENABLED) # Reason for #nosec: url has been validated as SSRF safe by the # validation check above. response = requests.get( url, verify=False, headers={'Accept-Encoding': None} ) # nosec file_content = response.content check_tasks_max_file_size(int(response.headers['content-length'])) file_upload = create_file_upload( user, project, SimpleUploadedFile(filename, file_content) ) if file_upload.format_could_be_tasks_list: could_be_tasks_list = True file_upload_ids.append(file_upload.id) tasks, found_formats, data_keys = FileUpload.load_tasks_from_uploaded_files( project, file_upload_ids ) except ValidationError as e: raise e except Exception as e: raise ValidationError(str(e)) return data_keys, found_formats, tasks, file_upload_ids, could_be_tasks_list ``` The `validate_upload_url` code in [`label_studio/core/utils/io.py`](https://github.com/HumanSignal/label-studio/blob/1.8.2/label_studio/core/utils/io.py#L174-L209) is shown below. ```python def validate_upload_url(url, block_local_urls=True): """Utility function for defending against SSRF attacks. Raises - InvalidUploadUrlError if the url is not HTTP[S], or if block_local_urls is enabled and the URL resolves to a local address. - LabelStudioApiException if the hostname cannot be resolved :param url: Url to be checked for validity/safety, :param block_local_urls: Whether urls that resolve to local/private networks should be allowed. """ parsed_url = parse_url(url) if parsed_url.scheme not in ('http', 'https'): raise InvalidUploadUrlError domain = parsed_url.host try: ip = socket.gethostbyname(domain) except socket.error: from core.utils.exceptions import LabelStudioAPIException raise LabelStudioAPIException(f"Can't resolve hostname {domain}") if not block_local_urls: return if ip == '0.0.0.0': # nosec raise InvalidUploadUrlError local_subnets = [ '127.0.0.0/8', '10.0.0.0/8', '172.16.0.0/12', '192.168.0.0/16', ] for subnet in local_subnets: if ipaddress.ip_address(ip) in ipaddress.ip_network(subnet): raise InvalidUploadUrlError ``` 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 a
- CVSS 3.1
- CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:N/A:N
- Severity from
- GitHub (reviewed advisory)
- Weakness
- CWE-918
- Also known as
- CVE-2023-47116, PYSEC-2024-127
- github.com/HumanSignal/label-studio/security/advisories/GHSA-p59w-9gqw-wj8r
- nvd.nist.gov/vuln/detail/CVE-2023-47116
- github.com/HumanSignal/label-studio/commit/55dd6af4716b92f2bb213fe461d1ffbc380c6a64
- en.wikipedia.org/wiki/DNS_rebinding
- github.com/HumanSignal/label-studio
- github.com/HumanSignal/label-studio/blob/1.8.2/label_studio/core/utils/io.py#L174-L209
- github.com/HumanSignal/label-studio/blob/1.8.2/label_studio/data_import/uploader.py#L127-L155
- github.com/HumanSignal/label-studio/releases/tag/1.11.0
- github.com/pypa/advisory-database/tree/main/vulns/label-studio/PYSEC-2024-127.yaml
More Label Studio advisories
All Label Studio| Date | Advisory | Severity | Fixed in |
|---|---|---|---|
| Feb 222024 | Label Studio vulnerable to Cross-site Scripting if `<Choices>` or `<Labels>` are used in labeling config | Medium4.7 | 1.11.0 |
| Jan 242024 | Cross-site Scripting Vulnerability on Data Import | Medium4.7 | 1.10.1 |
| Jan 242024 | Cross-site Scripting Vulnerability on Avatar Upload | High7.1 | 1.9.2 |
| Nov 142023 | Label Studio Object Relational Mapper Leak Vulnerability in Filtering Task | High7.5 | 1.9.2.post0 |
| Nov 92023 | Label Studio has Hardcoded Django `SECRET_KEY` that can be Abused to Forge Session Tokens | Critical9.8 | 1.8.2 |
| Mar 242023 | Nginx alias path traversal allows unauthenticated attackers to read all files on /label_studio/core/ | High7.5 | 1.7.2 |