[PR #5361] [MERGED] fix(runtime): cap remote node response size to bound master memory #5856

Closed
opened 2026-11-02 04:04:35 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/MHSanaei/3x-ui/pull/5361
Author: @n0ctal
Created: 6/15/2026
Status: ✅ Merged
Merged: 6/19/2026
Merged by: @MHSanaei

Base: main ← Head: pr-remote-response-cap


📝 Commits (1)

  • 4856c9b fix(runtime): cap remote node response size to bound master memory

📊 Changes

2 files changed (+152 additions, -4 deletions)

View changed files

📝 internal/web/runtime/remote.go (+56 -4)
📝 internal/web/runtime/remote_test.go (+96 -0)

📄 Description

Summary

Caps the size of a remote node's HTTP response that the master will buffer.

Why

Remote node responses were read with an unbounded io.ReadAll, so a broken or hostile node could force the master panel to buffer an arbitrarily large body (memory-exhaustion). All node calls funnel through a single Remote.do method.

Scope

  • validates HTTP status before reading any success payload (a non-OK body is read only up to a small bounded diagnostic snippet)
  • fast-fails on an honestly-declared oversize Content-Length
  • reads the success body through an io.LimitReader cap (64 MiB), returning a typed oversize error
  • documents that the cap bounds one response's wire/decompressed size — not a process-wide memory bound

Validation

  • tests for the cap+1 boundary, an oversize streamed body, a normal envelope, and non-OK status precedence
  • go test -race passes

Risk

Low–Medium. Touches the shared node-RPC path, but behavior is preserved for normal responses and the change is test-backed.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/MHSanaei/3x-ui/pull/5361 **Author:** [@n0ctal](https://github.com/n0ctal) **Created:** 6/15/2026 **Status:** ✅ Merged **Merged:** 6/19/2026 **Merged by:** [@MHSanaei](https://github.com/MHSanaei) **Base:** `main` ← **Head:** `pr-remote-response-cap` --- ### 📝 Commits (1) - [`4856c9b`](https://github.com/MHSanaei/3x-ui/commit/4856c9b9d74cdff1e08041284e7f78867d55ba7d) fix(runtime): cap remote node response size to bound master memory ### 📊 Changes **2 files changed** (+152 additions, -4 deletions) <details> <summary>View changed files</summary> 📝 `internal/web/runtime/remote.go` (+56 -4) 📝 `internal/web/runtime/remote_test.go` (+96 -0) </details> ### 📄 Description ## Summary Caps the size of a remote node's HTTP response that the master will buffer. ## Why Remote node responses were read with an unbounded `io.ReadAll`, so a broken or hostile node could force the master panel to buffer an arbitrarily large body (memory-exhaustion). All node calls funnel through a single `Remote.do` method. ## Scope - validates HTTP status before reading any success payload (a non-OK body is read only up to a small bounded diagnostic snippet) - fast-fails on an honestly-declared oversize `Content-Length` - reads the success body through an `io.LimitReader` cap (64 MiB), returning a typed oversize error - documents that the cap bounds one response's wire/decompressed size — not a process-wide memory bound ## Validation - tests for the `cap+1` boundary, an oversize streamed body, a normal envelope, and non-OK status precedence - `go test -race` passes ## Risk Low–Medium. Touches the shared node-RPC path, but behavior is preserved for normal responses and the change is test-backed. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-02 04:04:35 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
MHSanaei/3x-ui#5856
No description provided.