Avast Anti-Virus privileged arbitrary file create on virus restore (CVE-2023-1586)
Avast's virus restore function created files as SYSTEM but checked the path for links non-atomically, allowing a TOCTOU race. An attacker could redirect the restore to create an arbitrary file, leading to code execution as SYSTEM.
Published on the-deniss.github.io
In the previous post, we talked about how Avast Free Antivirus “awkwardly” removes malware and how an attacker, by chaining CVE-2023-1585 and CVE-2023-1587, was able to execute arbitrary code in the SYSTEM context. And it is quite obvious to assume that similar problems can be in the virus restore functionality.
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 path check and file creation are not atomic, allowing a time-of-check to time-of-use (TOCTOU) race condition.
Impact
An attacker could create arbitrary files with SYSTEM privileges, which could lead to code execution as SYSTEM, though the bug only allows creating new files, not overwriting existing ones.
What the attacker needed
Avast Antivirus installed; Ability to run code on the target machine; Self-defense bypass
The fix
The vulnerability was fixed by Norton, and the fix was confirmed correct by the reporter.
How it was found
- Create a directory and a test virus file inside it.
- Wait for the test virus to be quarantined.
- Set an oplock on the vault database to pause the restore process.
- Bypass self-defense and call the RPC interface to restore the file.
- When the oplock triggers, replace the parent directory with a mount point and a symbolic link pointing to the target file.
- Verify that the target file was created.
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.
When you restore a quarantined file, Avast checks the folder path for shortcuts (links) to prevent trickery, then creates the file. Because these two steps are separate, an attacker can quickly swap the folder for a link after the check but before the file is written. This lets them make Avast create a file anywhere, even in protected system folders, which can lead to running their own code with high privileges.
What is Race condition?
Parallel requests reach a state the code assumed could not happen: a coupon used twice, a limit overrun, a check skipped.