Backport of 'Count CI job token Git requests against the user's rate limit'

What does this MR do and why?

This MR backports !263309 (merged) to 19.4, for https://gitlab.com/gitlab-org/gitlab/-/work_items/634147.

Git over HTTP requests that authenticate with a CI job token (gitlab-ci-token:<token>) skip throttle_authenticated_git_http, so they are only counted per IP. One bot account on a GitLab Dedicated instance drove about 955 req/s this way for weeks (S1, infradev, SLO missed). Gitlab::Auth::RequestAuthenticator now reads job tokens from basic auth on Git paths, so these requests count against the job's user.

Rollout

After this change, job-token Git requests are no longer unauthenticated, so they leave throttle_unauthenticated_git_http and count under throttle_authenticated_git_http for the job's user. An instance that has only the unauthenticated Git HTTP limit enabled loses the limit that applies to these requests today. This applies to the affected GitLab Dedicated tenant and to every 19.4 self-managed instance.

  • GitLab Dedicated: confirmed in https://gitlab.com/gitlab-org/gitlab/-/work_items/634147. The affected instance has throttle_authenticated_git_http enforced at 6,000 requests per minute, and the limit never fired for this traffic because job-token requests skipped it. With this patch, those requests count against the job user's limit, so the patch does stop the incident traffic on that tenant. No setting change is needed there.
  • Self-managed instances that want a limit on these requests need throttle_authenticated_git_http_enabled on. This is the same rollout note as !263309 (merged), for the patch release post.
  • Job-token LFS batch and lock requests count toward the job user's limit. With throttle_authenticated_git_lfs_enabled on, they count toward that limit. With it off, they count toward the user's throttle_authenticated_web_enabled limit, as personal access token LFS requests do. LFS object uploads and downloads stay counted per IP.

Differences from master

Only changes that apply to 19.4 are backported. Code introduced in later releases is not added.

  • From !261357 (merged) (19.5): only Gitlab::PathRegex.repository_git_http_route_regex, in its current master form. The auth change needs an anchored Git path check. 19.4's git_request? matches .git anywhere in a path, which would accept job tokens on web paths such as /-/archive/main/x.git.zip or the raw files of a project named user.gitlab.io.
  • From !259720 (merged) (19.5): nothing. job_token_allowed stays true on API paths, so API behavior is unchanged. Only Git paths get [:basic_auth].
  • Job tokens are accepted only where both git_http_request? and 19.4's git_request? match. /<repo>/info/refs without .git is excluded, because the 19.4 throttles do not class it as Git. Master counts it as Git, so this is a deliberate difference.
  • Docs: the "Changed in GitLab 19.6" history entries are removed in doc/rate_limits/git.md, so the 19.4 docs do not reference a later version. The behavior text is kept.

Not changed on 19.4:

  • Throttle classification (git_path? and the labkit rules): info/refs without .git is still not classed as Git by the throttles.
  • API-path job token resolution at the rack layer, Bearer job tokens, and the git_request? override.

Specs from the master MR are included, except the cases that need the 19.5 changes above: info/refs without .git in the throttles, the user.gitlab.io web-throttle spec, the EE spec contexts, and a spec file that does not exist on 19.4. request_authenticator_spec.rb pins /<repo>/info/refs as not job-token-eligible on 19.4.

References

MR acceptance checklist

  • This MR is backporting a bug fix, documentation update, or spec fix, previously merged in the default branch.
  • The MR that fixed the bug on the default branch has been deployed to GitLab.com. (Merged 2026-11-16: confirm the deploy before merging.)
  • The MR title is descriptive (e.g. "Backport of 'title of default branch MR'"). This is important, since the title will be copied to the patch blog post.
  • Required labels have been applied to this merge request
  • This MR has been approved by a maintainer (only one approval is required). This touches authentication, so ask an Authentication maintainer.
  • Ensure the e2e:test-on-omnibus-ee job has succeeded, or if it has failed, investigate the failures. If you determine the failures are unrelated, you may proceed.

Note to the merge request author and maintainer

If you have questions about the patch release process, please:

Edited by Navjot Bansal

Merge request reports

Loading
Loading