mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 21:18:19 +07:00
[PR #5271] [MERGED] feat(web): cap request body size on state-changing routes #5838
Labels
No labels
backlog
bug
clarification needed
documentation
duplicate
enhancement
github_actions
good first issue
invalid
javascript
New Feature
PR welcomed
pull-request
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
MHSanaei/3x-ui#5838
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/MHSanaei/3x-ui/pull/5271
Author: @n0ctal
Created: 6/13/2026
Status: ✅ Merged
Merged: 6/15/2026
Merged by: @MHSanaei
Base:
main← Head:pr-0008-bodylimit-main📝 Commits (3)
107a14bfeat(web): cap request body size on state-changing routesc9f0330Merge branch 'main' into pr-0008-bodylimit-mainbbafc2bfix(web): exempt importDB from request body size cap📊 Changes
3 files changed (+132 additions, -0 deletions)
View changed files
➕
internal/web/middleware/bodylimit.go(+43 -0)➕
internal/web/middleware/bodylimit_test.go(+80 -0)📝
internal/web/web.go(+9 -0)📄 Description
Summary
This PR adds a request body size limit for state-changing routes.
It uses
http.MaxBytesReaderto reject oversized request bodies before they cause unnecessary memory allocation or long processing on mutation endpoints.Why
Even with authentication in place, large request bodies on create/update/import-style routes are an avoidable resource risk. A reasonable cap improves resilience against buggy clients and accidental oversized submissions.
Scope
Validation
Risk
Low. This is defensive hardening and does not alter normal successful request flows.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.