Label Studio has Hardcoded Django `SECRET_KEY` that can be Abused to Forge Session Tokens
Description
Label Studio is a multi-type data labeling and annotation tool with standardized output format. There is a vulnerability that can be chained within the ORM Leak vulnerability to impersonate any account on Label Studio. An attacker could exploit these vulnerabilities to escalate their privileges from a low privilege user to a Django Super Administrator user. The vulnerability was found to affect versions before 1.8.2, where a patch was introduced.
Affected packages
Versions sourced from the GitHub Security Advisory.
| Package | Affected versions | Patched versions |
|---|---|---|
label-studioPyPI | < 1.8.2 | 1.8.2 |
Affected products
1- Range: <= 1.8.1
Patches
13d06c5131c15fix: LSDV-5071: Ensure secret key is securely set persisting a new one if required (#4690)
4 files changed · +29 −2
deploy/requirements.txt+1 −0 modified@@ -25,6 +25,7 @@ Django==3.2.20 django-storages==1.12.3 django_annoying==0.10.6 django_debug_toolbar==3.2.1 +django-environ==0.10.0 django_filter==2.4.0 django_model_utils==4.1.1 django_rq==2.5.1
label_studio/core/settings/base.py+2 −2 modified@@ -74,7 +74,7 @@ if not logging.getLogger().hasHandlers(): logging.basicConfig(level=logging.DEBUG, format='%(message)s') -from label_studio.core.utils.io import get_data_dir +from label_studio.core.utils.io import get_data_dir, generate_key_if_missing from label_studio.core.utils.params import get_bool_env, get_env, get_env_list_int logger = logging.getLogger(__name__) @@ -105,7 +105,7 @@ INTERNAL_PORT = '8080' # SECURITY WARNING: keep the secret key used in production secret! -SECRET_KEY = '$(fefwefwef13;LFK{P!)@#*!)kdsjfWF2l+i5e3t(8a1n' +SECRET_KEY = generate_key_if_missing('SECRET_KEY') # SECURITY WARNING: don't run with debug turned on in production! DEBUG = get_bool_env('DEBUG', True)
label_studio/core/utils/io.py+19 −0 modified@@ -1,4 +1,5 @@ """This file and its contents are licensed under the Apache License 2.0. Please see the included NOTICE for copyright information and LICENSE for a copy of the license. + """ import os import socket @@ -16,6 +17,8 @@ from tempfile import mkstemp, mkdtemp from django.conf import settings +from django.core.management.utils import get_random_secret_key +from label_studio.core.utils.params import env, env_file from appdirs import user_config_dir, user_data_dir, user_cache_dir # full path import results in unit test failures @@ -208,3 +211,19 @@ def validate_upload_url(url, block_local_urls=True): if ipaddress.ip_address(ip) in ipaddress.ip_network(subnet): raise InvalidUploadUrlError +def generate_key_if_missing(key): + value = env.str(key, "") + + if value == "": + print(f'Warning: {key} not found in environment variables will generate a random key.') + value = get_random_secret_key() + try: + with open(env_file, 'a') as f: + f.write(f'\n{key}={value}\n') + except Exception as e: + print(f'Warning: failed to write {key} to .env file: {e}, new key will be regenerated on every server restart. If this key is used for signing, it will invalidate all existing sessions or tokens. Please set {key} in your environment variables to avoid this warning.') + + os.environ[key] = value + + return value +
label_studio/core/utils/params.py+7 −0 modified@@ -1,7 +1,14 @@ import os +import environ + from rest_framework.exceptions import ValidationError +env = environ.Env() +data_dir = os.environ.get('LABEL_STUDIO_DATA_DIR', os.path.join(os.path.dirname(__file__), '..', '..', '..', 'data')) +env_file = os.path.join(data_dir, '.env') +environ.Env.read_env(env_file) + def cast_bool_from_str(value): if isinstance(value, str): if value.lower() in ['true', 'yes', 'on', '1']:
Vulnerability mechanics
Generated by null/stub on May 9, 2026. Inputs: CWE entries + fix-commit diffs from this CVE's patches. Citations validated against bundle.
References
7- github.com/advisories/GHSA-f475-x83m-rx5mghsaADVISORY
- nvd.nist.gov/vuln/detail/CVE-2023-43791ghsaADVISORY
- github.com/HumanSignal/label-studio/commit/3d06c5131c15600621e08b06f07d976887cde81bghsax_refsource_MISCWEB
- github.com/HumanSignal/label-studio/pull/4690ghsax_refsource_MISCWEB
- github.com/HumanSignal/label-studio/releases/tag/1.8.2ghsax_refsource_MISCWEB
- github.com/HumanSignal/label-studio/security/advisories/GHSA-f475-x83m-rx5mghsax_refsource_CONFIRMWEB
- github.com/pypa/advisory-database/tree/main/vulns/label-studio/PYSEC-2023-274.yamlghsaWEB
News mentions
0No linked articles in our index yet.