[GH-ISSUE #6746] [Feature]: Option to update existing MTProto client secrets when the inbound's FakeTLS domain (SNI) changes #4496

Open
opened 2026-10-31 20:40:03 +07:00 by bsakaguchi · 3 comments
Owner

Originally created by @Ramazik on GitHub (Oct 5, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/6746

Describe the bug

As is known, for clients using the MTProto protocol, the “MTProto secret” value is generated according to a specific formula, where the last part consists precisely of the “FakeTLS domain (SNI)”.

FakeTLS secret is generated as a unified hexadecimal string composed of three sequential parts:
• Prefix (1 byte): The constant magic byte 0xEE.
• Proxy Token (16 bytes): Random cryptographic bytes used for traffic decryption.
• SNI Domain (Variable length): The disguise domain name encoded in UTF-8.
Formula:
Final Secret (MTProto secret) = Hex(0xEE + 16-byte Token + UTF-8 Domain)

However, from the very beginning of the implementation of this protocol in the 3x-ui panel, changing the “FakeTLS domain (SNI)” value in the MTProto protocol’s inbound does not change the “MTProto secret” value for clients. To obtain the new correct value, you have to do this manually for each client by clicking the “Update MTProto secret” button (the circle with an arrow).

How to reproduce the problem

The description is provided above.

Expected behavior

Changing the “FakeTLS domain (SNI)” in the MTProto protocol’s inbound should change the “MTProto secret” values for clients.

Actual behavior

[Bug]: Changing the “FakeTLS domain (SNI)” in the MTProto protocol’s inbound configuration does not change the “MTProto secret” value for clients.

Relevant logs


Screenshots

No response

3x-ui version

3.9.0

Xray-core version

26.9.30

How did you install 3x-ui?

install.sh script

Operating system

Ubuntu 24.04

Which parts of the panel are affected?

No response

Browser (only if it is a UI bug)

MS Edge 154

Is the panel behind a reverse proxy or CDN?

None

Before submitting

  • I searched existing issues and this bug has not been reported.
  • I am running the latest released version of 3x-ui (or have verified the bug still exists on it).
  • This bug report is written in English.
  • I have redacted any sensitive data (tokens, real domains, client UUIDs).
Originally created by @Ramazik on GitHub (Oct 5, 2026). Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/6746 ### Describe the bug As is known, for clients using the MTProto protocol, the “MTProto secret” value is generated according to a specific formula, where the last part consists precisely of the “FakeTLS domain (SNI)”. FakeTLS secret is generated as a unified hexadecimal string composed of three sequential parts: • Prefix (1 byte): The constant magic byte 0xEE. • Proxy Token (16 bytes): Random cryptographic bytes used for traffic decryption. • SNI Domain (Variable length): The disguise domain name encoded in UTF-8. Formula: Final Secret (MTProto secret) = Hex(0xEE + 16-byte Token + UTF-8 Domain) However, from the very beginning of the implementation of this protocol in the 3x-ui panel, changing the “FakeTLS domain (SNI)” value in the MTProto protocol’s inbound does not change the “MTProto secret” value for clients. To obtain the new correct value, you have to do this manually for each client by clicking the “Update MTProto secret” button (the circle with an arrow). ### How to reproduce the problem The description is provided above. ### Expected behavior Changing the “FakeTLS domain (SNI)” in the MTProto protocol’s inbound should change the “MTProto secret” values for clients. ### Actual behavior [Bug]: Changing the “FakeTLS domain (SNI)” in the MTProto protocol’s inbound configuration does not change the “MTProto secret” value for clients. ### Relevant logs ```shell ``` ### Screenshots _No response_ ### 3x-ui version 3.9.0 ### Xray-core version 26.9.30 ### How did you install 3x-ui? install.sh script ### Operating system Ubuntu 24.04 ### Which parts of the panel are affected? _No response_ ### Browser (only if it is a UI bug) MS Edge 154 ### Is the panel behind a reverse proxy or CDN? None ### Before submitting - [x] I searched [existing issues](../issues?q=is%3Aissue) and this bug has not been reported. - [x] I am running the latest released version of 3x-ui (or have verified the bug still exists on it). - [x] This bug report is written in English. - [x] I have redacted any sensitive data (tokens, real domains, client UUIDs).
Author
Owner

@github-actions[bot] commented on GitHub (Oct 5, 2026):

This is how the panel is designed to work, not a defect: the inbound's FakeTLS domain (SNI) is only the default used when a new client secret is generated, and every client keeps the domain already embedded in its own secret. Updating existing clients automatically when the default changes would be a new feature, so I've relabelled this as an enhancement request and left it open.

Why existing secrets don't change

  • The field's tooltip says so: frontend/src/pages/inbounds/form/protocols/mtproto.tsx:20 shows pages.inbounds.form.mtprotoFakeTlsDomainHint, which is (internal/web/translation/en-US.json:507):

    "Default FakeTLS domain used to generate a new client's secret. Each client can front its own domain."

  • When an inbound is saved, normalizeMtprotoSecret (internal/web/service/inbound.go:1002) calls HealMtprotoClientSecrets (internal/database/model/model.go:724). That function only uses the inbound domain when a client's secret has no domain of its own:
    domain := mtprotoSecretDomain(secret)
    if domain == "" {
        domain = defaultDomain
    }
    
    The comment on mtprotoSecretDomain (model.go:700-703) gives the reason: "Each mtproto client carries its own domain inside its secret, so healing preserves it instead of forcing every client onto the inbound-level default."
  • A test pins this behaviour. TestHealMtprotoClientSecrets (internal/database/model/model_mtproto_test.go:107-114) checks that a client secret for b.com stays unchanged when the inbound default is a.com: "a valid per-client secret must be left untouched".
  • Per-client domains were designed in from the start: this logic came in with d97bd864 ("feat(mtproto): adopt dolonet/mtg-multi and make MTProto inbounds multi-client").

There's a second reason not to rewrite secrets on their own. The secret is the value in each client's tg:// link, so changing it silently would break every link you've already handed out until clients import the new one.

Workaround for now

Do what you're already doing: open each client and click the regenerate button next to MTProto secret. It calls regenerateMtprotoSecret() (frontend/src/pages/clients/ClientFormModal.tsx:521), which builds a new secret from the inbound's current domain. Then send the new link to that client.

What the feature could look like (for the maintainer)

When the inbound's fakeTlsDomain changes on save, offer an opt-in "also re-key clients that use the old domain" action. It would rewrite only the domain suffix and keep each secret's 16-byte random middle (mtprotoSecretMiddle, model.go:629), and it should warn that existing links will stop working. Clients that deliberately use a different domain would be left alone.

I changed the title to describe this as a request. The old title was: "[Bug]: Changing the “FakeTLS domain (SNI)” in the MTProto protocol’s inbound configuration does not change the “MTProto secret” value for clients."

Verdict: Feature request

This reply was generated automatically; a maintainer may follow up.

<!-- gh-comment-id:6003190800 --> @github-actions[bot] commented on GitHub (Oct 5, 2026): This is how the panel is designed to work, not a defect: the inbound's **FakeTLS domain (SNI)** is only the *default* used when a new client secret is generated, and every client keeps the domain already embedded in its own secret. Updating existing clients automatically when the default changes would be a new feature, so I've relabelled this as an enhancement request and left it open. **Why existing secrets don't change** - The field's tooltip says so: `frontend/src/pages/inbounds/form/protocols/mtproto.tsx:20` shows `pages.inbounds.form.mtprotoFakeTlsDomainHint`, which is (`internal/web/translation/en-US.json:507`): > "Default FakeTLS domain used to generate a new client's secret. Each client can front its own domain." - When an inbound is saved, `normalizeMtprotoSecret` (`internal/web/service/inbound.go:1002`) calls `HealMtprotoClientSecrets` (`internal/database/model/model.go:724`). That function only uses the inbound domain when a client's secret has no domain of its own: ```go domain := mtprotoSecretDomain(secret) if domain == "" { domain = defaultDomain } ``` The comment on `mtprotoSecretDomain` (`model.go:700-703`) gives the reason: *"Each mtproto client carries its own domain inside its secret, so healing preserves it instead of forcing every client onto the inbound-level default."* - A test pins this behaviour. `TestHealMtprotoClientSecrets` (`internal/database/model/model_mtproto_test.go:107-114`) checks that a client secret for `b.com` stays unchanged when the inbound default is `a.com`: *"a valid per-client secret must be left untouched"*. - Per-client domains were designed in from the start: this logic came in with `d97bd864` ("feat(mtproto): adopt dolonet/mtg-multi and make MTProto inbounds multi-client"). There's a second reason not to rewrite secrets on their own. The secret is the value in each client's `tg://` link, so changing it silently would break every link you've already handed out until clients import the new one. **Workaround for now** Do what you're already doing: open each client and click the regenerate button next to **MTProto secret**. It calls `regenerateMtprotoSecret()` (`frontend/src/pages/clients/ClientFormModal.tsx:521`), which builds a new secret from the inbound's current domain. Then send the new link to that client. **What the feature could look like (for the maintainer)** When the inbound's `fakeTlsDomain` changes on save, offer an opt-in "also re-key clients that use the old domain" action. It would rewrite only the domain suffix and keep each secret's 16-byte random middle (`mtprotoSecretMiddle`, `model.go:629`), and it should warn that existing links will stop working. Clients that deliberately use a different domain would be left alone. I changed the title to describe this as a request. The old title was: "[Bug]: Changing the “FakeTLS domain (SNI)” in the MTProto protocol’s inbound configuration does not change the “MTProto secret” value for clients." Verdict: Feature request *This reply was generated automatically; a maintainer may follow up.* <!-- claude-issue:analyst -->
Author
Owner

@Ramazik commented on GitHub (Oct 28, 2026):

@MHSanaei Hello. Please take note of my comment. Perhaps I don’t understand something, but I believe the AI agent’s reasoning and the change of the request status from [Bug] to [Feature] are incorrect.

There is no compelling argument not to consider this a bug. All subscription settings, when changed, can be viewed by a person on their subscription page, including changes to the MTProto inbound.
There is no compelling argument to worry about any value of the existing tg:// link for the client if the inbound parameters have already been changed, which means the configuration will be different.
There is no compelling argument to manually open the settings panel for each client and click the regeneration button next to the MTProto secret, as this takes a lot of time, especially if there are many clients.

<!-- gh-comment-id:6477598085 --> @Ramazik commented on GitHub (Oct 28, 2026): @MHSanaei Hello. Please take note of my comment. Perhaps I don’t understand something, but I believe the AI agent’s reasoning and the change of the request status from [Bug] to [Feature] are incorrect. There is no compelling argument not to consider this a bug. All subscription settings, when changed, can be viewed by a person on their subscription page, including changes to the MTProto inbound. There is no compelling argument to worry about any value of the existing tg:// link for the client if the inbound parameters have already been changed, which means the configuration will be different. There is no compelling argument to manually open the settings panel for each client and click the regeneration button next to the MTProto secret, as this takes a lot of time, especially if there are many clients.
Author
Owner

@Ramazik commented on GitHub (Oct 28, 2026):

Please also pay attention to this comment: https://github.com/MHSanaei/3x-ui/pull/6963#issuecomment-6477282031

<!-- gh-comment-id:6477620961 --> @Ramazik commented on GitHub (Oct 28, 2026): Please also pay attention to this comment: https://github.com/MHSanaei/3x-ui/pull/6963#issuecomment-6477282031
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#4496
No description provided.