Security hardening: CSRF protection, input validation, secure file permissions
Security fixes based on adversarial audit:
1. CSRF Protection (CRITICAL)
- Added CSRF middleware with double-submit cookie pattern
- All POST forms now include hidden _csrf field
- Tokens validated on all state-changing requests
2. Private Key Permissions (HIGH)
- Private key now written with mode 0600 (owner read/write only)
- Prevents other system users from reading the key
3. Input Validation (MEDIUM)
- Added TID format validation for rkey parameters
- Prevents potential path traversal or injection via malformed IDs
4. Added validation library for future use
- TID validation
- HTTPS URL validation
- String sanitization helper
Co-authored-by: Shelley <shelley@exe.dev>