Rate limit vulnerability severity overrides and bulk dismissals per user
What does this MR do and why?
The vulnerabilitiesSeverityOverride and vulnerabilitiesDismiss mutations each take up to 100 vulnerability IDs. Severity override writes notes, audit events and other records for every vulnerability. Bulk dismiss changes the state of each one, writing state transitions and audit events. Today nothing limits how often one user can call either mutation, beyond generic request throttling.
This MR adds per-user rate limits to both mutations:
| Key | Mutation | Limit |
|---|---|---|
vulnerability_severity_override |
vulnerabilitiesSeverityOverride |
160 calls per minute |
vulnerability_severity_override_hourly |
vulnerabilitiesSeverityOverride |
4,000 calls per hour |
vulnerability_bulk_dismiss |
vulnerabilitiesDismiss |
520 calls per minute |
vulnerability_bulk_dismiss_hourly |
vulnerabilitiesDismiss |
11,200 calls per hour |
The per-minute limits stop bursts and the hourly limits cap sustained use. The numbers are a starting point and may change before enforcement. The bulk dismiss numbers are placeholders until its traffic is re-analysed.
The new Mutations::Vulnerabilities::BulkUpdateRateLimit concern provides bulk_update_rate_limited?(keys). It counts the call against every key. It logs over-limit calls to auth.log. Calls without a Rack request (such as GraphqlChannel) still count, but are not logged.
Each mutation defines RATE_LIMIT_KEYS and a private verify_rate_limit!, called at the start of resolve. That method checks the mutation's flag and raises the throttled error. The flag check lives in the mutation because feature flag names must be literal symbols. Aliased mutations in one request each count.
Calls are rejected only when the mutation's flag is on:
enforce_vulnerability_severity_override_rate_limitfor severity overrideenforce_vulnerability_bulk_dismiss_rate_limitfor bulk dismiss
Both flags are gitlab_com_derisk, off by default, and use the current user as actor. With a flag off, calls are counted and logged but still go through. This lets us see real traffic before we enforce.
The UI sends one call per bulk action, so normal use stays far below the limits. The MCP save_vulnerability tool also calls the severity override mutation. It is covered because the limit is per user.
The two mutations have separate keys and flags because they have different traffic and write different records. Separate keys let us watch each one's logs, and we can merge to a combined limit later if the logs support it. The bulk dismiss limit was first reviewed in !266310 (merged), which was merged into this branch.
GitLab.com rate limit docs and the mutation descriptions will be updated when the limits are enforced, not in this MR.
References
- Related to https://gitlab.com/gitlab-org/gitlab/-/work_items/635824 (confidential) and https://gitlab.com/gitlab-org/gitlab/-/work_items/606896 (confidential)
- Same logging pattern: !265715 (merged)
- Same flag approach: !265662 (merged)
- Rollout issues: #638269 (severity override) and #639443 (bulk dismiss). Before either 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.
The steps below use severity override. For bulk dismiss, use the vulnerability_bulk_dismiss key with 520.times, the enforce_vulnerability_bulk_dismiss_rate_limit flag and the vulnerabilitiesDismiss mutation.
-
In a Rails console, use up the per-minute limit for your user:
user = User.find_by_username('your-username') 160.times { Gitlab::ApplicationRateLimiter.throttled?(:vulnerability_severity_override, scope: { user: user }) } -
Make sure the flag is off:
Feature.disable(:enforce_vulnerability_severity_override_rate_limit) -
Within a minute, sign in as that user and open GraphiQL at
/-/graphql-explorer. Run avulnerabilitiesSeverityOverridemutation. 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_severity_override_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.