---
title: "WEB-PY-003 Django Uses the Generated Development Secret Key"
canonical: https://openvapt.com/checks/WEB-PY-003.html
html: https://openvapt.com/checks/WEB-PY-003.html
site: OpenVAPT, https://openvapt.com/
license: OpenVAPT Source-Available Licence 1.3, https://openvapt.com/legal/licence-text.html
modified: 2026-10-14
version: 0.1.0-alpha.6
---

# WEB-PY-003 Django Uses the Generated Development Secret Key

Checks Django settings for a SECRET_KEY that starts with django-insecure-, the marker of the key generated by startproject.

- Domain: Web Apps
- Severity: High
- Control category: Cryptography and TLS
- Fix effort: low
- CVSS v3.1 vector: `CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:N`
- CIS Controls v8: 3.10
- NIST CSF 2.0: PR.DS-02
- CWE: CWE-798, CWE-321
- OWASP Top 10 2021: A02:2021, A05:2021
- OWASP ASVS 4.0.3: 2.10.4
- NIST SP 800-53 Rev. 5: IA-5, SC-12

## Why It Matters

SECRET_KEY signs sessions, password-reset tokens and other data. The generated key sits in source files that are usually copied into repositories and backups; anyone who has it can forge signed data and, with some session backends, take over accounts.

## How It Detects

Reads the same Django settings files as WEB-PY-001 and flags SECRET_KEY = 'django-insecure-...'. The key itself is never copied into the report.

## How to Fix

Generate a new key (python -c 'from django.core.management.utils import get_random_secret_key; print(get_random_secret_key())'), load it from the environment or a root-readable file (SECRET_KEY = os.environ['DJANGO_SECRET_KEY']), and restart. Changing the key logs all users out.

## How to Verify

```
python manage.py check --deploy  reports no SECRET_KEY warning.
```

## Learn the Theory

- [P13 Application Servers: Tomcat, Node.js and Python](https://openvapt.com/academy/p13.md)

## References

- [Django documentation, Deployment checklist](https://docs.djangoproject.com/en/6.1/howto/deployment/checklist/)
- [Django settings reference, SECRET_KEY](https://docs.djangoproject.com/en/6.1/ref/settings/#secret-key)

## Source Code

https://github.com/OpenVAPT/openvapt/blob/574f7f3333c44b75a3c649e2d93a76d507f75adf/internal/checks/web/runtimes.go

Run it: `openvapt scan --only WEB-PY-003`. Read it offline: `openvapt explain WEB-PY-003`.

---

OpenVAPT is academic, non-commercial, source-available and built by AI Cybersecurity Engineers (AI systems, not people). Free for your own use on machines you own or control, 100% at your own risk; not for sale and not for providing services. This page in HTML: https://openvapt.com/checks/WEB-PY-003.html. Part of OpenVAPT Check Catalogue. How to cite: https://openvapt.com/cite.html. Site summary for models: https://openvapt.com/llms.txt.
