Attack Surface Analysis - Part 3 - Resurrected Code Execution
A custom protocol handler passed command-line switches to a .NET desktop app, and two hidden switches accepted a remote XML script plus an output file. A script command could launch a local executable without arguments, and because the output file echoed the failing script line verbatim, an attacker could write an HTA to a chosen local path and then launch it, achieving code execution with arguments.
Published on parsiya.net
In part 3 of my attack surface analysis series, I will discuss an undisclosed RCE. This bug uses a combination of all tricks introduced in part 2 of the series.
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
Likely the app trusted command-line switches reachable from a protocol handler, loaded remote script and output paths, and echoed raw script lines into an attacker-chosen output file, then allowed a second invocation to execute that file.
Impact
An attacker could achieve remote code execution with arguments on a victim's machine, though the victim must click Allow for each protocol handler launch and Chromium requires a user gesture between launches.
What the attacker needed
Victim clicks a link; victim clicks Allow twice; attacker hosts remote script; known or writable local path
How it was found
- Create a remote XML script containing an unknown tag whose text is the HTA payload.
- Invoke the protocol handler with the script switch, the remote script, and a local output path ending in .hta.
- The app writes the error line, including the payload, into the chosen .hta file.
- Invoke the protocol handler again with a second script that uses BrowserOpen on the injected HTA.
- The user clicks Allow for each protocol handler launch.
- The injected HTA executes.
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.
This desktop program can be started from a web link through a custom link type it registers. Two hidden start-up options let it read a script file from a network share and write a result file to any local path. When the script has an error, the program copies the bad line into that result file, so an attacker can make it write a malicious file and then run it.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.