Commit graph

725 commits

Author SHA1 Message Date
Eliot Sykes
1cd4a1cd79
Mitigate login throttle bypasses in docs
This commit mitigates rate limit bypasses in the configuration
docs by normalizing the email throttle key. (The normalization process
used is the same as used by the Clearance gem.)

---

Often an authentication process normalizes email addresses and usernames
before look up, say by downcasing and removing any whitespace.

Throttles that do not perform the same normalization are vulnerable
to rate limit bypasses.

For example, an attacker can bypass a vulnerable throttle by using
unlimited case and whitespace variants for the same email address:

- Variant 1: `victim@example.org`
- Variant 2: `victim@example. org` (one whitespace)
- Variant 3: `victim@example.  org` (two whitespaces)
- Variant 4: `ViCtIm@eXaMpLe.org`
- etc, etc.

All of these variants resolve to the same email address, but allow
an attacker to bypass a vulnerable throttle. To mitigate, the email
throttle key should be normalized using the same logic the
authentication process uses for normalizing emails.

(cherry picked from commit 03926e0b75)
2021-01-23 13:55:47 -03:00
Tristan Toye
48531f546c
Clarify Calling HTTP_APIKey header in example (#488)
* Clarify Calling HTTP_ header in example

In trying to track down a bug here turns out I was trying to reference the wrong header shown in the readme.

Printing our `request.env` it becomes clear this is just the full request object:

```
{"rack.version"=>[1, 3],
 "rack.errors"=>#<IO:<STDERR>>,
 "rack.multithread"=>true,
 "rack.multiprocess"=>false,
 "rack.run_once"=>false,
 "SCRIPT_NAME"=>"",
 "QUERY_STRING"=>"",
 "SERVER_PROTOCOL"=>"HTTP/1.1",
 "SERVER_SOFTWARE"=>"puma 4.3.5 Mysterious Traveller",
 "GATEWAY_INTERFACE"=>"CGI/1.2",
 "REQUEST_METHOD"=>"POST",
 "REQUEST_PATH"=>"/api/v1/....",
 "REQUEST_URI"=>"/api/v1/...",
 "HTTP_VERSION"=>"HTTP/1.1",
 "HTTP_HOST"=>"example.com",
 "HTTP_APIKEY"=>"secret_key",
 "CONTENT_TYPE"=>"application/json",
 "HTTP_USER_AGENT"=>"PostmanRuntime/7.25.0",
 "HTTP_ACCEPT"=>"*/*",
 "HTTP_CACHE_CONTROL"=>"no-cache",
...
```

* Update README.md

(cherry picked from commit f92889b360)
2021-01-23 13:55:47 -03:00
Olle Jonsson
44b6a7353a
Use RuboCop 0.84.0
- this enables each of the new Cops and marks each with the version
they appeared in

(cherry picked from commit c07fcdde43)
2021-01-23 13:55:46 -03:00
Ryan Laughlin
9da0bb7712
Consolidate #testing section of README
(cherry picked from commit 029b5481fe)
2021-01-23 13:55:46 -03:00
Lukas Spieß
614e10aa9c
Use gender-neutral pronoun in Readme
(cherry picked from commit 58b4042e35)
2021-01-23 13:55:45 -03:00
fatkodima
1d2c646ae1
Remove support for ruby 2.3
(cherry picked from commit 56361ab56b)
2021-01-23 13:55:21 -03:00
Gonzalo Rodriguez
3a5d10c8b3
Bump gem version to v6.3.1 2020-05-20 23:19:26 -03:00
Gonzalo Rodriguez
02f56979f1
Merge pull request #482 from splitwise/rofreg/avoid-rails-5.2.4.3-deprecation-warning
Fix deprecation warning in Rails 5.2.4.3
2020-05-20 23:03:29 -03:00
Gonzalo Rodriguez
35e4983400
doc: add Testing section to the README 2020-04-26 13:09:13 -03:00
Gonzalo Rodriguez
aa071aa5df
Bump gem version to v6.3.0 2020-04-26 11:57:31 -03:00
Gonzalo Rodriguez
76bbada48f
ci: update rubies 2020-04-25 16:30:34 -03:00
Gonzalo Rodriguez
4c33737ed3
build: update rubocop to v0.78 2020-04-25 16:29:17 -03:00
Gonzalo
8787f7db5a
ci: test against latest rack minor versions 2020-04-25 16:28:48 -03:00
Gonzalo
aeac2d4887
ci: update to final ruby 2.7 2020-04-25 16:28:34 -03:00
Gonzalo Rodriguez
fadb98f25c
ci: update Travis dist to bionic 2020-04-25 16:28:27 -03:00
Gonzalo
8bbd0ab702
ci: test against ruby 2.7.0
- don't test ruby 2.7.0 with incompatible rails versions
2020-04-25 16:28:17 -03:00
fatkodima
9923012fe8
Allow to reset state between tests 2020-04-25 16:22:55 -03:00
Gonzalo Rodriguez
64f879395d
Merge commit '8fcd6c855915c802adeeb1784c503fc74115f5a3' into 6-stable 2020-04-25 16:17:37 -03:00
Gonzalo Rodriguez
da41880663 Bump gem version to v6.2.2 2019-12-18 11:44:15 -03:00
Gonzalo Rodriguez
d7b67011b7 ci: fix rubygems install step 2019-12-18 11:43:42 -03:00
fatkodima
6cca2467d2
Fix rescuing errors in RedisProxy#increment 2019-12-17 17:54:18 -03:00
Gonzalo Rodriguez
3654293085
Bump gem version to v6.2.1 2019-10-30 15:26:58 -03:00
Gonzalo Rodriguez
e3056e737f
fix: avoid unintended effects on load_config_initializers and other gems load order
Because of the sort algorithm rails uses to satisfy `after` and `before`
constraints, gems can have unintended effects on others. See
0a120a818d

Prefer making rack-attack middleware idempotent instead of relying on
the load order and the contents of the middleware stack too much.

closes #452
closes #456
2019-10-29 15:45:26 -03:00
Gonzalo Rodriguez
8fcd6c8559
Merge pull request #450 from fatkodima/better-failsafe
Do not rescue all errors for redis backed stores
2019-10-18 17:44:23 -03:00
Gonzalo Rodriguez
1f216e12e7
refactor: move require statement to correct file 2019-10-18 17:29:58 -03:00
fatkodima
20ec4d31db Do not rescue all errors for redis backed stores 2019-10-18 02:31:05 +03:00
Gonzalo Rodriguez
0188a90ab2
refactor: DRY setting config defaults 2019-10-17 14:27:32 -03:00
Gonzalo Rodriguez
55cb6def03
feat: clear custom response when clearing configuration 2019-10-17 14:26:22 -03:00
Gonzalo Rodriguez
6731e231cd
Merge pull request #440 from fatkodima/retry-after-header
Allow to configure Retry-After header for default throttled_response handler
2019-10-16 19:41:44 -03:00
fatkodima
a34c187dda Allow to configure Retry-After header for default throttled_response handler 2019-10-17 00:26:13 +03:00
Gonzalo Rodriguez
0112405fb4
refactor: prefer require over autoload for const referenced in the same file 2019-10-16 17:43:16 -03:00
Gonzalo Rodriguez
20fdab0c50
style: fix indentation 2019-10-16 16:27:30 -03:00
Gonzalo Rodriguez
a67a7bfdeb
Merge pull request #446 from fatkodima/extract-config
Extract Configuration class
2019-10-16 16:23:21 -03:00
fatkodima
7118b7a243 Extract Configuration class 2019-10-16 17:34:46 +03:00
Gonzalo Rodriguez
9cf227a32e
Merge pull request #445 from fatkodima/redis-proxy-increment
Fix rescuing errors in RedisProxy#increment
2019-10-15 18:13:52 -03:00
fatkodima
2fac6418f8 Fix rescuing errors in RedisProxy#increment 2019-10-15 22:54:33 +03:00
Gonzalo Rodriguez
6cfd036c2b
Merge pull request #435 from dsantosmerino/refactor/throttle-matched-by
Refactor `Throttle#matched_by?` method
2019-10-14 18:01:04 -03:00
dsantosmerino
49131bb4c6 Refactor Throttle#matched_by? method
Code Climate complains about the complexity of this method. Here we try to reduce it by using private methods that encapsulate some details that are not required to understand the implementation of the main method.
2019-10-13 09:36:44 +02:00
Gonzalo Rodriguez
9bfec1ac70
Bump gem version to v6.2.0 2019-10-12 19:04:46 -03:00
Gonzalo Rodriguez
1167c65ba6
Don't autoplug middleware for untested rails versions 2019-10-12 18:10:10 -03:00
Gonzalo Rodriguez
f65431f788
feat: provide possibility of rescuing any Rack::Attack error 2019-10-11 18:02:04 -03:00
Gonzalo Rodriguez
7b5f9c07c8
build: fix gem build open-ended version warning 2019-10-11 17:51:46 -03:00
Gonzalo Rodriguez
2d1de4ac62
docs: add note about README contents gotcha 2019-10-11 16:00:01 -03:00
Gonzalo Rodriguez
95347e35f1
Merge pull request #431 from fatkodima/use-middleware
Auto plug middleware for simpler installation
2019-10-09 16:12:22 -03:00
fatkodima
f22b24cbc5 Do not auto-plug for rails < 5 2019-10-08 13:08:07 +03:00
fatkodima
bdfb01ab5b Changes and tests 2019-10-08 12:29:25 +03:00
fatkodima
b512e05786 Auto plug middleware for simpler installation 2019-10-08 12:29:25 +03:00
Gonzalo Rodriguez
e5ceab040c
ci: update rubies 2019-10-02 10:51:01 -03:00
Gonzalo Rodriguez
bdc89dde7b
test: fix minitest/spec deprecation warnings 2019-10-01 17:19:44 -03:00
Gonzalo Rodriguez
6fba2c010d
test: update rubocop-performance to v1.5 2019-10-01 16:52:21 -03:00