How to Hack a Django Website
summary
Four concrete exploits and fixes: a Sentry instance exposing pickle serializer plus signed cookies and the secret key lets an attacker craft a pickle RCE payload and run arbitrary Python on the server; a GitHub Unicode case collision lets password resets target the wrong email (patched in Django on 2020-12-18 / Django 3.1); admin use of mark_safe causes XSS (use format_html); embedding JSON in script tags needs json_script or CSP and serve a security.txt for vuln reports.
AI-written summary · about
chapters (26)
- 0:00Intro
- 0:16Four Stories
- 1:43Scan Facebook IP range
- 2:07Find Sentry
- 2:33Browse Sentry Wow, DEBUG=True
- 2:58Read Debugged Settings
- 4:04Replace contents of signed cookie
- 5:20PICKLE IS CODE
- 7:14Bounty
- 9:50GitHub 2019 Blog Post by John Gracey
- 11:26All Case Collisions with English: Lowercase Uppercase
- 12:41Step 3 - Reset Password
- 13:29Step 4 - Unleash Chaos
- 15:46How to Protect • Upgrade Django.
- 16:22YPlan Happened to me
- 17:0699 Step 2: Someone browses the admin
- 17:18mark_safe is not safe
- 18:30Use format_html
- 21:22Lotsa sites Recurring audit issue.
- 22:09View Forms "JSON"
- 22:36Step 3: Template Inlines JSON
- 23:06Cat Alert
- 24:35Use json_script
- 27:13Bonus Protection: security.txt
- 27:48security.txt view
- 28:08security.txt example
