Rate limit bulk vulnerability dismissals per user
What does this MR do and why?
This is a stacked MR. It targets the branch of !266133 (merged) and must merge after it.
The vulnerabilitiesDismiss mutation takes up to 100 vulnerability IDs and changes the state of each one. Today nothing limits how often one user can call it, beyond generic request throttling.
This MR adds two per-user rate limits to the EE Labkit registry:
vulnerability_bulk_dismiss: 520 calls per minute.vulnerability_bulk_dismiss_hourly: 11,200 calls per hour.
These numbers are placeholders until bulk dismiss traffic is re-analysed. They will change before enforcement.
Mutations::Vulnerabilities::BulkDismiss includes the BulkUpdateRateLimit concern. It defines RATE_LIMIT_KEYS and a private verify_rate_limit!, called at the start of resolve. The behavior matches the severity override limit:
- With the flag off, calls are counted and logged but still go through.
- With the flag on, over-limit calls get the throttled error.
- Aliased mutations in one request each count.
- Calls without a Rack request are counted but not logged.
Rejection only happens when the enforce_vulnerability_bulk_dismiss_rate_limit flag is on. The flag is gitlab_com_derisk and off by default.
The keys are separate from severity override because the two mutations have different traffic and write different records. We can merge to a combined limit later if the logs support it.
GitLab.com rate limit docs and the mutation description will be updated when the limit is enforced, not in this MR.
References
- Related to https://gitlab.com/gitlab-org/gitlab/-/work_items/606896 (confidential)
- Depends on !266133 (merged)
- Rollout issue: to be created. Before the flag is enabled, someone familiar with rate limits will review the final numbers.
Screenshots or screen recordings
Not applicable, backend-only change.
How to set up and validate locally
You need the admin_vulnerability permission on the project (for example, a maintainer). The project needs an Ultimate license.
-
In a Rails console, use up the per-minute limit for your user:
user = User.find_by_username('your-username') 520.times { Gitlab::ApplicationRateLimiter.throttled?(:vulnerability_bulk_dismiss, scope: { user: user }) } -
Make sure the flag is off:
Feature.disable(:enforce_vulnerability_bulk_dismiss_rate_limit) -
Within a minute, sign in as that user and open GraphiQL at
/-/graphql-explorer. Run avulnerabilitiesDismissmutation. It succeeds. If the minute has passed, repeat step 1 first. -
Check that
log/auth_json.loghas a newApplication_Rate_Limiter_Requestline for your user. -
Enable the flag in the console:
Feature.enable(:enforce_vulnerability_bulk_dismiss_rate_limit) -
Within a minute of step 1, run the same mutation again. It returns the rate limit error.
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.