Loading
Enforce maximum attachment size on repository UI file uploads
What does this MR do and why?
This MR enforces the "Maximum attachment size" admin setting on files uploaded to a repository through the GitLab UI "Upload file" button. Previously the setting applied only to comment and reply attachments, so a repository upload of any size was accepted.
The original reporter was able to commit a 417 MiB file with the instance limit set to 50 MiB. This was reproduced on a local GDK instance on 2026-09-15.
Why this gap existed:
- Workhorse: this upload path falls through to Workhorse's catch-all route, which pre-authorizes against the generic
/api/v4/internal/workhorse/authorize_uploadendpoint. That endpoint returns only aTempPathand noMaximumSize, so Workhorse streams the file with no size limit. - Rails:
Projects::BlobController#createand#updatenever consultedGitlab::CurrentSettings.max_attachment_size. - Git hooks:
Gitlab::Checks::FileSizeLimitCheckis a no-op in CE. The real implementation is EE-only and draws its limit from an EE push rule or a SaaS-only plan limit, which is why this does not reproduce on GitLab.com. - Maximum push size: this setting does not apply either, because a UI upload is a Gitaly
UserCommitFilesRPC rather than a git push, soreceive.maxInputSizeis never injected.
References
Screenshots or screen recordings
| Before | After |
|---|---|
![]() |
How to set up and validate locally
- In Admin Area, go to Settings > General > Account and limit and set "Maximum attachment size (MiB)" to 50.
- Create a file larger than 50 MiB:
head -c 55574528 /dev/urandom > large.bin - In a project, select the "Upload file" button and choose that file.
- The modal shows
File is too big (53.00MiB). Max filesize: 50MiB.and the commit button stays disabled. No commit is created. - Confirm the server-side check independently by disabling JavaScript or by posting the file directly to the create-blob endpoint; the response is HTTP 413 and no commit is created.
- Set the limit back to 100, then confirm a file under the limit still uploads and commits normally.
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.
Edited by Joseph Fletcher
