mtg icon indicating copy to clipboard operation
mtg copied to clipboard

Suspicion of TSPU protocol detection after a Fake-TLS handshake

Open 6lGRUSHAl6 opened this issue 6 months ago • 6 comments

It seems that TSPU (RF) algorithms have learned to accurately detect MTProto traffic inside Fake-TLS, based on payload analysis after connection establishment.

I captured a traffic dump (Wireshark) and discovered the following blocking pattern:

1. Normal availability check and initial handshake succeed. The server responds to TCP SYN, and the TLS Client Hello and Server Hello exchange completes.
2. As soon as Application Data transmission (the actual MTProto session setup) begins, TSPU intervenes in the process.
3. The connection is not actively terminated (DPI does not send a TCP RST), but packet drops occur. The client starts spamming [TCP Retransmission], trying to reach the server, but there is no further response.

By the way, if you simply test server availability, the connection establishes perfectly.

I am using the latest version of mtg (2.2.8) as well as the latest version of Telegram.

Image Image Image Image

6lGRUSHAl6 avatar May 28 '26 00:05 6lGRUSHAl6

Please see here: https://github.com/telegramdesktop/tdesktop/issues/30733 We can do nothing about it.

9seconds avatar May 28 '26 09:05 9seconds

For other server-side maintainers landing here — there IS one server-side trick that doesn't require client cooperation: announce a small TCP MSS in the SYN-ACK, and the client kernel fragments its outgoing ClientHello across multiple TCP segments. At MSS=256, ALPN and signature_algorithms typically land in segment 2/3 of a Telegram ClientHello, and a DPI that JA4-fingerprints from the first packet alone gets the wrong hash.

teleproxy v4.14.0 ships this automatically on the public listener: https://github.com/teleproxy/teleproxy/releases/tag/v4.14.0 — full mechanism and the throughput trade-off are documented at https://teleproxy.github.io/features/dpi-resistance/#forced-clienthello-fragmentation-automatic.

Not a complete fix — a DPI that fully reassembles TCP streams still computes the right JA4 — but TSPU has been observed to operate on intact segments at line-rate, so single-packet fragmentation is enough to defeat many deployments today. Filed in case the same trick is useful in mtg.

rkline0x avatar May 30 '26 11:05 rkline0x

Thanks for the suggestion @rkline0x I tested this on my VPS.

Unfortunately, TSPU (Russian DPI) is smart enough to bypass this trick via full stream reassembly.

So, while the TCP MSS trick is great, in my region TSPU apparently performs full stream reassembly when needed, making this workaround ineffective right now.

6lGRUSHAl6 avatar May 31 '26 00:05 6lGRUSHAl6

I tried splitting the TCP MSS stream, but that didn't work either. - (Russian DPI) I also tried using a proxy from colleagues, "teleproxy," where this feature is enabled by default, and the behavior is the same.

Currently, almost no proxy with the MTPROTO protocol works. There are occasional connections, but mostly a constant "connection".

In the desktop version, I use HTTP; this option works for now...

Termetik avatar Jun 07 '26 11:06 Termetik

  1. My mtproto proxy connection is blocked periods-to-periods, right now on my Android proxy is successfully working, both through mobile network and through home cable internet.
  2. As far I can see, this is a protocol-blocking issue, right? No matter if I deploy mtproto backend to my Moscow-hosted VPS instead of Finland-hosted?
  3. On my Desktop I am autossh-ing to that Finnish VPS, using dynamic port forward as a SOCKS proxy. On the Moscowish VPS I am also autossh-ing with dynamic port forward, to provide stable connection for my Telegram bot based there. I am considering as an option to set up a public SOCKS proxy over that tunnel. Anybody tried? What caveats are there? What to use as a frontend? Something like 3proxy?

enderteszla avatar Jun 09 '26 03:06 enderteszla

Поддержите пальцем вверх и максимальный репост Please like and share this as often as possible. We need to get the developers' attention. https://bugs.telegram.org/c/62528

iolpltuisciaoln avatar Jun 09 '26 03:06 iolpltuisciaoln