# Rack::Attack

> Rack middleware for blocking & throttling abusive requests

Source: https://talira.ai/catalog/rack-attack-nd3d7d1b
Every listing: https://talira.ai/catalog.md

- Kind: Open source
- Types: Library
- Categories: [security / rate limiting](https://talira.ai/categories/security/rate-limiting), [languages / ruby / rails](https://talira.ai/categories/languages/ruby/rails), [languages / ruby](https://talira.ai/categories/languages/ruby)
- Licence: MIT[^2]
- Pricing: Free and open source[^2]
- Free tier: yes[^2]
- API: yes[^1]
- Backed by: [Rack](https://talira.ai/orgs/rack.md)
- Creator: Aaron Suggs (the gem's author), at Kickstarter

Rack::Attack is Rack middleware that protects Rails and other Rack apps from abusive clients by deciding, for each request, whether to allow, block or throttle it. You define safelists, blocklists, throttles and tracks in Ruby, matching an IP, a subnet or any property of the request (such as the email on a login form), plus Fail2Ban and Allow2Ban rules that ban an IP after repeated bad requests. Throttle and ban counters live in a cache store, `Rails.cache` by default, and the README recommends a separate [Redis](https://talira.ai/catalog/redis-v917j45s.md) or [Memcached](https://talira.ai/catalog/memcached-qjqvpryd.md) database that every process shares. It was introduced on Kickstarter's engineering blog and now lives in the Rack [GitHub](https://talira.ai/catalog/github-ppcgj756.md) organization; a Rails app uses it as soon as the gem is installed.

## Links

- GitHub: https://github.com/rack/rack-attack

## Problems it solves

- bots are hammering our login page trying thousands of passwords
- limit how many requests a single IP can make to my Rails API per minute
- throttle password reset attempts per email address, not just per IP
- a badly written scraper keeps taking our site down with too many requests
- block requests from a list of bad IP addresses and subnets in my Ruby web app
- automatically ban an IP for an hour after it probes for /wp-admin or /etc/passwd
- send a 429 with a Retry-After header when a client calls us too fast
- always let our office IPs and health checks through while rate limiting everyone else
- give API clients that send a key a higher request limit than anonymous traffic
- log and graph requests from a suspicious user agent without blocking them yet
- our in-app rate limit doesn't hold across several Puma workers and servers
- stop credential stuffing at the application level when we don't have a WAF in front
- clear rate limit state between tests so specs don't throttle each other

## Features

- safelists and blocklists by IP address, subnet or any request property
- throttles with a limit and period, fixed or computed per request
- Fail2Ban and Allow2Ban rules that ban an IP after repeated matches
- tracks that log matching requests without blocking them
- custom responses for blocked and throttled requests (403 and 429 by default)
- optional Retry-After header, and RateLimit headers through a custom responder
- ActiveSupport::Notifications events for logging and metrics
- any ActiveSupport cache store that implements increment and write
- enabled switch, reset! and clear_configuration for tests

## Limitations

- Doesn't share throttle counters between processes with an in-memory cache: throttles need an external store such as Redis or Memcached[^1]

## Capabilities

- Has an API: plan not known

## Trust

Overall: 0.58 out of 1.
Signals: maintenance 0.61, adoption 0.75, momentum 0.46, community 0.80, backing 0.50, extensibility 0.20.

- last commit 12 days ago
- 1 commits in the last 90 days
- latest release v6.8.0 13 months ago
- 5.8k GitHub stars
- 97 contributors
- backed by Rack
- created by Aaron Suggs (the gem's author), at Kickstarter

## Sources

[^1]: https://github.com/rack/rack-attack (checked 20 Nov 2026)
[^2]: https://github.com/rack/rack-attack/blob/main/LICENSE (checked 20 Nov 2026)
