boulder/sa
Jacob Hoffman-Andrews 6c93b41f20 Add a limit on failed authorizations (#2513)
Fixes #976.

This implements a new rate limit, InvalidAuthorizationsPerAccount. If a given account fails authorization for a given hostname too many times within the window, subsequent new-authz attempts for that account and hostname will fail early with a rateLimited error. This mitigates the misconfigured clients that constantly retry authorization even though they always fail (e.g., because the hostname no longer resolves).

For the new rate limit, I added a new SA RPC, CountInvalidAuthorizations. I chose to implement this only in gRPC, not in AMQP-RPC, so checking the rate limit is gated on gRPC. See #2406 for some description of the how and why. I also chose to directly use the gRPC interfaces rather than wrapping them in core.StorageAuthority, as a step towards what we will want to do once we've moved fully to gRPC.

Because authorizations don't have a created time, we need to look at the expires time instead. Invalid authorizations retain the expiration they were given when they were created as pending authorizations, so we use now + pendingAuthorizationLifetime as one side of the window for rate limiting, and look backwards from there. Note that this means you could maliciously bypass this rate limit by stacking up pending authorizations over time, then failing them all at once.

Similarly, since this limit is by (account, hostname) rather than just (hostname), you can bypass it by creating multiple accounts. It would be more natural and robust to limit by hostname, like our certificate limits. However, we currently only have two indexes on the authz table: the primary key, and

(`registrationID`,`identifier`,`status`,`expires`)

Since this limit is intended mainly to combat misconfigured clients, I think this is sufficient for now.

Corresponding PR for website: letsencrypt/website#125
2017-01-23 11:22:51 -08:00
..
_db `certificateStatus` table optimizations (Part One) (#2177) 2016-09-30 14:52:19 -04:00
_db-next Use `DEFAULT "valid"` for new status column on reg. (#2380) 2016-12-01 13:14:50 -08:00
proto Add a limit on failed authorizations (#2513) 2017-01-23 11:22:51 -08:00
satest Updates `go-jose` dep to v1.1.0 (#2314) 2016-11-08 13:56:50 -05:00
authz.go Reverts pending auth/authz table merge. (#2297) 2016-10-31 10:31:19 -07:00
database.go Renames prefixedDatabase pkg to prefixdb 2016-11-30 16:51:08 -05:00
database_test.go Use max_statement_time for timeouts. (#2263) 2016-10-20 10:29:29 -04:00
ip_range_test.go Remove all stray copyright headers and appends the initial line to LICENSE.txt (#1853) 2016-05-31 12:32:04 -07:00
model.go Updates `go-jose` dep to v1.1.0 (#2314) 2016-11-08 13:56:50 -05:00
model_test.go Re-apply 2138 with proper gating (#2199) 2016-09-29 17:16:03 -04:00
rollback.go context.Context as the first parameter of all RPC calls (#1741) 2016-04-19 11:34:36 -07:00
sa.go Add a limit on failed authorizations (#2513) 2017-01-23 11:22:51 -08:00
sa_test.go Add a limit on failed authorizations (#2513) 2017-01-23 11:22:51 -08:00
test-cert.der Store a DB of issued names. 2015-09-28 19:37:50 -07:00
test-cert2.der Implement rate limiting by domain name. 2015-10-04 21:04:26 -07:00
type-converter.go Updates `go-jose` dep to v1.1.0 (#2314) 2016-11-08 13:56:50 -05:00
type-converter_test.go Fixes unused errs 2016-11-30 13:51:43 -05:00
www.eff.org.der Add initial certificate status in SA. 2015-04-23 19:52:34 -07:00