[PR #6135] [MERGED] fix(sub): honor trustedProxyCIDRs before forwarded URLs #6098

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

📋 Pull Request Information

Original PR: https://github.com/MHSanaei/3x-ui/pull/6135
Author: @PathGao
Created: 7/29/2026
Status: ✅ Merged
Merged: 7/29/2026
Merged by: @MHSanaei

Base: main ← Head: fix-sub-forwarded-header-trust-v2


📝 Commits (3)

  • 6b9a1fe fix(sub): honor trustedProxyCIDRs before forwarded URLs
  • 419ab8e fix(sub): avoid unused trust-setting lookups
  • 2672b22 fix(frontend): meet config text contrast requirements

📊 Changes

10 files changed (+325 additions, -12 deletions)

View changed files

📝 docs/content/docs/en/config/panel.mdx (+1 -1)
📝 docs/content/docs/fa/config/panel.mdx (+1 -1)
📝 docs/content/docs/ru/config/panel.mdx (+1 -1)
📝 docs/content/docs/zh/config/panel.mdx (+1 -1)
📝 frontend/src/components/clients/ConfigBlock.css (+4 -0)
➕ internal/sub/forwarded_trust.go (+92 -0)
➕ internal/sub/forwarded_trust_test.go (+205 -0)
📝 internal/sub/service.go (+17 -6)
📝 internal/web/controller/util.go (+1 -1)
📝 internal/web/service/setting.go (+2 -1)

📄 Description

Summary

Subscription URLs now honor an operator's customized trustedProxyCIDRs before forwarded headers determine their host or scheme. This aligns the subscription server with the setting's intended boundary without changing existing deployments that have no stored value, an empty value, or the shipped default.

The compatibility rule is deliberate: those untouched states retain the legacy forwarded-header behavior. Deployments that have declared a proxy boundary now receive the same protection for subscription links as they do for panel-generated links; rejected headers are diagnosable without permitting a polling client to flood warning logs.

Tests

  • Table-driven coverage for unset, empty, factory-default, custom-CIDR, malformed, and IPv4-mapped proxy origins.
  • Coverage that untrusted X-Real-IP cannot bypass the forwarded-header gate.
  • The local checkout has no Go toolchain, so the Go suite could not be run here.

🔄 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/6135 **Author:** [@PathGao](https://github.com/PathGao) **Created:** 7/29/2026 **Status:** ✅ Merged **Merged:** 7/29/2026 **Merged by:** [@MHSanaei](https://github.com/MHSanaei) **Base:** `main` ← **Head:** `fix-sub-forwarded-header-trust-v2` --- ### 📝 Commits (3) - [`6b9a1fe`](https://github.com/MHSanaei/3x-ui/commit/6b9a1fe4a8b3c78826e24310346b6c7b2895a642) fix(sub): honor trustedProxyCIDRs before forwarded URLs - [`419ab8e`](https://github.com/MHSanaei/3x-ui/commit/419ab8e1a7bf6618f4d544bf7ac3ded87c4889e8) fix(sub): avoid unused trust-setting lookups - [`2672b22`](https://github.com/MHSanaei/3x-ui/commit/2672b22b41971b9336c593ad32423b6293b0d5aa) fix(frontend): meet config text contrast requirements ### 📊 Changes **10 files changed** (+325 additions, -12 deletions) <details> <summary>View changed files</summary> 📝 `docs/content/docs/en/config/panel.mdx` (+1 -1) 📝 `docs/content/docs/fa/config/panel.mdx` (+1 -1) 📝 `docs/content/docs/ru/config/panel.mdx` (+1 -1) 📝 `docs/content/docs/zh/config/panel.mdx` (+1 -1) 📝 `frontend/src/components/clients/ConfigBlock.css` (+4 -0) ➕ `internal/sub/forwarded_trust.go` (+92 -0) ➕ `internal/sub/forwarded_trust_test.go` (+205 -0) 📝 `internal/sub/service.go` (+17 -6) 📝 `internal/web/controller/util.go` (+1 -1) 📝 `internal/web/service/setting.go` (+2 -1) </details> ### 📄 Description ## Summary Subscription URLs now honor an operator's customized `trustedProxyCIDRs` before forwarded headers determine their host or scheme. This aligns the subscription server with the setting's intended boundary without changing existing deployments that have no stored value, an empty value, or the shipped default. The compatibility rule is deliberate: those untouched states retain the legacy forwarded-header behavior. Deployments that have declared a proxy boundary now receive the same protection for subscription links as they do for panel-generated links; rejected headers are diagnosable without permitting a polling client to flood warning logs. ## Tests - Table-driven coverage for unset, empty, factory-default, custom-CIDR, malformed, and IPv4-mapped proxy origins. - Coverage that untrusted `X-Real-IP` cannot bypass the forwarded-header gate. - The local checkout has no Go toolchain, so the Go suite could not be run here. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-02 04:06:21 +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#6098
No description provided.