Challenge - 5 Problems
Django Security Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate1:30remaining
Why is the SECRET_KEY important in Django?
What is the main purpose of the SECRET_KEY in a Django project?
Attempts:
2 left
💡 Hint
Think about what needs to be protected from being changed by attackers.
✗ Incorrect
The SECRET_KEY is used by Django to sign cookies, sessions, and tokens. This prevents attackers from modifying them without detection.
❓ component_behavior
intermediate1:30remaining
Effect of DEBUG=True on security
What happens if you leave
DEBUG = True in your Django settings on a public website?Attempts:
2 left
💡 Hint
Consider what information an attacker might see if debugging is on.
✗ Incorrect
When DEBUG = True, Django shows detailed error pages that can reveal secret keys, environment variables, and code paths. This is a security risk on public sites.
📝 Syntax
advanced2:00remaining
Correct way to set SECRET_KEY in settings.py
Which option correctly sets the SECRET_KEY in Django's settings.py using an environment variable with a fallback?
Attempts:
2 left
💡 Hint
Check the correct method to get environment variables with a default value in Python.
✗ Incorrect
os.getenv is the correct function to get an environment variable with a fallback default. os.environ['VAR'] raises an error if missing. os.get and ?? are invalid in Python.
🔧 Debug
advanced1:30remaining
Identify the error in this security setting
What error will this Django setting cause?
SECURE_SSL_REDIRECT = 'True'
Attempts:
2 left
💡 Hint
Check the data type expected for this setting.
✗ Incorrect
SECURE_SSL_REDIRECT expects a boolean True or False, not a string. Using a string can cause unexpected behavior or errors.
❓ state_output
expert2:00remaining
Result of missing SECRET_KEY in production
What happens when you run a Django project in production mode without setting a SECRET_KEY?
Attempts:
2 left
💡 Hint
Think about how critical SECRET_KEY is for Django's security.
✗ Incorrect
Django requires a SECRET_KEY to run. If missing, it raises an ImproperlyConfigured error to prevent insecure operation.