Skip to content

Commit c3fb1fe

Browse files
authored
fix: hardcoded default Django SECRET_KEY allows offline forgery of signing-based tokens and unauthenticated file access (#6802)
1 parent 458b6c1 commit c3fb1fe

1 file changed

Lines changed: 2 additions & 4 deletions

File tree

  • apps/maxkb/settings/base

apps/maxkb/settings/base/web.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from ...const import CONFIG, PROJECT_DIR
1111
import os
1212
from django.utils.translation import gettext_lazy as _
13+
from django.core.management.utils import get_random_secret_key
1314

1415
# Build paths inside the project like this: BASE_DIR / 'subdir'.
1516
BASE_DIR = Path(__file__).resolve().parent.parent.parent
@@ -18,10 +19,7 @@
1819
# See https://docs.djangoproject.com/en/4.2/howto/deployment/checklist/
1920

2021
# SECURITY WARNING: keep the secret key used in production secret!
21-
SECRET_KEY = CONFIG.get('SECRET_KEY')
22-
if not SECRET_KEY:
23-
raise RuntimeError(
24-
"MAXKB_SECRET_KEY not configured, please provide it in the environment variable or configuration")
22+
SECRET_KEY = CONFIG.get('SECRET_KEY') or get_random_secret_key()
2523
# SECURITY WARNING: don't run with debug turned on in production!
2624
DEBUG = CONFIG.get_debug()
2725

0 commit comments

Comments
 (0)