Skip to content
RCE Write-up Advanced

Windows Telemetry service elevation of privilege

The Windows Connected User Experiences and Telemetry service (DiagTrack) allowed any user to start a custom trace with a user-controlled XML profile, leading to arbitrary file overwrite and creation in SYSTEM-writable locations. By combining this with a snapshot trace and a race condition, an attacker could place a malicious DLL in System32 and have it loaded by Windows Error Reporting, achieving code execution as SYSTEM.

secret.club

Published on secret.club

Today, we will be looking at the “Connected User Experiences and Telemetry service,” also known as “diagtrack.” This article is quite heavy on NTFS-related terminology, so you’ll need to have a good understanding of it.

Jonas L, on secret.club

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.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

How it worked

Root cause

The service executed a user-supplied WindowsPerformanceRecorder profile without validating the output path, and later allowed renaming of trace files into arbitrary locations via a user-controlled output directory, combined with a race condition on a junction point.

Impact

An attacker could execute arbitrary code with SYSTEM privileges, and also disclose sensitive information such as filenames and raw network traffic.

What the attacker needed

Local access to the machine; ability to create files in user-writable directories

How it was found

  1. Create the folders %WINDIR%\temp\DiagTrack_alternativeTrace\extra\indirections
  2. Start diagnostic trace
  3. Create %WINDIR%\temp\DiagTrack_alternativeTrace\WPR_initiated_DiagTrack[0-100].etl as hardlinks to the payload.
  4. Create symbolic links \RPC Control\WPR_initiated_DiagTrack[0-100.]etl targeting %WINDIR%\system32\phoneinfo.dll
  5. Make OPLOCK on WPR_initiated_DiagTrack100.etl; when broken, check if %WINDIR%\system32\phoneinfo.dll exists. If not, repeat creation of WPR_initiated_DiagTrack[].etl files and matching symbolic links.
  6. Make OPLOCK on on WPR_initiated_DiagTrack0.etl; when it is broken, we know that the rename flow has begun but the first rename operation has not happened yet.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

The DiagTrack service runs with high privileges and lets any user start a diagnostic trace using a file they provide. The file controls where trace output is written, so an attacker can trick the service into writing files to protected folders like System32. By carefully timing a folder swap, they can plant a malicious DLL that another service later loads, giving them full control of the computer.

What is RCE?

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.

Similar reports

View all

Same bug class and techniques, clearest first.

Remote code execution

The lesson behind this report.

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.