Web Application and Django Security MOC

Django AppSec

Hub for concepts, labs, runbooks, and case studies on web application security, Django hardening, bot mitigation, and availability protection.

                        ┌────────────────────────────────────┐
                        │  Web Application & Django Sec MOC  │
                        └─────────────────┬──────────────────┘
                                          │
        ┌────────────────────────┬────────┴───────────────┬────────────────────────┐
        ▼                        ▼                        ▼                        ▼
┌──────────────┐       ┌────────────────┐       ┌────────────────┐       ┌────────────────┐
│ Public Form  │       │ Bot Mitigation │       │ Rate Limiting  │       │  Labs, Posts & │
│ Abuse Risks  │       │  & Honeypots   │       │ & Proxy IPs    │       │  Runbooks      │
└──────────────┘       └────────────────┘       └────────────────┘       └────────────────┘

Core concepts

Availability & public endpoint risks

Bot mitigation & abuse prevention

  • Form Honeypot Design and Silent Rejection: enticing field naming (website), autofill/accessibility isolation (autocomplete="off", tabindex="-1", aria-hidden="true"), and why silent 302 redirects prevent bot adaptation.
  • Per-IP Rate Limiting Behind a Reverse Proxy in Django: taking the client IP from a header the proxy sets (X-Real-IP) or the trusted proxy's X-Forwarded-For entry, never the forgeable first one, an atomic fixed-window counter with cache.add + cache.incr (429 Too Many Requests), and why rate limiting runs before honeypot checks.

Output encoding & XSS

Browser security model & tokens

Labs (02 - Sources/)

Runbooks (05 - SOPs & Manuals/)

Post-mortems & case studies (06 - Posts/)

Open questions

  • Should outbound email (send_mail()) be offloaded from the synchronous HTTP request cycle to a background task queue (e.g., Celery, Django Q, or Django 6 background tasks)? Gunicorn now runs --workers 3 --timeout 60 (see Container Entrypoint Hardening and Gunicorn Worker Configuration), which prevents a single slow SMTP response from freezing the site, but 3 concurrent slow SMTP calls can still saturate the worker pool.
  • Should rate-limit counters move to a shared cache such as Redis? Without a CACHES setting Django uses per-process LocMemCache, so each Gunicorn worker counts separately and every deploy resets the counters (see Per-IP Rate Limiting Behind a Reverse Proxy in Django).
  • Should edge rate limiting (Nginx limit_req_zone or Cloudflare WAF rules) be layered in front of Django's application-level cache counter?
  • Should Markdown-rendered user content allow <img> at all? Any https: image is a tracking pixel that reveals when staff open a message; dropping img or proxying images would close it.

References