{"id":"CVE-2023-47115","aliases":["CVE-2023-47115","GHSA-q68h-xwq5-mm7x","PYSEC-2024-126"],"related":[],"kind":"vulnerability","state":"published","title":"Label Studio XSS Vulnerability on Avatar Upload","summary":"Label Studio is an a popular open source data labeling tool. Versions prior to 1.9.2 have a cross-site scripting (XSS) vulnerability that could be exploited when an authenticated user uploads a crafted image file for their avatar that gets rendered as a HTML file on the website. Executing arbitrary JavaScript could result in an attacker performing malicious actions on Label Studio users if they visit the crafted avatar image. For an example, an attacker can craft a JavaScript payload that adds a new Django Super Administrator user if a Django administrator visits the image.\n\nThe file `users/functions.py` lines 18-49 show that the only verification check is that the file is an image by extracting the dimensions from the file. Label Studio serves avatar images using Django's built-in `serve` view, which is not secure for production use according to Django's documentation. The issue with the Django `serve` view is that it determines the `Content-Type` of the response by the file extension in the URL path. Therefore, an attacker can upload an image that contains malicious HTML code and name the file with a `.html` extension to be rendered as a HTML page. The only file extension validation is performed on the client-side, which can be easily bypassed.\n\nVersion 1.9.2 fixes this issue. Other remediation strategies include validating the file extension on the server side, not in client-side code; removing the use of Django's `serve` view and implement a secure controller for viewing uploaded avatar images; saving file content in the database rather than on the filesystem to mitigate against other file related vulnerabilities; and avoiding trusting user controlled inputs.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"Label Studio is an a popular open source data labeling tool. Versions prior to 1.9.2 have a cross-site scripting (XSS) vulnerability that could be exploited when an authenticated user uploads a crafted image file for their avatar that gets rendered as a HTML file on the website. Executing arbitrary JavaScript could result in an attacker performing malicious actions on Label Studio users if they visit the crafted avatar image. For an example, an attacker can craft a JavaScript payload that adds a new Django Super Administrator user if a Django administrator visits the image.\n\nThe file `users/functions.py` lines 18-49 show that the only verification check is that the file is an image by extracting the dimensions from the file. Label Studio serves avatar images using Django's built-in `serve` view, which is not secure for production use according to Django's documentation. The issue with the Django `serve` view is that it determines the `Content-Type` of the response by the file extension in the URL path. Therefore, an attacker can upload an image that contains malicious HTML code and name the file with a `.html` extension to be rendered as a HTML page. The only file extension validation is performed on the client-side, which can be easily bypassed.\n\nVersion 1.9.2 fixes this issue. Other remediation strategies include validating the file extension on the server side, not in client-side code; removing the use of Django's `serve` view and implement a secure controller for viewing uploaded avatar images; saving file content in the database rather than on the filesystem to mitigate against other file related vulnerabilities; and avoiding trusting user controlled inputs.","source":"cvelist"},{"lang":"en","text":"# Introduction\n\nThis 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.9.2` and was tested on version `1.8.2`.\n\n# Overview\n\n[Label Studio](https://github.com/HumanSignal/label-studio) has a cross-site scripting (XSS) vulnerability that could be exploited when an authenticated user uploads a crafted image file for their avatar that gets rendered as a HTML file on the website.\n\n# Description\n\nThe following [code snippet in Label Studio](https://github.com/HumanSignal/label-studio/blob/1.8.2/label_studio/users/functions.py#L18-L49) shows that the only verification check is that the file is an image by extracting the dimensions from the file.\n\n```python\n\ndef hash_upload(instance, filename):\n    filename = str(uuid.uuid4())[0:8] + '-' + filename\n    return settings.AVATAR_PATH + '/' + filename <3>\n\n\ndef check_avatar(files):\n    images = list(files.items())\n    if not images:\n        return None\n\n    filename, avatar = list(files.items())[0]  # get first file\n    w, h = get_image_dimensions(avatar) <1>\n    if not w or not h:\n        raise forms.ValidationError(\"Can't read image, try another one\")\n\n    # validate dimensions\n    max_width = max_height = 1200\n    if w > max_width or h > max_height:\n        raise forms.ValidationError('Please use an image that is %s x %s pixels or smaller.'\n                                    % (max_width, max_height))\n\n    # validate content type\n    main, sub = avatar.content_type.split('/') <2>\n    if not (main == 'image' and sub.lower() in ['jpeg', 'jpg', 'gif', 'png']):\n        raise forms.ValidationError(u'Please use a JPEG, GIF or PNG image.')\n\n    # validate file size\n    max_size = 1024 * 1024\n    if len(avatar) > max_size:\n        raise forms.ValidationError('Avatar file size may not exceed ' + str(max_size/1024) + ' kb')\n\n    return avatar\n```\n1. Attempts to get image dimensions to validate the uploaded avatar file is an image.\n2. Extracts the `Content-Type` from the upload `POST` request. A user can easily bypass this verification by changing the mimetype of the uploaded file to an allowed type (eg. `image/jpeg`).\n3. The file extension of the uploaded file is never validated and is saved to the filesystem.\n\n[Label Studio serves avatar images using Django's built-in `serve` view](https://github.com/HumanSignal/label-studio/blob/1.8.2/label_studio/users/urls.py#L25-L26), which is [not secure for production use according to Django's documentation](https://docs.djangoproject.com/en/4.2/ref/views/#serving-files-in-development).\n\n```python\n    re_path(r'^data/' + settings.AVATAR_PATH + '/(?P<path>.*)$', serve,\n            kwargs={'document_root': join(settings.MEDIA_ROOT, settings.AVATAR_PATH)}),\n```\n\nThe issue with the Django `serve` view is that it determines the `Content-Type` of the response by the file extension in the URL path. Therefore, an attacker can upload an image that contains malicious HTML code and name the file with a `.html` extension to be rendered as a HTML page. The only file extension validation is performed on the client-side, which can be easily bypassed.\n\n# Proof of Concept\n\nBelow are the steps to reproduce this issue and execute JavaScript code in the context of the Label Studio website.\n\n1. Using any JPEG or PNG image, add in the comment field in the metadata the HTML code `<script>alert(document.domain)</script>`. This can be done using the `exiftool` command as shown below that was used to create the following image.\n\n```bash\nexiftool -Comment='<script>alert(document.domain)</script>' penguin.jpg\n```\n\n![xss-penguin](https://user-images.githubusercontent.com/139727151/266989884-c2cd9b4f-f374-416e-a468-acf41f52e088.jpg)\n\n2. On Label Studio, navigate to account & settings page and intercept the upload request of the avatar image using a tool such as Burp Suite. Modify the filename in the request to have a `.html` extension.\n\n3. Right click the image on the avatar profile and copy the URL. Send this to a victim and it will display an alert box with the host name of the Label Studio instance as shown below.\n\n![xss-alert](https://user-images.githubusercontent.com/139727151/266989952-6fb74c6e-9961-447c-a602-5a6f36627ae6.png)\n\n# Impact\n\nExecuting arbitrary JavaScript could result in an attacker performing malicious actions on Label Studio users if they visit the crafted avatar image. For an example, an attacker can craft a JavaScript payload that adds a new Django Super Administrator user if a Django administrator visits the image.\n\n# Remediation Advice\n\n* Validate the file extension on the server side, not in client-side code.\n* Remove the use of Django's `serve` view and implement a secure controller for viewing uploaded avatar images.\n* Consider saving file content in the database rather than on the filesystem to mitigate against other file related vulnerabilities.\n* Avoid trusting user controlled inputs.\n\n# Discovered\n- August 2023, Alex Brown, elttam","format":"markdown","source":"ghsa"},{"lang":"es","text":"Label Studio es una popular herramienta de etiquetado de datos de código abierto. Las versiones anteriores a la 1.9.2 tienen una vulnerabilidad de cross-site scripting (XSS) que podría explotarse cuando un usuario autenticado carga un archivo de imagen manipulado para su avatar que se representa como un archivo HTML en el sitio web. La ejecución de JavaScript arbitrario podría provocar que un atacante realice acciones maliciosas en los usuarios de Label Studio si visitan la imagen de avatar creada. Por ejemplo, un atacante puede crear un payload de JavaScript que agregue un nuevo usuario de Superadministrador de Django si un administrador de Django visita la imagen. Las líneas 18-49 del archivo `users/functions.py` muestran que la única verificación de verificación es que el archivo es una imagen extrayendo las dimensiones del archivo. Label Studio sirve imágenes de avatar utilizando la vista \"servir\" incorporada de Django, que no es segura para uso en producción según la documentación de Django. El problema con la vista `serve` de Django es que determina el `Tipo de contenido` de la respuesta por la extensión del archivo en la ruta URL. Por lo tanto, un atacante puede cargar una imagen que contenga código HTML malicioso y nombrar el archivo con una extensión \".html\" para que se represente como una página HTML. La única validación de la extensión de archivo se realiza en el lado del cliente, lo que se puede omitir fácilmente. La versión 1.9.2 soluciona este problema. Otras estrategias de corrección incluyen validar la extensión del archivo en el lado del servidor, no en el código del lado del cliente; eliminar el uso de la vista `serve` de Django e implementar un controlador seguro para ver las imágenes de avatar cargadas; guardar el contenido del archivo en la base de datos en lugar de en el sistema de archivos para mitigar otras vulnerabilidades relacionadas con los archivos; y evitar confiar en las entradas controladas por el usuario.","source":"nvd"}],"published":"2024-01-23T22:49:03.958Z","modified":"2026-09-10T03:50:05.049Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:L","score":7.1,"rating":"HIGH"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:L","score":7.1,"rating":"HIGH"},{"scorer":"GitHub","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:L","score":7.1,"rating":"HIGH"},{"scorer":"NVD","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:C/C:L/I:L/A:N","score":5.4,"rating":"MEDIUM"},{"scorer":"PyPA Advisory Database","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:C/C:L/I:L/A:N","score":5.4,"rating":"MEDIUM"}],"cwes":["CWE-79"],"affected":[{"ranges":[{"version":"< 1.9.2","status":"affected"}],"vendor":"HumanSignal","product":"label-studio","source":"cvelist"},{"ranges":[{"type":"ecosystem","introduced":"0","status":"affected","fixed":"1.9.2"}],"ecosystem":"PyPI","package":"label-studio","purl":"pkg:pypi/label-studio","source":"ghsa"},{"ranges":[{"status":"affected","fixed":"1.9.2"}],"vendor":"humansignal","product":"label_studio","cpe":"cpe:2.3:a:humansignal:label_studio:*:*:*:*:*:*:*:*","source":"nvd"},{"ranges":[{"type":"git","introduced":"0","status":"affected","fixed":"a7a71e594f32ec4af8f3f800d5ccb8662e275da3"},{"type":"ecosystem","introduced":"0","status":"affected","fixed":"1.9.2"}],"ecosystem":"PyPI","package":"label-studio","purl":"pkg:pypi/label-studio","repo":"https://github.com/HumanSignal/label-studio","source":"pysec"}],"references":[{"url":"https://github.com/HumanSignal/label-studio/security/advisories/GHSA-q68h-xwq5-mm7x","tags":["advisory","exploit","third-party-advisory","web","x-refsource-confirm","x-transferred"],"sources":["cvelist","ghsa","nvd","pysec"]},{"url":"https://github.com/HumanSignal/label-studio/commit/a7a71e594f32ec4af8f3f800d5ccb8662e275da3","tags":["fix","patch","web","x-refsource-misc","x-transferred"],"sources":["cvelist","ghsa","nvd","pysec"]},{"url":"https://docs.djangoproject.com/en/4.2/ref/views/#serving-files-in-development","tags":["not-applicable","web","x-refsource-misc","x-transferred"],"sources":["cvelist","ghsa","nvd","pysec"]},{"url":"https://github.com/HumanSignal/label-studio/blob/1.8.2/label_studio/users/functions.py#L18-L49","tags":["product","web","x-refsource-misc","x-transferred"],"sources":["cvelist","ghsa","nvd","pysec"]},{"url":"https://github.com/HumanSignal/label-studio/blob/1.8.2/label_studio/users/urls.py#L25-L26","tags":["product","web","x-refsource-misc","x-transferred"],"sources":["cvelist","ghsa","nvd","pysec"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2023-47115","tags":["advisory"],"sources":["ghsa"]},{"url":"https://github.com/HumanSignal/label-studio","tags":["package"],"sources":["ghsa"]},{"url":"https://github.com/pypa/advisory-database/tree/main/vulns/label-studio/PYSEC-2024-126.yaml","tags":["web"],"sources":["ghsa"]}],"credits":[],"assigner":"GitHub_M","ssvc":{"scorer":"CISA-ADP","exploitation":"poc","automatable":"no","technicalImpact":"partial","date":"2025-05-08T20:11:25.718Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2023-47115","url":"https://www.cve.org/CVERecord?id=CVE-2023-47115","licence":"CVE Terms of Use","modified":"2025-05-30T14:18:15.145Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-q68h-xwq5-mm7x","url":"https://github.com/advisories/GHSA-q68h-xwq5-mm7x","licence":"CC-BY-4.0","modified":"2026-09-10T03:50:05.049Z"},{"source":"nvd","name":"NVD","id":"CVE-2023-47115","url":"https://nvd.nist.gov/vuln/detail/CVE-2023-47115","licence":"Public domain","modified":"2026-06-17T06:32:10.937Z"},{"source":"pysec","name":"PyPA Advisory Database","id":"PYSEC-2024-126","url":"https://osv.dev/vulnerability/PYSEC-2024-126","licence":"CC-BY-4.0","modified":"2024-11-21T14:57:12.872Z"}],"updatedAt":"2026-11-25T22:58:32.243Z","epss":{"score":0.01448,"percentile":0.74099,"date":"2026-12-01T12:00:22.000Z"}}