Commit 7b9701c
committed
Harden web app security
- Random secret key (env var or generated per-process, not hardcoded)
- CSRF token on all POST forms with constant-time comparison
- Security headers: CSP, X-Frame-Options DENY, X-Content-Type-Options,
Referrer-Policy, Permissions-Policy
- All form inputs validated against whitelists, no raw user strings
reach enum lookups or int() calls
- Text inputs truncated to 500 chars
- Numeric inputs bounded (days 3-6, minutes 30-120, sets 0-50)
- Per-session program storage replaces shared global mutable state
- In-memory rate limiter (20 req/min per IP)
- Debug mode off by default (env var opt-in)
- Secure session cookies (HttpOnly, SameSite=Lax, optional Secure)
- Error templates for 400/403/429/500
https://claude.ai/code/session_01Lo7Z7GoRzG6hZkKwrxnXVk1 parent 2bc64f6 commit 7b9701c
3 files changed
Lines changed: 278 additions & 61 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
208 | 208 | | |
209 | 209 | | |
210 | 210 | | |
| 211 | + | |
211 | 212 | | |
212 | 213 | | |
213 | 214 | | |
| |||
0 commit comments