CVE-2023-47116: Label Studio SSRF on Import Bypassing `SSRF_PROTECTION_ENABLED` Protections

Published Jan 31, 2024
·
Updated

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 SSRFPROTECTIONENABLED 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 tasksfromurl method in labelstudio/dataimport/uploader.py performs the SSRF validation (validateuploadurl) before sending the request.

python def tasksfromurl(fileuploadids, project, user, url, couldbetaskslist): """Download file using URL and read tasks from it""" # process URL with tasks try: filename = url.rsplit('/', 1)[-1]

validateuploadurl(url, blocklocalurls=settings.SSRFPROTECTIONENABLED) # 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 filecontent = response.content checktasksmaxfilesize(int(response.headers['content-length'])) fileupload = createfileupload( user, project, SimpleUploadedFile(filename, filecontent) ) if fileupload.formatcouldbetaskslist: couldbetaskslist = True fileuploadids.append(fileupload.id) tasks, foundformats, datakeys = FileUpload.loadtasksfromuploadedfiles( project, fileuploadids )

except ValidationError as e: raise e except Exception as e: raise ValidationError(str(e)) return datakeys, foundformats, tasks, fileuploadids, couldbetaskslist

The validateuploadurl code in labelstudio/core/utils/io.py is shown below.

python def validateuploadurl(url, blocklocalurls=True): """Utility function for defending against SSRF attacks. Raises - InvalidUploadUrlError if the url is not HTTP[S], or if blocklocalurls 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 blocklocalurls: Whether urls that resolve to local/private networks should be allowed. """

parsedurl = parseurl(url)

if parsedurl.scheme not in ('http', 'https'): raise InvalidUploadUrlError

domain = parsedurl.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 blocklocalurls: return

if ip == '0.0.0.0': # nosec raise InvalidUploadUrlError localsubnets = [ '127.0.0.0/8', '10.0.0.0/8', '172.16.0.0/12', '192.168.0.0/16', ] for subnet in localsubnets: if ipaddress.ipaddress(ip) in ipaddress.ipnetwork(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 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.

python from http.server import BaseHTTPRequestHandler, HTTPServer

class RedirectHandler(BaseHTTPRequestHandler):

def doGET(self): self.sendresponse(301) # skip first slash self.sendheader('Location', self.path[1:]) self.endheaders()

HTTPServer(("", 8080), RedirectHandler).serveforever()

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

Other sources

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 SSRFPROTECTIONENABLED 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.

MITRE

Affected Software

2 affected componentsFixes available
pip/label-studio<1.11.0
1.11.0
HumanSignal Label Studio<1.11.0

Event History

Jan 31, 2024
CVE Published
via MITRE·04:21 PM
Data Sourced
via MITRE·04:21 PM
DescriptionSeverityWeakness
Data Sourced
via NVD·05:15 PM
DescriptionSeverityWeakness
Advisory Published
via GitHub·06:04 PM
Data Sourced
via GitHub·06:04 PM
DescriptionSeverityWeaknessAffected Software

Frequently Asked Questions

1

What is the severity of CVE-2023-47116?

CVE-2023-47116 has been assigned a high severity level due to its potential impact on the confidentiality and integrity of data.

2

How do I fix CVE-2023-47116?

To fix CVE-2023-47116, upgrade Label Studio to version 1.11.0 or later.

3

Which versions of Label Studio are affected by CVE-2023-47116?

All versions of Label Studio prior to version 1.11.0 are affected by CVE-2023-47116.

4

What type of vulnerability is CVE-2023-47116?

CVE-2023-47116 is a security vulnerability that can lead to unauthorized access and manipulation of data.

5

Is there a workaround for CVE-2023-47116?

There is no official workaround for CVE-2023-47116; upgrading to the latest version is the recommended solution.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203