mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 21:18:19 +07:00
[PR #6134] [CLOSED] fix(sub): honor trustedProxyCIDRs before letting forwarded headers steer URLs #6097
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#6097
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/6134
Author: @PathGao
Created: 7/29/2026
Status: ❌ Closed
Base:
main← Head:fix-sub-forwarded-header-trust📝 Commits (3)
9692e7dfix(sub): honor trustedProxyCIDRs before letting forwarded headers steer URLs161da9dfix(sub): evaluate the forwarded-header gate once and log when it bites457503efix(sub): enforce forwarded-header trust by default📊 Changes
3 files changed (+296 additions, -6 deletions)
View changed files
➕
internal/sub/forwarded_trust.go(+77 -0)➕
internal/sub/forwarded_trust_test.go(+202 -0)📝
internal/sub/service.go(+17 -6)📄 Description
Summary
Subscription URLs now apply
trustedProxyCIDRswith the same trust boundary as panel-generated links. Before this change, a request reaching the subscription server could steer generated hosts and schemes through forwarded headers even when the setting was unset, empty, or still at its default; now those states trust only loopback, while a configured value trusts exactly its listed addresses and CIDRs.This is an intentional default-behavior change. Deployments using a remote reverse proxy for the subscription endpoint must add that proxy to
trustedProxyCIDRsor configuresubURI; this matches the setting's documented meaning and the panel's existing behavior. Rejected forwarded headers are logged at debug level, with one process-level warning when they first affect URL generation.Tests
X-Real-IPcannot bypass the forwarded-header gate.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.