We Trusted Telegram With Our Research to Protect Users — and Were Written Out of the Story
Qt's HTTP authentication code automatically starts an NTLM exchange with the logged-on Windows account when a proxy or server sends a 407 or 401 challenge advertising NTLM, without asking the user or the application. An attacker controlling the proxy could relay that authentication to another service, and a separate flaw in timestamp parsing leaked uninitialised heap memory into the NTLM response.
Published on medium.com
Information Security
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Context
Telegram Desktop delegates HTTP and SOCKS5 proxy connections to Qt. The proxy subsystem is therefore a trust boundary: a hostile proxy server controls the responses exchanged while the connection is being established. This write-up follows ExPatch's audit of that boundary, which began with a simple question: what happens when an attacker controls the proxy responses during connection establishment?
The chain that emerged combines forced NTLM authentication through a proxy, a repeatable heap-memory disclosure in QtNetwork, and a laboratory-validated relay to remote code execution. The root cause sits in QtNetwork's shared HTTP authentication implementation, qauthenticator.cpp, but Telegram Desktop made it practically reachable through its supported tg://proxy mechanism.
Setup
The testing used the official Telegram Desktop client, unmodified in source, executable, Qt build and authentication mechanisms. The full RCE chain was built in an isolated Active Directory environment using Windows Server 2022 and an Enterprise CA with AD CS Web Enrollment enabled. Every offensive component remained on the controlled proxy and laboratory infrastructure.
Additional applications were tested to establish reach of the underlying QtNetwork defect:
| Application | Qt version | Result |
|---|---|---|
| qBittorrent 4.6.3 | Qt 6.4.2 | Controlled proxy switched Basic to NTLM via 407; 65,076-byte NtChallengeResponse, about 64,876 bytes of unrelated heap data |
| Nextcloud Desktop 3.11.0 | Qt 5.15.13 | Four consecutive NTLM exchanges in one session; each response 65,076 bytes, roughly 260 KB of memory in total |
| Electrum 4.7.2 | Qt 6.11.0 | Separate direct path with no proxy; automatic NTLM Type 1 from a 401 response |
Finding it
The investigation started with the architecture of Telegram Desktop's proxy subsystem. For almost a month the team examined trust boundaries, state transitions and ways to force the client into unexpected behaviour. Most directions reached a dead end. The turning point was the discovery that, during an active proxy exchange, Qt accepted a demand to switch authentication to NTLM. A modern proxy connection could silently transition to a legacy mechanism associated with NTLM Relay attacks for decades.
At a high level the chain is simple. Telegram Desktop connects through a configured HTTP proxy and Qt sends a CONNECT request. A hostile proxy replies with 407 Proxy Authentication Required and advertises Proxy-Authenticate: NTLM. Qt treats the response as a normal authentication challenge, starts NTLM automatically, and sends the first handshake message, NTLM Type 1 (Negotiate). No explicit user consent is requested.
The key question was which checks Qt performed before allowing NTLM to use the user's system credentials. Because NTLM Relay has been understood for decades, the team expected a control binding authentication to the intended proxy and preventing replay to another service. The implementation contained no such protection: Qt did not validate an expected SPN, did not bind the exchange to a protected channel through EPA, and did not require exchange integrity through MIC. An attacker controlling the proxy did not need to crack NTLM or recover a password; relaying the authentication messages to another service in real time was enough.
Exploitation
Step 1: Qt accepts the 407 response
Telegram Desktop configures the proxy through QTcpSocket::setProxy. In qhttpsocketengine.cpp:562–599, Qt processes the proxy's response to CONNECT. A 407 Proxy Authentication Required status is passed to the built-in authentication mechanism:
} else if (statusCode == 407) { if (d->authenticator.isNull()) d->authenticator.detach(); priv = QAuthenticatorPrivate::getPrivate( d->authenticator ); const auto headers = d->reply->header(); priv->parseHttpResponse( headers, true, d->proxy.hostName() ); }
NTLM has not yet been selected at this level. The important detail is that Qt passes every proxy-controlled response header to parseHttpResponse() with isProxy=true. The authentication method is therefore selected from attacker-controlled Proxy-Authenticate content.
Step 2: Qt selects the authentication scheme
The transition to NTLM is chosen inside QAuthenticatorPrivate::parseHttpResponse() in qauthenticator.cpp:466–558. Because the function was called with isProxy=true, Qt examines the proxy-controlled Proxy-Authenticate header:
const auto search = isProxy ? QHttpHeaders::WellKnownHeader::ProxyAuthenticate : QHttpHeaders::WellKnownHeader::WWWAuthenticate;for (const auto ¤t : headers.values(search)) { if (method < Basic && str.startsWith("basic"_L1, Qt::CaseInsensitive)) { method = Basic; } else if (method < Ntlm && str.startsWith("ntlm"_L1, Qt::CaseInsensitive)) { method = Ntlm; headerVal = QByteArrayView(current).mid(5); } else if (method < DigestMd5 && str.startsWith("digest"_L1, Qt::CaseInsensitive)) { } else if (method < Negotiate && str.startsWith("negotiate"_L1, Qt::CaseInsensitive)) { }}case Ntlm:case Negotiate: break;
An additional problem is that method is reset before each new response is parsed. A proxy can therefore demand NTLM not only in the first response, but in a later 407, and change the scheme while the connection is already being established. Once Ntlm has been selected, the function performs no additional trust checks; generation of the system response is deferred to calculateResponse().
Step 3: Qt starts NTLM without notifying the application
After selecting the scheme, execution returns to qhttpsocketengine.cpp:574–599:
if (priv->phase == QAuthenticatorPrivate::Done || (priv->phase == QAuthenticatorPrivate::Start && (priv->method == QAuthenticatorPrivate::Ntlm || priv->method == QAuthenticatorPrivate::Negotiate))) { if (priv->phase == QAuthenticatorPrivate::Start) priv->phase = QAuthenticatorPrivate::Phase1; if ((priv->method != QAuthenticatorPrivate::Ntlm && priv->method != QAuthenticatorPrivate::Negotiate) || credentialsWasSent) { proxyAuthenticationRequired( d->proxy, &d->authenticator ); }}
The decisive point is the condition before proxyAuthenticationRequired(). With an ordinary scheme, Qt emits this signal so the application can request credentials or refuse authentication. During the first transition to NTLM or Negotiate, however, credentialsWasSent == false, making the entire condition false. No signal is emitted. Telegram Desktop consequently has no opportunity to approve, warn about, or block the transition. Qt moves the authenticator to Phase1, calls calculateResponse(), asks Windows SSPI for system SSO credentials, and sends an NTLM Type 1 (Negotiate) message to the proxy. The transition is silent not only to the user, but to the application itself.
The critical issue is not a flaw in SSPI itself, but the way Qt invokes it during automatic proxy authentication. If QAuthenticator contains no username, Qt does not stop the connection or ask the application for credentials. It calls Windows SSPI and obtains the default credentials of the current logon session. In a domain environment, a hostile proxy can therefore initiate an NTLM exchange on behalf of the user's corporate account without the user's knowledge.
Step 4: calculateResponse() selects system authentication
The first confirmation appears in qauthenticator.cpp:585–592. When the proxy requests NTLM and no challenge has yet been received, Qt begins the first handshake phase:
case QAuthenticatorPrivate::Ntlm: if (challenge.isEmpty()) {#if QT_CONFIG(sspi) QByteArray phase1Token; if (user.isEmpty()) { phase1Token = qSspiStartup( this, method, host ); } #endif } break;
The Qt comment is explicit: "Only pull from system if no user was specified in authenticator." This is where a proxy-controlled demand for NTLM is connected to the current Windows account.
Step 5: System credentials in qSspiStartup()
SEC_WINNT_AUTH_IDENTITY auth;auth.Flags = SEC_WINNT_AUTH_IDENTITY_UNICODE;bool useAuth = false;if (method == QAuthenticatorPrivate::Negotiate && !ctx->user.isEmpty()) { useAuth = true;}SECURITY_STATUS secStatus = pSecurityFunctionTable->AcquireCredentialsHandle( nullptr, L"NTLM", SECPKG_CRED_OUTBOUND, nullptr, useAuth ? &auth : nullptr, nullptr, nullptr, &ctx->sspiWindowsHandles->credHandle, &expiry );
useAuth becomes true only for Negotiate when a username has been supplied explicitly. In the NTLM path, Qt passes nullptr rather than a SEC_WINNT_AUTH_IDENTITY structure to AcquireCredentialsHandle(). Under the SSPI model, this selects the default outbound credentials of the current Windows security context, typically the logged-on corporate account in a domain environment. Qt does not obtain the password or NTLM hash in cleartext; SSPI returns an opaque credential handle from which it produces NTLM messages. The vulnerability lets the attacker relay the victim's authentication exchange.
Step 6: The NTLM context is not bound to the intended proxy
The credential handle is passed to qSspiContinue(), where Qt continues the handshake through Windows SSPI:
InitializeSecurityContext( &ctx->sspiWindowsHandles->credHandle, ..., ISC_REQ_ALLOCATE_MEMORY, ...);
Qt requests only automatic allocation for the output token. Three controls that could have hindered relay are absent:
ISC_REQ_INTEGRITYis not set, so Qt does not require context integrity;- no
SECBUFFER_CHANNEL_BINDINGSbuffer is supplied, so EPA/Channel Binding does not bind the NTLM exchange to a protected channel; - for direct NTLM,
targetNameWremains empty, so no SPN binds the context to the intended service.
Together, these omissions mean the SSPI context is not tied to the proxy to which the user believes they are authenticating. In the tested configuration, Qt generated NTLM Type 1 and Type 3 messages for the domain user, and the controlling proxy could relay them to another corporate service in real time.

The proxy forwards NTLM messages between Telegram Desktop and a corporate service, obtaining an authenticated session with the victim's privileges.
Step 7: Two-stage NTLM to Negotiate escalation (P1)
Even supplying an explicit proxy username and password did not protect the user. A controlled server could force two consecutive authentications over a single connection:
1. 407 + Proxy-Authenticate: NTLM │ └─► Qt uses the explicitly configured proxy credentials and produces NTLMv2 response no. 12. The proxy rejects the first authentication │ └─► qhttpsocketengine resets the authenticator; user becomes empty3. 407 + Proxy-Authenticate: Negotiate │ └─► qSspiStartup() requests the default SSPI credentials; Negotiate falls back to NTLM; Qt produces NTLMv2 response no. 2 for the Windows domain user
The attacker therefore received two different NTLMv2 responses in one session: the first based on the explicit proxy credentials, and the second based on the logged-on domain user's account. Both were under attacker control, and the domain user's response could be relayed immediately to a selected corporate service. This scenario significantly expanded the affected population: after rejecting the first authentication and forcing a second exchange through Negotiate, the proxy could reach system credentials even when the user had supplied separate proxy credentials.
Step 8: SOCKS5-in-tunnel vector (V3)
Vector V3 did not require the victim to follow a tg://proxy link. It affected domain-joined Windows systems where an enterprise proxy was deployed centrally through GPO, WPAD, or a PAC file. After a SOCKS5 tunnel had been established, the controlled proxy could see Telegram Desktop's unencrypted HTTP request, including its headers, URL, and MTProto POST body, and substitute the server response:
HTTP/1.1 407 Proxy Authentication RequiredProxy-Authenticate: NTLM
Qt interpreted the response as a normal proxy-authentication challenge and entered the SSPI path automatically.

A controlled SOCKS5 proxy injects 407 Proxy Authentication Required into an active tunnel, after which Qt automatically obtains an NTLMv2 response for the Windows domain user through SSPI.
In a laboratory environment using a domain-joined Windows 10 machine, a single Telegram Desktop session produced more than 230 NTLM Type 3 messages. Qt's repeated attempts multiplied the amount of authentication material available to the attacker and the number of relay opportunities.
Step 9: The same path without a proxy
The root cause was located in QtNetwork's shared HTTP authentication implementation, qauthenticator.cpp, and was not limited to 407 Proxy Authentication Required responses. If an attacker-controlled HTTP server answered an ordinary unencrypted request with 401 Unauthorized and the following header:
WWW-Authenticate: NTLM
Qt treated it as a routine authentication challenge. On a domain-joined Windows system with no explicit credentials supplied, the library called SSPI without user interaction and began an NTLM exchange on behalf of the current account. The proxy was therefore not a prerequisite for exploitation, but an especially dangerous entry point in Telegram Desktop.
Step 10: Heap memory disclosure in qExtractServerTime()
If an untrusted server could activate rarely used authentication code without user interaction and control the contents of NTLM Type 2, the remaining attacker-controlled fields also had to be audited. That work exposed a second independent primitive: reading uninitialized heap memory in qExtractServerTime():
static QByteArray qExtractServerTime(const QByteArray &targetInfoBuff){ QByteArray timeArray; QDataStream ds(targetInfoBuff); ds.setByteOrder(QDataStream::LittleEndian); quint16 avId, avLen; ds >> avId; ds >> avLen; while (avId != 0) { if (avId == AVTIMESTAMP) { timeArray.resize(avLen); ds.readRawData(timeArray.data(), avLen); } }}
In NTLM Type 2, the server controls targetInfo, including the MsvAvTimestamp identifier and the 16-bit avLen field. The team declared a length of 65,000 bytes but supplied only the eight-byte timestamp. Qt allocated the declared buffer, filled only the eight available bytes, and failed to check that readRawData() had performed a short read. The remaining 64,992 bytes retained prior heap contents. Qt then included the entire buffer, uninitialized area included, in the NTLMv2 response sent to the attacker's server.
An ordinary NTLM exchange thus became a remote, repeatable memory-read primitive. In captured dumps, the team confirmed disclosure of code pointers and heap metadata sufficient to bypass ASLR, network addresses, VPN client and adapter names, HTTP headers, and previous NTLM tokens. One hundred exchanges over approximately five minutes yielded about 6.5 MB of Telegram Desktop process memory.

Qt allocates 65,000 bytes from attacker-controlled avLen, writes only the eight-byte timestamp, and includes the remaining 64,992 bytes of heap memory in NTLM Type 3.
Step 11: What the leaked memory contained

Categories of data found in leaked memory during laboratory testing.
Individually, the fragments could look like random noise. Together, they formed a detailed profile of the device and its owner: username, work domain and hostname from NTLM, VPN software, virtualization, internal addressing, and enterprise network infrastructure. Through controlled heap grooming, the team placed test passwords and API-secret markers in reused buffers and later recovered them from the NTLMv2 response sent to the proxy. The same mechanism could disclose API keys, session tokens, cookies, Authorization headers, and other secrets recently present in process memory. Later disclosures also contained previously generated NTLM Type 3 messages. The domain user's password was not recovered directly from NTLM; cleartext passwords could leak as contents of a reused buffer, independently of the NTLM protocol itself.
The most troubling aspect was the channel: a feature intended to help users bypass restrictions and retain access to information. The proxy continued to function, Telegram displayed no warning, and the user could not see that a malicious proxy operator was receiving process-memory fragments, including passwords, API secrets, and data capable of identifying the user or granting access to connected systems.
Step 12: Full RCE chain in the laboratory
Once Telegram connected to the proxy, the chain executed automatically:

From adding a tg://proxy endpoint to obtaining SYSTEM on hosts where the compromised account held administrative privileges.
All nine AD CS relay attempts authenticated successfully and issued a certificate. Because the test account had Domain Admin privileges, the team obtained NT AUTHORITY\SYSTEM on both the workstation and the domain controller. The complete chain took approximately 30-35 seconds and required neither password guessing nor password recovery. Post-compromise access was determined by the victim account's privileges: an ordinary user did not automatically become a domain administrator. Relaying an administrator, privileged employee, or service account, however, could lead directly to remote code execution and compromise of the corresponding systems.
The issued certificate also created persistence. A password change did not revoke it automatically; with a one- or two-year certificate lifetime, an attacker could continue authenticating until expiration, explicit revocation, or account disablement.
Root cause
The defect lives in QtNetwork's shared HTTP authentication implementation, qauthenticator.cpp. Three independent problems combine:
- Unconditional NTLM/Negotiate activation. Qt selects the authentication scheme from proxy-controlled
Proxy-Authenticate(or server-controlledWWW-Authenticate) headers, resetsmethodbefore each response, and, on the first transition to NTLM or Negotiate, suppresses theproxyAuthenticationRequired()signal becausecredentialsWasSent == false. The application is never given the chance to approve or block the transition.qSspiStartup()then callsAcquireCredentialsHandle()withnullptrfor the identity, selecting the default outbound credentials of the current Windows logon session. - Missing relay defences.
InitializeSecurityContext()is called with onlyISC_REQ_ALLOCATE_MEMORY.ISC_REQ_INTEGRITYis not set, noSECBUFFER_CHANNEL_BINDINGSbuffer is supplied, andtargetNameWremains empty for direct NTLM. The SSPI context is therefore not bound to the intended proxy or service, which is exactly what NTLM Relay needs. - Unchecked short read in
qExtractServerTime(). The server-controlledMsvAvTimestamp.avLenis used to sizetimeArrayviatimeArray.resize(avLen), butreadRawData()is not checked for a short read. The uninitialized remainder of the buffer is then included in the NTLMv2 response.
Telegram Desktop made the defect practically reachable by accepting and persisting a user-supplied proxy, passing it to Qt without prohibiting NTLM and Negotiate, giving the user no opportunity to see or reject the proxy-selected scheme, allowing an untrusted proxy to activate SSPI and obtain an NTLMv2 response, and transmitting Telegram Desktop process-memory fragments through the same channel. Remove any key product element, tg://proxy, automatic proxy persistence, or the absence of an NTLM prohibition, and the Telegram path no longer works.
Impact
The scope was substantial: any corporate Windows system on which a user was logged in with a domain account could become a potential entry point. The practical result was an authenticated session on a relay-vulnerable target with the victim's permissions. Depending on the selected service and the victim's privileges, the consequences ranged from access to corporate data to remote code execution or compromise of domain infrastructure, all initiated by a single 407 Proxy Authentication Required response.
The memory disclosure added a second dimension: code pointers and heap metadata sufficient to bypass ASLR, network addresses, VPN client and adapter names, HTTP headers, previous NTLM tokens, and, through heap grooming, passwords and API secrets.
In the laboratory, all nine AD CS relay attempts authenticated successfully and issued a certificate. With a Domain Admin test account, the team obtained NT AUTHORITY\SYSTEM on both the workstation and the domain controller in approximately 30-35 seconds. An ordinary user did not automatically become a domain administrator; the impact depended on the privileges of the relayed account. The issued certificate also created persistence that survived a password change until expiration, explicit revocation, or account disablement.
Fix
On June 8, Telegram's dependency repository recorded two new commits, both authored by John Preston: a Qt 5 patch at 13:23:04 UTC and a Qt 6 patch at 13:27:01 UTC. The Qt 6 patch introduced a new file, qtbase_6.11.1/0038-disable-proxy-ntlm.patch, and addressed both independent issues: forced NTLM/Negotiate authentication through a proxy and the memory disclosure in qExtractServerTime().
The change added an avLen > end - p remaining-buffer check, required avLen == 8, returned and wrote exactly eight timestamp bytes, and introduced qNtlmBufferFits() for targetName and targetInfo bounds checks. It also covered both Qt network paths used by Telegram, QHttpNetworkConnection and QHttpSocketEngine. When NTLM or Negotiate was detected, the authenticator was reset, the connection ended with ProxyAuthenticationRequiredError, and no NTLMv2 response was sent to the proxy.
On June 16, Telegram stated that Telegram Desktop v6.9.2 contained fixes for all reported scenarios, with one exception: NTLM remained available to system-wide proxies. This exception matched the distinction introduced while the patch was revised on June 10-11: proxies from tg://proxy and application settings were blocked, while system proxies were allowed to use NTLM.
Upstream, Qt opened QTBUG-147373 on June 10, two days after Telegram's acknowledgement. The associated commit was 6e88e0f708. On June 12, Gerrit 744448 appeared: the same qExtractServerTime() function, the same MsvAvTimestamp.avLen field, an eight-byte timestamp requirement, and boundary-condition tests.
Variants to test
- Other Qt-based clients behind a hostile proxy. Point a Qt application at a controlled HTTP proxy that answers CONNECT with
407 Proxy Authentication RequiredandProxy-Authenticate: NTLM. A positive result is an NTLM Type 1 message from the client without any user prompt, followed by a Type 3 message containing the domain user's credentials. - Explicit proxy credentials followed by Negotiate. Configure the client with a proxy username and password, then have the proxy reject the first NTLM authentication and issue a second
407withProxy-Authenticate: Negotiate. A positive result is two different NTLMv2 responses in one session, the second for the logged-on domain account. - SOCKS5 tunnel injection. Establish a SOCKS5 tunnel and inject
HTTP/1.1 407 Proxy Authentication RequiredwithProxy-Authenticate: NTLMinto the active tunnel. A positive result is automatic entry into the SSPI path and an NTLMv2 response for the domain user. - Direct 401 without a proxy. Have an attacker-controlled HTTP server answer an ordinary unencrypted request with
401 UnauthorizedandWWW-Authenticate: NTLM. A positive result is an automatic NTLM Type 1 from a domain-joined Windows client with no explicit credentials. - Heap disclosure via
MsvAvTimestamp.avLen. In NTLM Type 2, declare a largeavLen(for example 65,000) while supplying only an eight-byte timestamp. A positive result is an NTLMv2 response whoseNtChallengeResponseis far larger than the timestamp and contains heap data such as pointers, headers, or previous tokens. - Rich-text image injection in QML applications. Inject
<img src="http://…">into a rendered rich-text field (for example a Bitcoin or LNURL invoice description) and answer the resulting request with401 WWW-Authenticate: NTLM. A positive result is an automatic NTLM Type 1 from an application with noauthenticationRequiredhandler capable of stopping the exchange. - AD CS relay to certificate issuance. Relay the captured NTLM exchange to AD CS Web Enrollment. A positive result is a successfully issued certificate, followed by PKINIT authentication and, where the relayed account holds administrative privileges,
NT AUTHORITY\SYSTEMon the target host.
Disclosure timeline
- June 6, 2026: Telegram receives the complete 21-page technical report EXPATCH-2026-TG-002, marked CONFIDENTIAL and supplied under Coordinated Responsible Disclosure. The PDF cover is dated June 5;
CreationDaterecords June 6, 2026 at 04:04:01 UTC. SHA-256:[redacted]. - June 7, 2026: Telegram receives an additional email with the 694-line
sspi_rce_v3.pyexploit and a video of the complete chain, pluspoc2.zip. - June 8, 2026, 05:08: Telegram Support acknowledges receipt: "The team is investigating your research, and we will contact you soon." At 13:23:04 and 13:27:01 UTC, the Qt 5 and Qt 6 patches appear in Telegram's dependency repository.
- June 10, 2026: Qt opens QTBUG-147373.
- June 12, 2026: Gerrit 744448 appears with the same
qExtractServerTime()fix. - June 15, 2026: Telegram offers a $1,000 bounty: "We would like to award you a bounty of $1000 for your findings regarding NTLM via proxy settings." ExPatch asks for the amount to be donated to charity and requests clarification on scope.
- June 16, 2026, 05:07: Telegram says the bounty decision is final and proposes an agreement effectively functioning as an NDA. At 05:56 ExPatch declines to sign and confirms a 90-day disclosure window. At 08:53 Telegram states: "Telegram Desktop v6.9.2 contains fixes for all reported scenarios, with one exception."

Page 5 of EXPATCH-2026-TG-002, identifying the vulnerable function, attacker-controlled avLen, disclosure of 64,992 heap bytes, and results reproduced against Telegram Desktop 6.8.2.

The beginning of ExPatch's original June 6 disclosure to Telegram.

Continuation of the June 6 email: delivered materials, mitigations Telegram could implement without waiting for upstream, researcher names, and the attached report.

Google Drive metadata dating the creation and last modification of the delivered poc.zip archive to June 6, 2026.


Additional June 7 disclosure: exploitation scenarios, the 694-line sspi_rce_v3.py, a video of the complete chain, and the attached poc2.zip.

Google Drive records the creation and last modification of poc2.zip on June 7, 2026.

Telegram's June 8 response confirming that the team was investigating the submitted research.

Correspondence between the June 6 ExPatch report and the June 8 Telegram patch: disabling NTLM/Negotiate for proxy authentication and correcting MsvAvTimestamp.avLen handling.

Telegram's June 15 offer, describing the bounty as covering findings related to NTLM through proxy settings.

ExPatch's June 15 reply: a request to donate the bounty and clarify which findings the decision covered.

Telegram's June 16 response: an agreement linking payment or donation processing to restricting vulnerability information to authorized parties.

ExPatch's June 16 email: refusal of the agreement, confirmation of the 90-day disclosure window, and a request for remediation status.

Telegram links version 6.9.2 to remediation of all submitted scenarios, with a specific exception for system-wide proxies.

ExPatch's report and the corresponding Telegram and Qt changes: June 6-12, 2026.

Closing note
The team's position is that public attribution is the professional result of forty days of work and the foundation of trust on which coordinated disclosure depends. Telegram used the head start to prepare fixes and users benefited, but when the corresponding Qt changes appeared, ExPatch was not informed of the coordination and neither the researchers nor ExPatch appeared in the public records reviewed. The team is publishing the original report, its SHA-256 and metadata, correspondence, laboratory results, vulnerable code, patches, and an exact timeline, and expects Telegram and Qt to explain how the results of the confidential research came to be reflected in the upstream fix and why their source remained unattributed.
Research and demonstrations: Alexander Rostilov and Denis Rostilov, ExPatch Vulnerability Research Team. Web version: https://expatch.com/writeups/telegram-ntlm-relay.html Full PDF report: https://expatch.com/writeups/expatch-telegram-ntlm-en.pdf Contact: [redacted] · https://expatch.com
What happened, in plain words
A small security research team, ExPatch, spent about a month looking at how Telegram Desktop handles proxy servers. A proxy is a middleman computer that sits between your app and the internet: instead of talking to the internet directly, the app sends everything to the proxy, and the proxy passes it on. People use proxies to get around blocks and censorship, so for many Telegram users a proxy is the difference between reading independent news and not reading it at all.
The team found that a malicious proxy could quietly make Telegram Desktop perform an NTLM login on the user's behalf, which could be relayed to another service, and could also make it leak chunks of its own memory. They reported it to Telegram privately, with a full technical report, a working proof of concept and a video. Telegram's dependency repository gained patches within days, and Telegram later said v6.9.2 contained fixes for all reported scenarios with one exception. Later, fixes for the same underlying code appeared in Qt, the software library Telegram Desktop uses for networking, and the researchers say they were never told about that coordination and were not credited in the public records they reviewed.
This article walks through the whole story for someone who has never done security work: what the pieces are, what the attack did, what the code does line by line, and what happened after the report was sent.
The cast of characters
Before the technical part, here is who and what is involved.
- Telegram Desktop is the Telegram messaging app for Windows, macOS and Linux computers. It is a normal program you install and log into.
- Qt (pronounced "cute") is a large collection of ready-made code that many desktop programs use so their authors do not have to write everything from scratch. Qt includes a networking part, QtNetwork, which knows how to speak HTTP (the language of the web) and how to talk to proxies. Telegram Desktop hands its proxy connections to Qt.
- A proxy server is the middleman described above. In this story the proxy is controlled by the attacker.
- NTLM is an old Microsoft login mechanism used mostly inside company networks (Windows domains). When you log into a company Windows PC, you get a kind of invisible pass that NTLM can present to other company services so you do not have to type your password again. That convenience is exactly what makes it interesting to attackers.
- NTLM Relay is a classic attack on NTLM. The attacker does not steal or crack your password. Instead, they stand in the middle and pass your login conversation along to a different service, in real time, so that service thinks you are the one logging in. It is like a courier who takes your signed letter of introduction, changes the address on the envelope, and delivers it to a different office that accepts it because the signature is genuine.
- SSPI is the Windows component that actually produces those NTLM messages on behalf of a program. A program asks SSPI "please log me in", and SSPI uses the credentials of whoever is currently logged into Windows.
- Heap memory is the general-purpose working memory a program uses for data it creates while running. When a program frees a chunk of memory and later reuses it, the old contents can still be sitting there until overwritten. Reading memory you were not supposed to read is called a memory disclosure or information leak.
- Remote code execution (RCE) means an attacker gets a program to run their own commands on the victim's machine. It is usually the worst outcome of a security bug.
- Active Directory (AD) is Microsoft's system for managing users, computers and permissions in a company network. AD CS (Active Directory Certificate Services) is the part that issues digital certificates, which are cryptographic ID cards used for logging in.
- A domain here means a Windows company network with a central server that manages logins, not a website address.
The setup: what was tested and how
The team also built a full attack chain in an isolated laboratory: a Windows Server 2022 machine acting as the company's central login server, plus an Enterprise Certificate Authority with AD CS Web Enrollment turned on. That last piece is a web page where a computer can request a certificate; it is a normal corporate feature, and it becomes dangerous when an attacker can make requests on someone else's behalf.
The only thing the user did was add a proxy through Telegram's own supported interface. Everything hostile lived on the attacker's proxy and in the lab.
To show the problem was not Telegram-specific, the team also tested other programs built on Qt:
| Application | Qt version | Result |
|---|---|---|
| qBittorrent 4.6.3 | Qt 6.4.2 | Controlled proxy switched Basic to NTLM via 407; 65,076-byte NtChallengeResponse, about 64,876 bytes of unrelated heap data |
| Nextcloud Desktop 3.11.0 | Qt 5.15.13 | Four consecutive NTLM exchanges in one session; each response 65,076 bytes, roughly 260 KB of memory in total |
| Electrum 4.7.2 | Qt 6.11.0 | Separate direct path with no proxy; automatic NTLM Type 1 from a 401 response |
In plain terms: qBittorrent (a torrent client), Nextcloud Desktop (a file-sync client) and Electrum (a Bitcoin wallet) all showed the same underlying weakness, because they all use the same Qt networking code. The numbers in the table are sizes of data the programs sent back to the attacker's server, far larger than they should have been.
Finding it: how the team got there
The investigation started with a simple question about a trust boundary. A trust boundary is a line in a system where data crosses from something you control into something you do not. When Telegram Desktop connects through a proxy, the proxy's replies are data from outside, and the app has to decide how much to believe them. The team asked: what happens if the proxy is hostile and controls those replies?
For almost a month they poked at this from different angles: how the connection moves from one state to another, and how to push the client into behaviour it did not intend. Most ideas led nowhere. The turning point was discovering that, in the middle of an ordinary proxy conversation, Qt would accept a demand to switch the login method to NTLM. A modern connection could silently drop into a legacy login scheme that has been known to be relayable for decades.
The basic chain is short:
- Telegram Desktop connects through the configured HTTP proxy, and Qt sends a
CONNECTrequest.CONNECTis the HTTP command that says "please open a tunnel to this destination for me". - The hostile proxy replies with
407 Proxy Authentication Requiredand a header sayingProxy-Authenticate: NTLM. A407is HTTP's way of saying "you need to log in to the proxy first". - Qt treats that as a normal login challenge, starts NTLM on its own, and sends the first NTLM handshake message, called NTLM Type 1 (Negotiate). The user is never asked for permission.
The key question was what checks Qt performed before letting NTLM use the user's Windows credentials. Since NTLM Relay has been understood for decades, the team expected some protection that tied the login to the intended proxy and stopped it being replayed elsewhere. There was none: Qt did not check an expected SPN (Service Principal Name, the name that identifies which service you are logging in to), did not bind the exchange to a protected channel using EPA (Extended Protection for Authentication, a feature that ties a login to the specific encrypted connection it happens on), and did not require MIC (Message Integrity Code, a check that the login messages were not altered). The attacker did not need to crack NTLM or recover a password; relaying the messages to another service in real time was enough.
Exploitation, step by step
The next sections follow the code path from the moment the 407 arrives to the moment Windows credentials are used. Each code block is copied from the report, and after each one there is a plain-language walkthrough.
Step 1: Qt accepts the 407 response
Telegram Desktop tells Qt which proxy to use through a function called QTcpSocket::setProxy. In a file called qhttpsocketengine.cpp, around lines 562 to 599, Qt handles the proxy's answer to the CONNECT request. A 407 status is passed into Qt's built-in login machinery:
} else if (statusCode == 407) { if (d->authenticator.isNull()) d->authenticator.detach(); priv = QAuthenticatorPrivate::getPrivate( d->authenticator ); const auto headers = d->reply->header(); priv->parseHttpResponse( headers, true, d->proxy.hostName() ); }
Line by line:
} else if (statusCode == 407) {checks whether the proxy's reply was a 407, meaning "authentication required".if (d->authenticator.isNull())checks whether there is no authenticator object yet, that is, whether this is the first time a login is being attempted.d->authenticator.detach();creates a real, separate authenticator object (in Qt,detachis how a shared object is made independent before it is modified).priv = QAuthenticatorPrivate::getPrivate(d->authenticator);reaches into the authenticator's internal private data, which is where the login state lives.const auto headers = d->reply->header();grabs all the headers from the proxy's reply. Headers are the labelled lines at the top of an HTTP message, likeContent-Type: text/html.priv->parseHttpResponse(headers, true, d->proxy.hostName());hands those headers to the parsing function. Thetruemeans "this is a proxy response", and the last argument is the proxy's hostname.
NTLM has not been chosen yet at this point. The important detail is that every header the proxy sent is passed to parseHttpResponse() with isProxy=true. That means the login method is chosen from content the attacker controls.
Step 2: Qt selects the authentication scheme
The switch to NTLM happens inside QAuthenticatorPrivate::parseHttpResponse() in qauthenticator.cpp, around lines 466 to 558. Because the function was called with isProxy=true, Qt looks at the proxy's Proxy-Authenticate header:
const auto search = isProxy ? QHttpHeaders::WellKnownHeader::ProxyAuthenticate : QHttpHeaders::WellKnownHeader::WWWAuthenticate;for (const auto ¤t : headers.values(search)) { if (method < Basic && str.startsWith("basic"_L1, Qt::CaseInsensitive)) { method = Basic; } else if (method < Ntlm && str.startsWith("ntlm"_L1, Qt::CaseInsensitive)) { method = Ntlm; headerVal = QByteArrayView(current).mid(5); } else if (method < DigestMd5 && str.startsWith("digest"_L1, Qt::CaseInsensitive)) { } else if (method < Negotiate && str.startsWith("negotiate"_L1, Qt::CaseInsensitive)) { }}case Ntlm:case Negotiate: break;
Line by line:
const auto search = isProxy ? ...ProxyAuthenticate : ...WWWAuthenticate;picks which header to read. For a proxy it isProxy-Authenticate; for a normal web server it isWWW-Authenticate. This one line is why the same bug also works without a proxy.for (const auto ¤t : headers.values(search)) {loops over every value of that header. A server can send several, and each is examined.if (method < Basic && str.startsWith("basic"_L1, Qt::CaseInsensitive))checks whether the header starts with the word "basic" (case-insensitive) and whether Basic is a "better" method than whatever was chosen so far. Themethod < Basiccomparison is an ordering trick: Qt keeps the strongest scheme it has seen.method = Basic;records Basic as the chosen scheme.} else if (method < Ntlm && str.startsWith("ntlm"_L1, Qt::CaseInsensitive)) {does the same for NTLM.method = Ntlm;records NTLM as the chosen scheme.headerVal = QByteArrayView(current).mid(5);stores the rest of the header value after the first five characters (the word "NTLM" plus a space), which is where the server's challenge data would be.- The
digestandnegotiatebranches do the same for those schemes. case Ntlm: case Negotiate: break;is a switch statement that simply stops for these two schemes, meaning no further checks are done here.
There is an extra problem: method is reset before each new response is parsed. So a proxy can demand NTLM not only in the first reply but in a later 407, changing the scheme while the connection is already being set up. Once NTLM is selected, this function does no further trust checks; producing the actual login response is left to a function called calculateResponse().
Step 3: Qt starts NTLM without notifying the application
After the scheme is chosen, execution goes back to qhttpsocketengine.cpp, around lines 574 to 599:
if (priv->phase == QAuthenticatorPrivate::Done || (priv->phase == QAuthenticatorPrivate::Start && (priv->method == QAuthenticatorPrivate::Ntlm || priv->method == QAuthenticatorPrivate::Negotiate))) { if (priv->phase == QAuthenticatorPrivate::Start) priv->phase = QAuthenticatorPrivate::Phase1; if ((priv->method != QAuthenticatorPrivate::Ntlm && priv->method != QAuthenticatorPrivate::Negotiate) || credentialsWasSent) { proxyAuthenticationRequired( d->proxy, &d->authenticator ); }}
Line by line:
if (priv->phase == ...Done || (priv->phase == ...Start && (priv->method == ...Ntlm || priv->method == ...Negotiate))) {checks whether the authenticator is finished, or is just starting with NTLM or Negotiate.phaseis a state marker: the authenticator moves through stages as the login proceeds.if (priv->phase == ...Start) priv->phase = ...Phase1;moves the state from "Start" to "Phase1", the first handshake step.if ((priv->method != ...Ntlm && priv->method != ...Negotiate) || credentialsWasSent) {is the decisive condition. It says: notify the application only if the method is something other than NTLM or Negotiate, or if credentials have already been sent.proxyAuthenticationRequired(d->proxy, &d->authenticator);is the signal that tells the application "the proxy wants a login, please supply credentials or refuse".
With an ordinary scheme, Qt emits that signal so the application can ask the user for a password or say no. But on the first switch to NTLM or Negotiate, credentialsWasSent is false, so the whole condition is false and no signal is emitted. Telegram Desktop never gets the chance to approve, warn about or block the transition. Qt moves the authenticator to Phase1, calls calculateResponse(), asks Windows SSPI for the system's single-sign-on credentials, and sends an NTLM Type 1 (Negotiate) message to the proxy. The transition is silent to the user and to the application itself.
Why does this allow NTLM Relay? The problem is not SSPI itself but the way Qt calls it during automatic proxy login. If the authenticator has no username, Qt does not stop and does not ask the application for credentials. It calls Windows SSPI and gets the default credentials of the current Windows login session. On a company laptop joined to a domain, a hostile proxy can therefore start an NTLM exchange on behalf of the user's corporate account without the user knowing.
Step 4: calculateResponse() selects system authentication
The first confirmation is in qauthenticator.cpp, around lines 585 to 592. When the proxy asks for NTLM and no challenge has been received yet, Qt begins the first handshake phase:
case QAuthenticatorPrivate::Ntlm: if (challenge.isEmpty()) {#if QT_CONFIG(sspi) QByteArray phase1Token; if (user.isEmpty()) { phase1Token = qSspiStartup( this, method, host ); } #endif } break;
Line by line:
case QAuthenticatorPrivate::Ntlm:handles the case where the chosen method is NTLM.if (challenge.isEmpty()) {checks whether the server has not yet sent its challenge. In NTLM, the server sends a challenge (Type 2) and the client answers it (Type 3); this is the very beginning, before any challenge.#if QT_CONFIG(sspi)is a compile-time switch: the following code is only included if Qt was built with SSPI support, which it is on Windows.QByteArray phase1Token;declares a variable to hold the first handshake message.if (user.isEmpty()) {checks whether no username was configured for this proxy.phase1Token = qSspiStartup(this, method, host);calls the function that starts SSPI, passing the authenticator, the method and the host.#endifcloses the conditional block, andbreak;ends the case.
The Qt comment in the source is explicit: "Only pull from system if no user was specified in authenticator." This is the exact point where a proxy's demand for NTLM gets connected to the current Windows account.
Step 5: System credentials in qSspiStartup()
SEC_WINNT_AUTH_IDENTITY auth;auth.Flags = SEC_WINNT_AUTH_IDENTITY_UNICODE;bool useAuth = false;if (method == QAuthenticatorPrivate::Negotiate && !ctx->user.isEmpty()) { useAuth = true;}SECURITY_STATUS secStatus = pSecurityFunctionTable->AcquireCredentialsHandle( nullptr, L"NTLM", SECPKG_CRED_OUTBOUND, nullptr, useAuth ? &auth : nullptr, nullptr, nullptr, &ctx->sspiWindowsHandles->credHandle, &expiry );
Line by line:
SEC_WINNT_AUTH_IDENTITY auth;declares a structure that can hold an explicit username, domain and password.auth.Flags = SEC_WINNT_AUTH_IDENTITY_UNICODE;says the text inside it is Unicode.bool useAuth = false;starts with "do not use explicit credentials".if (method == ...Negotiate && !ctx->user.isEmpty()) { useAuth = true; }setsuseAuthto true only for Negotiate and only when a username was supplied.pSecurityFunctionTable->AcquireCredentialsHandle(nullptr, L"NTLM", SECPKG_CRED_OUTBOUND, nullptr, useAuth ? &auth : nullptr, ...)asks Windows for a credential handle. The firstnullptrmeans "use the current process's identity".L"NTLM"names the package.SECPKG_CRED_OUTBOUNDmeans credentials for making outgoing logins. The fifth argument is either the explicit identity ornullptr.
In the NTLM path, Qt passes nullptr instead of an identity structure. Under the SSPI model, that selects the default outgoing credentials of the current Windows security context, typically the logged-on corporate account on a domain machine. Qt never sees the password or the NTLM hash in cleartext; SSPI gives back an opaque handle and produces the NTLM messages from it. That distinction matters: the attacker is not stealing a password, they are relaying the login exchange.
Step 6: The NTLM context is not bound to the intended proxy
The credential handle is passed to qSspiContinue(), where Qt continues the handshake through Windows SSPI:
InitializeSecurityContext( &ctx->sspiWindowsHandles->credHandle, ..., ISC_REQ_ALLOCATE_MEMORY, ...);
Line by line:
InitializeSecurityContext(is the Windows function that produces the next NTLM message in the handshake.&ctx->sspiWindowsHandles->credHandle,passes the credential handle obtained in the previous step....,stands for arguments the report does not show.ISC_REQ_ALLOCATE_MEMORY,is the only option Qt asks for: let Windows allocate memory for the output message....);stands for the remaining arguments.
Qt asks only for automatic memory allocation. Three protections that could have made relaying much harder are missing:
ISC_REQ_INTEGRITYis not set, so Qt does not require the login context to be integrity-protected.- No
SECBUFFER_CHANNEL_BINDINGSbuffer is supplied, so EPA/Channel Binding does not tie the NTLM exchange to a protected channel. Channel binding is like stapling the login to the exact encrypted pipe it travels through, so it cannot be reused on another pipe. - For direct NTLM,
targetNameWstays empty, so no SPN ties the context to the intended service.
Together, these omissions mean the SSPI context is not tied to the proxy the user thinks they are logging in to. In the tested setup, Qt produced NTLM Type 1 and Type 3 messages for the domain user, and the controlling proxy could relay them to another corporate service in real time.

The diagram shows the relay: the proxy forwards NTLM messages between Telegram Desktop and a corporate service, and ends up with an authenticated session carrying the victim's privileges.
Step 7: Two-stage NTLM to Negotiate escalation (P1)
Even typing an explicit proxy username and password did not protect the user. A controlled server could force two logins in a row over a single connection:
1. 407 + Proxy-Authenticate: NTLM │ └─► Qt uses the explicitly configured proxy credentials and produces NTLMv2 response no. 12. The proxy rejects the first authentication │ └─► qhttpsocketengine resets the authenticator; user becomes empty3. 407 + Proxy-Authenticate: Negotiate │ └─► qSspiStartup() requests the default SSPI credentials; Negotiate falls back to NTLM; Qt produces NTLMv2 response no. 2 for the Windows domain user
Line by line:
1. 407 + Proxy-Authenticate: NTLMis the first reply: the proxy asks for a login and names NTLM.Qt uses the explicitly configured proxy credentials and produces NTLMv2 response no. 1means Qt answers using the username and password the user typed into Telegram's proxy settings. An NTLMv2 response is the client's answer to the server's challenge, derived from the password without sending it.2. The proxy rejects the first authenticationmeans the proxy says "no, try again".qhttpsocketengine resets the authenticator; user becomes emptymeans Qt wipes the login state, including the username the user configured.3. 407 + Proxy-Authenticate: Negotiateis the second reply: the proxy asks again, this time naming Negotiate. Negotiate is a wrapper that lets the two sides pick a scheme, and on Windows it commonly ends up using NTLM.qSspiStartup() requests the default SSPI credentials; Negotiate falls back to NTLM; Qt produces NTLMv2 response no. 2 for the Windows domain usermeans Qt now asks Windows for the logged-on user's credentials and sends a second NTLMv2 response, this time for the corporate account.
The attacker therefore got two different NTLMv2 responses in one session: the first based on the explicit proxy credentials, the second based on the logged-on domain account. Both were under the attacker's control, and the second could be relayed straight to a chosen corporate service. This widened the affected population a lot: after rejecting the first login and forcing a second through Negotiate, the proxy could reach system credentials even when the user had supplied separate proxy credentials.
Step 8: SOCKS5-in-tunnel vector (V3)
This variant did not need the victim to click a tg://proxy link. It affected domain-joined Windows machines where a company proxy is deployed centrally through GPO (Group Policy, a way for a company to push settings to many computers), WPAD (Web Proxy Auto-Discovery, a way for machines to find the proxy automatically) or a PAC file (a small script that tells the browser or app which proxy to use for which address).
The difference from the basic attack is where the fake reply is injected. After a SOCKS5 tunnel was established (SOCKS5 is another proxy protocol, often used for tunnelling traffic), the controlled proxy could see Telegram Desktop's unencrypted HTTP request, including its headers, URL and MTProto POST body (MTProto is Telegram's own messaging protocol), and swap the server's response for its own:
HTTP/1.1 407 Proxy Authentication RequiredProxy-Authenticate: NTLM
Line by line:
HTTP/1.1 407 Proxy Authentication Requiredis the status line: HTTP version 1.1, status code 407, and the reason phrase. It tells the client the proxy wants a login.Proxy-Authenticate: NTLMis the header naming the login scheme the proxy wants to use.
Qt read this as a normal proxy login challenge and entered the SSPI path automatically.

The diagram shows the SOCKS5 proxy injecting the 407 into an active tunnel, after which Qt automatically obtains an NTLMv2 response for the Windows domain user through SSPI.
In a lab with a domain-joined Windows 10 machine, a single Telegram Desktop session produced more than 230 NTLM Type 3 messages. Qt's repeated attempts multiplied both the amount of login material available to the attacker and the number of chances to relay it.
Step 9: The same path without a proxy
The root cause was in QtNetwork's shared HTTP login code, qauthenticator.cpp, and was not limited to 407 Proxy Authentication Required replies. If an attacker-controlled web server answered an ordinary unencrypted request with 401 Unauthorized and this header:
WWW-Authenticate: NTLM
Line by line:
WWW-Authenticate: NTLMis the header a normal web server uses to ask the client to log in. It names NTLM as the scheme.
Qt treated it as a routine login challenge. On a domain-joined Windows machine with no explicit credentials supplied, the library called SSPI without any user interaction and started an NTLM exchange on behalf of the current account. The proxy was therefore not required for exploitation, but it was an especially dangerous entry point in Telegram Desktop.
Step 10: Heap memory disclosure in qExtractServerTime()
If an untrusted server could trigger rarely used login code without user interaction and control the contents of NTLM Type 2, then the other fields the attacker controls also needed auditing. That work turned up a second, independent problem: reading uninitialised heap memory in a function called qExtractServerTime():
static QByteArray qExtractServerTime(const QByteArray &targetInfoBuff){ QByteArray timeArray; QDataStream ds(targetInfoBuff); ds.setByteOrder(QDataStream::LittleEndian); quint16 avId, avLen; ds >> avId; ds >> avLen; while (avId != 0) { if (avId == AVTIMESTAMP) { timeArray.resize(avLen); ds.readRawData(timeArray.data(), avLen); } }}
Line by line:
static QByteArray qExtractServerTime(const QByteArray &targetInfoBuff)declares a function that takes a block of bytes calledtargetInfoBuffand returns a block of bytes. In NTLM Type 2, the server sends thistargetInfodata, so the attacker controls it.QByteArray timeArray;creates an empty byte array to hold the result.QDataStream ds(targetInfoBuff);wraps the input in a stream object that can read structured values from it.ds.setByteOrder(QDataStream::LittleEndian);sets the byte order. Little-endian means the least significant byte comes first; it is a convention for how multi-byte numbers are stored.quint16 avId, avLen;declares two 16-bit unsigned integers: an identifier and a length.ds >> avId;reads the identifier from the stream.ds >> avLen;reads the length from the stream.while (avId != 0) {loops through the list of fields until it hits the identifier 0, which marks the end.if (avId == AVTIMESTAMP) {checks whether this field is the timestamp field,MsvAvTimestamp.timeArray.resize(avLen);makes the output array exactlyavLenbytes long, using the length the server supplied.ds.readRawData(timeArray.data(), avLen);tries to readavLenbytes from the stream into that array.- The closing braces end the loop and the function.
In NTLM Type 2, the server controls targetInfo, including the MsvAvTimestamp identifier and the 16-bit avLen field. The team declared a length of 65,000 bytes but supplied only the eight-byte timestamp. Qt allocated the declared buffer, filled only the eight bytes that were actually available, and never checked that readRawData() had performed a short read. The remaining 64,992 bytes kept whatever was already in that heap memory. Qt then put the whole buffer, uninitialised part included, into the NTLMv2 response sent to the attacker's server.
An ordinary NTLM exchange thus became a remote, repeatable memory-read primitive. In captured dumps the team confirmed disclosure of code pointers and heap metadata sufficient to bypass ASLR (Address Space Layout Randomisation, a defence that randomises where code sits in memory so attackers cannot jump to it reliably), network addresses, VPN client and adapter names, HTTP headers, and previous NTLM tokens. One hundred exchanges over about five minutes yielded roughly 6.5 MB of Telegram Desktop process memory.

The diagram shows the leak mechanism: Qt allocates 65,000 bytes from the attacker-controlled avLen, writes only the eight-byte timestamp, and includes the remaining 64,992 bytes of heap memory in NTLM Type 3.
Step 11: What the leaked memory contained

The chart lists the categories of data found in leaked memory during laboratory testing.
On their own, the fragments could look like random noise. Together they formed a detailed profile of the device and its owner: username, work domain and hostname from NTLM, VPN software, virtualisation, internal addressing, and enterprise network infrastructure. Through controlled heap grooming (deliberately arranging what data sits in memory so it lands in the reused buffer), the team placed test passwords and API-secret markers in those buffers and later recovered them from the NTLMv2 response sent to the proxy. The same mechanism could disclose API keys (long secret strings that let a program talk to a service on your behalf), session tokens (short-lived strings that prove you are logged in), cookies (small pieces of data a browser or app stores to remember you), Authorization headers, and other secrets recently present in process memory. Later disclosures also contained previously generated NTLM Type 3 messages.
The domain user's password was not recovered directly from NTLM. Cleartext passwords could leak as contents of a reused buffer, independently of the NTLM protocol itself.
The most troubling part was the channel: a feature meant to help users get around restrictions and keep access to information. The proxy kept working, Telegram showed no warning, and the user could not see that a malicious proxy operator was receiving fragments of process memory, including passwords, API secrets, and data that could identify the user or grant access to connected systems.
Step 12: Full RCE chain in the laboratory
To find the maximum practical impact, the team built an isolated Active Directory lab with Windows Server 2022 and an Enterprise CA with AD CS Web Enrollment enabled. The victim ran the official Telegram Desktop 6.8.2, unmodified. The user's only action was adding a proxy through Telegram's supported interface; every offensive component stayed on the controlled proxy and the lab.
Once Telegram connected to the proxy, the chain ran automatically:

The diagram shows the complete laboratory chain, from adding a tg://proxy endpoint to obtaining SYSTEM on hosts where the compromised account held administrative privileges.
All nine AD CS relay attempts authenticated successfully and issued a certificate. Because the test account had Domain Admin privileges, the team obtained NT AUTHORITY\SYSTEM on both the workstation and the domain controller. NT AUTHORITY\SYSTEM is the highest local account on Windows, more powerful than any normal administrator. The whole chain took about 30 to 35 seconds and needed neither password guessing nor password recovery.
What an attacker gets after the relay depends on the victim account's privileges: an ordinary user does not automatically become a domain administrator. Relaying an administrator, a privileged employee or a service account, however, could lead directly to remote code execution and compromise of the corresponding systems.
The issued certificate also created persistence, meaning a way to keep access after the initial attack. A password change did not revoke it automatically; with a one- or two-year certificate lifetime, an attacker could keep authenticating until the certificate expired, was explicitly revoked, or the account was disabled.
Root cause
The defect lives in QtNetwork's shared HTTP login code, qauthenticator.cpp. Two independent problems combine:
- Unconditional NTLM/Negotiate activation. Qt picks the login scheme from proxy-controlled
Proxy-Authenticate(or server-controlledWWW-Authenticate) headers, resetsmethodbefore each response, and on the first switch to NTLM or Negotiate suppresses theproxyAuthenticationRequired()signal becausecredentialsWasSent == false. The application never gets the chance to approve or block it.qSspiStartup()then callsAcquireCredentialsHandle()withnullptrfor the identity, selecting the default outgoing credentials of the current Windows login session. - Missing relay defences.
InitializeSecurityContext()is called with onlyISC_REQ_ALLOCATE_MEMORY.ISC_REQ_INTEGRITYis not set, noSECBUFFER_CHANNEL_BINDINGSbuffer is supplied, andtargetNameWstays empty for direct NTLM. The SSPI context is therefore not bound to the intended proxy or service, which is exactly what NTLM Relay needs. - Unchecked short read in
qExtractServerTime(). The server-controlledMsvAvTimestamp.avLenis used to sizetimeArrayviatimeArray.resize(avLen), butreadRawData()is not checked for a short read. The uninitialised remainder of the buffer is then included in the NTLMv2 response.
Telegram Desktop made the defect practically reachable by accepting and saving a user-supplied proxy, passing it to Qt without forbidding NTLM and Negotiate, giving the user no chance to see or reject the proxy-selected scheme, letting an untrusted proxy activate SSPI and obtain an NTLMv2 response, and sending Telegram Desktop process-memory fragments through the same channel. Remove any key product element, tg://proxy, automatic proxy persistence, or the absence of an NTLM prohibition, and the Telegram path no longer works.
Impact
The scope was substantial: any corporate Windows machine where a user was logged in with a domain account could become a potential entry point. The practical result was an authenticated session on a relay-vulnerable target with the victim's permissions. Depending on the chosen service and the victim's privileges, the consequences ranged from access to corporate data to remote code execution or compromise of domain infrastructure, all started by a single 407 Proxy Authentication Required response.
The memory disclosure added a second dimension: code pointers and heap metadata sufficient to bypass ASLR, network addresses, VPN client and adapter names, HTTP headers, previous NTLM tokens, and, through heap grooming, passwords and API secrets.
In the lab, all nine AD CS relay attempts authenticated successfully and issued a certificate. With a Domain Admin test account, the team obtained NT AUTHORITY\SYSTEM on both the workstation and the domain controller in about 30 to 35 seconds. An ordinary user did not automatically become a domain administrator; the impact depended on the privileges of the relayed account. The issued certificate also created persistence that survived a password change until expiration, explicit revocation, or account disablement.
Fix
On June 8, Telegram's dependency repository recorded two new commits, both authored by John Preston: a Qt 5 patch at 13:23:04 UTC and a Qt 6 patch at 13:27:01 UTC. A commit is a saved change in a code repository, with a timestamp and an author. The Qt 6 patch introduced a new file, qtbase_6.11.1/0038-disable-proxy-ntlm.patch, and addressed both independent issues: forced NTLM/Negotiate login through a proxy and the memory disclosure in qExtractServerTime().
The change added an avLen > end - p remaining-buffer check, required avLen == 8, returned and wrote exactly eight timestamp bytes, and introduced qNtlmBufferFits() for targetName and targetInfo bounds checks. In plain words: before trusting the length the server sent, the code now checks that the length fits in what is actually left in the buffer, and insists the timestamp is exactly eight bytes. It also covered both Qt network paths used by Telegram, QHttpNetworkConnection and QHttpSocketEngine. When NTLM or Negotiate was detected, the authenticator was reset, the connection ended with ProxyAuthenticationRequiredError, and no NTLMv2 response was sent to the proxy.
On June 16, Telegram stated that Telegram Desktop v6.9.2 contained fixes for all reported scenarios, with one exception: NTLM remained available to system-wide proxies. This exception matched the distinction introduced while the patch was revised on June 10 and 11: proxies from tg://proxy and application settings were blocked, while system proxies were allowed to use NTLM.
Upstream, Qt opened QTBUG-147373 on June 10, two days after Telegram's acknowledgement. The associated commit was 6e88e0f708. On June 12, Gerrit 744448 appeared: the same qExtractServerTime() function, the same MsvAvTimestamp.avLen field, an eight-byte timestamp requirement, and boundary-condition tests. Gerrit is a web tool for reviewing code changes before they are merged. By the time the team downloaded the Qt 6.11.2 branch, the vulnerable paths had already been closed.
Variants to test
These are the checks the team describes for anyone wanting to look for the same weakness elsewhere. Each one says what a positive result looks like.
- Other Qt-based clients behind a hostile proxy. Point a Qt application at a controlled HTTP proxy that answers
CONNECTwith407 Proxy Authentication RequiredandProxy-Authenticate: NTLM. A positive result is an NTLM Type 1 message from the client without any user prompt, followed by a Type 3 message containing the domain user's credentials. - Explicit proxy credentials followed by Negotiate. Configure the client with a proxy username and password, then have the proxy reject the first NTLM login and issue a second
407withProxy-Authenticate: Negotiate. A positive result is two different NTLMv2 responses in one session, the second for the logged-on domain account. - SOCKS5 tunnel injection. Establish a SOCKS5 tunnel and inject
HTTP/1.1 407 Proxy Authentication RequiredwithProxy-Authenticate: NTLMinto the active tunnel. A positive result is automatic entry into the SSPI path and an NTLMv2 response for the domain user. - Direct 401 without a proxy. Have an attacker-controlled HTTP server answer an ordinary unencrypted request with
401 UnauthorizedandWWW-Authenticate: NTLM. A positive result is an automatic NTLM Type 1 from a domain-joined Windows client with no explicit credentials. - Heap disclosure via
MsvAvTimestamp.avLen. In NTLM Type 2, declare a largeavLen(for example 65,000) while supplying only an eight-byte timestamp. A positive result is an NTLMv2 response whoseNtChallengeResponseis far larger than the timestamp and contains heap data such as pointers, headers, or previous tokens. - Rich-text image injection in QML applications. Inject
<img src="http://…">into a rendered rich-text field (for example a Bitcoin or LNURL invoice description) and answer the resulting request with401 WWW-Authenticate: NTLM. QML is Qt's language for building user interfaces, and rich text is text that can contain formatting and images. A positive result is an automatic NTLM Type 1 from an application with noauthenticationRequiredhandler capable of stopping the exchange. - AD CS relay to certificate issuance. Relay the captured NTLM exchange to AD CS Web Enrollment. A positive result is a successfully issued certificate, followed by PKINIT authentication (logging in with a certificate instead of a password) and, where the relayed account holds administrative privileges,
NT AUTHORITY\SYSTEMon the target host.
Disclosure timeline
A disclosure is the process of telling a vendor about a security problem. Coordinated disclosure means the researcher and the vendor agree on when details become public, usually after a fix. A bounty is a payment some companies offer for useful reports.
- June 6, 2026: Telegram receives the complete 21-page technical report EXPATCH-2026-TG-002, marked CONFIDENTIAL and supplied under Coordinated Responsible Disclosure. The PDF cover is dated June 5;
CreationDaterecords June 6, 2026 at 04:04:01 UTC. SHA-256:[redacted]. A SHA-256 is a fingerprint of a file: if the file changes by even one byte, the fingerprint changes too. - June 7, 2026: Telegram receives an additional email with the 694-line
sspi_rce_v3.pyexploit and a video of the complete chain, pluspoc2.zip. A PoC (proof of concept) is a working demonstration that the problem is real. - June 8, 2026, 05:08: Telegram Support acknowledges receipt: "The team is investigating your research, and we will contact you soon." At 13:23:04 and 13:27:01 UTC, the Qt 5 and Qt 6 patches appear in Telegram's dependency repository.
- June 10, 2026: Qt opens QTBUG-147373.
- June 12, 2026: Gerrit 744448 appears with the same
qExtractServerTime()fix. - June 15, 2026: Telegram offers a $1,000 bounty: "We would like to award you a bounty of $1000 for your findings regarding NTLM via proxy settings." ExPatch asks for the amount to be donated to charity and requests clarification on scope.
- June 16, 2026, 05:07: Telegram says the bounty decision is final and proposes an agreement effectively functioning as an NDA. An NDA (non-disclosure agreement) is a contract promising to keep information secret. At 05:56 ExPatch declines to sign and confirms a 90-day disclosure window. At 08:53 Telegram states: "Telegram Desktop v6.9.2 contains fixes for all reported scenarios, with one exception."

Page 5 of EXPATCH-2026-TG-002, identifying the vulnerable function, attacker-controlled avLen, disclosure of 64,992 heap bytes, and results reproduced against Telegram Desktop 6.8.2.

The beginning of ExPatch's original June 6 disclosure to Telegram.

Continuation of the June 6 email: delivered materials, mitigations Telegram could implement without waiting for upstream, researcher names, and the attached report.

Google Drive metadata dating the creation and last modification of the delivered poc.zip archive to June 6, 2026.


Additional June 7 disclosure: exploitation scenarios, the 694-line sspi_rce_v3.py, a video of the complete chain, and the attached poc2.zip.

Google Drive records the creation and last modification of poc2.zip on June 7, 2026.

Telegram's June 8 response confirming that the team was investigating the submitted research.

Correspondence between the June 6 ExPatch report and the June 8 Telegram patch: disabling NTLM/Negotiate for proxy authentication and correcting MsvAvTimestamp.avLen handling.

Telegram's June 15 offer, describing the bounty as covering findings related to NTLM through proxy settings.

ExPatch's June 15 reply: a request to donate the bounty and clarify which findings the decision covered.

Telegram's June 16 response: an agreement linking payment or donation processing to restricting vulnerability information to authorized parties.

ExPatch's June 16 email: refusal of the agreement, confirmation of the 90-day disclosure window, and a request for remediation status.

Telegram links version 6.9.2 to remediation of all submitted scenarios, with a specific exception for system-wide proxies.

ExPatch's report and the corresponding Telegram and Qt changes: June 6 to 12, 2026.

Closing note
The team's position is that public attribution is the professional result of forty days of work and the foundation of trust on which coordinated disclosure depends. Telegram used the head start to prepare fixes and users benefited, but when the corresponding Qt changes appeared, ExPatch was not informed of the coordination and neither the researchers nor ExPatch appeared in the public records reviewed. The team is publishing the original report, its SHA-256 and metadata, correspondence, laboratory results, vulnerable code, patches, and an exact timeline, and expects Telegram and Qt to explain how the results of the confidential research came to be reflected in the upstream fix and why their source remained unattributed.
Research and demonstrations: Alexander Rostilov and Denis Rostilov, ExPatch Vulnerability Research Team. Web version: https://expatch.com/writeups/telegram-ntlm-relay.html Full PDF report: https://expatch.com/writeups/expatch-telegram-ntlm-en.pdf Contact: [redacted] · https://expatch.com
Glossary
- AD CS (Active Directory Certificate Services): Microsoft's system for issuing digital certificates inside a company network.
- API: a defined way for one program to talk to another; an API key is a secret string that identifies the caller.
- API key: a long secret string that lets a program use a service on your behalf.
- ASLR (Address Space Layout Randomisation): a defence that places code and data at random memory addresses so attackers cannot reliably jump to them.
- Active Directory: Microsoft's system for managing users, computers and permissions in a company network.
- Authentication: proving who you are, usually with a password, certificate or token.
- Authorization header: an HTTP header that carries proof of login, such as a token, with a request.
- Bounty: a payment a company offers for a useful security report.
- CONNECT: the HTTP command that asks a proxy to open a tunnel to a destination.
- Channel binding (EPA): a protection that ties a login to the specific encrypted connection it happens on, so it cannot be reused elsewhere.
- Commit: a saved change in a code repository, with an author and a timestamp.
- Cookie: a small piece of data a browser or app stores to remember you between requests.
- Coordinated disclosure: an arrangement where a researcher and a vendor agree when details of a bug become public, usually after a fix.
- Credentials: the data that proves your identity, such as a username and password, or a token derived from them.
- Domain (Windows): a company network with a central server that manages logins and permissions.
- EPA (Extended Protection for Authentication): see channel binding.
- Exploit: code or steps that turn a weakness into a working attack.
- GPO (Group Policy Object): a way for a company to push settings to many Windows computers at once.
- Gerrit: a web tool for reviewing code changes before they are merged.
- Heap: the general-purpose working memory a program uses for data it creates while running.
- Heap grooming: deliberately arranging what data sits in memory so that chosen data lands in a reused buffer.
- Header: a labelled line at the top of an HTTP message, such as
Content-Type: text/html. - HTTP: the language web browsers and apps use to request and receive pages and data.
- Information leak / memory disclosure: a bug that lets someone read data they should not see, often leftover memory contents.
- Little-endian: a convention where the least significant byte of a number is stored first.
- MIC (Message Integrity Code): a check that login messages were not altered in transit.
- MTProto: Telegram's own protocol for sending messages.
- NDA (non-disclosure agreement): a contract promising to keep information secret.
- NTLM: an old Microsoft login mechanism used mostly inside company networks.
- NTLM Relay: an attack that passes a victim's NTLM login messages to a different service in real time, without cracking the password.
- NTLM Type 1 / Type 2 / Type 3: the three messages of an NTLM handshake: the client's opening request, the server's challenge, and the client's answer.
- NTLMv2 response: the client's answer to an NTLM challenge, derived from the password without sending it.
- PAC file: a small script that tells a browser or app which proxy to use for which address.
- PKINIT: logging in with a certificate instead of a password.
- PoC (proof of concept): a working demonstration that a problem is real.
- Persistence: a way for an attacker to keep access after the initial attack.
- Proxy: a middleman computer that passes traffic between an app and the internet.
- QML: Qt's language for building user interfaces.
- Qt / QtNetwork: a large collection of ready-made code used by many desktop programs; QtNetwork is its networking part.
- RCE (remote code execution): getting a program to run an attacker's commands on the victim's machine.
- Rich text: text that can contain formatting and images.
- SPN (Service Principal Name): the name that identifies which service a login is meant for.
- SSPI: the Windows component that produces NTLM login messages on behalf of a program.
- SOCKS5: a proxy protocol often used for tunnelling traffic.
- Session token: a short-lived string that proves you are logged in.
- SHA-256: a fingerprint of a file; any change to the file changes the fingerprint.
- Trust boundary: a line in a system where data crosses from something you control into something you do not.
- WPAD (Web Proxy Auto-Discovery): a way for machines to find the proxy automatically.
NT AUTHORITY\SYSTEM: the highest local account on Windows, more powerful than a normal administrator.