Skip to content

Add user ID based allowlist for Rack::Attack

Jacob Vosmaer requested to merge jv-rack-attack-user-bypass into master

What does this MR do?

For gitlab-com/gl-infra&341 (closed) we are finding that in order to tighten rate limiting, it would help us to have an allowlist for a small number of existing users that currently exceed the limits.

This implements gitlab-com/gl-infra/scalability#697 (closed).

"Screenshots"

At startup, this feature will log the current allowlist in auth.log.

{"severity":"INFO","time":"2020-12-03T17:05:14.096Z","correlation_id":null,"gitlab_throttle_user_allowlist":[1,53,217]}

Requests that bypass rate limiting because of the user allowlist get marked as such in the structured logs with "throttle_safelist":"throttle_user_allowlist":

{"time":"2020-12-03T17:03:26.567Z","severity":"INFO","duration_s":0.05236,"db_duration_s":0.01356,"view_duration_s":0.0388,"status":200,"method":"GET","path":"/api/v4/projects/7","params":[],"host":"localhost","remote_ip":"127.0.0.1","ua":"curl/7.64.1","route":"/api/:version/projects/:id","user_id":1,"username":"root","queue_duration_s":0.196763,"redis_calls":7,"redis_duration_s":0.001245,"redis_read_bytes":804,"redis_write_bytes":329,"redis_cache_calls":7,"redis_cache_duration_s":0.001245,"redis_cache_read_bytes":804,"redis_cache_write_bytes":329,"throttle_safelist":"throttle_user_allowlist","correlation_id":"nUBaysbbe6a","meta.user":"root","meta.project":"root/gitlab2","meta.root_namespace":"root","meta.caller_id":"/api/:version/projects/:id","meta.feature_category":"projects"}

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

Security

If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:

  • Label as security and @ mention @gitlab-com/gl-security/appsec
  • The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
  • Security reports checked/validated by a reviewer from the AppSec team
Edited by Jacob Vosmaer

Merge request reports