Rack Attack
Rack Attack Security
This module includes comprehensive security configurations for Rack::Attack to protect your Decidim instance from various attacks and abuse.
Features
- Allow2Ban protection - Temporary bans after repeated violations
- Fail2ban protection against common attack patterns
- System access protection with IP safelisting
- Email-based protection for authentication endpoints (resistant to IP changes)
- Configurable rate limits and ban durations
Protected Endpoints
| Endpoint | Method | Max Attempts | Ban Duration | Description |
|---|---|---|---|---|
/api | POST | 300/min | - | API requests (throttled) |
/users | POST | 10/min | 10 min | User registration (Allow2Ban) |
/users/sign_in | POST | 30/min | 10 min | User login (Allow2Ban, email-based) |
/users/password | POST | 5/min | 10 min | Password reset (Allow2Ban, email-based) |
/comments | POST/PUT | 10/min | 10 min | Comment operations (Allow2Ban) |
/conversations | GET | 100/min | 10 min | Conversation viewing (Allow2Ban) |
/conversations | POST/PUT | 20/min | 10 min | Conversation operations (Allow2Ban) |
/system | All | IP safelist | - | System administration |
Security Features
Allow2Ban Protection
Most endpoints use Allow2Ban instead of simple throttling:
- Tracks violations: Counts failed attempts within a 1-minute window
- Temporary bans: Automatically bans the source (IP or email) for 10 minutes after hitting the limit
- Auto-recovery: Bans expire automatically, allowing legitimate users to retry
- Email-based protection: Authentication endpoints track by email address, making them resistant to IP changes
Fail2ban Protection
Automatically bans IPs for an hour that attempt to access forbidden paths or common attack vectors:
- WordPress-related paths (
/wp-admin,/wp-login, etc.) - System files (
.env,.git,.htaccess, etc.) - Common exploit attempts