Avast Anti-Virus privileged arbitrary file create on virus quarantine (CVE-2023-1585 and CVE-2023-1587)
Avast Anti-Virus had a time-of-check time-of-use (TOCTOU) flaw in its quarantine deletion: it checked a file path for links and then deleted the file, but an attacker could redirect the path between check and delete to remove an arbitrary file or directory as SYSTEM. Chained with a null-pointer crash that restarts the service and recreates a world-writable directory, plus an RPC copy gadget, this allowed arbitrary file write and code execution as SYSTEM.
Published on the-deniss.github.io
I’m not a big fan of privileged file operation abuse, because such vulnerabilities are usually quite trivial. But there are attack surfaces where you really want to find a vulnerability - because it seems difficult due to the great attention of developers and researchers to it, the old age of the feature and…
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 path check and the subsequent file deletion are not atomic, allowing an attacker to redirect the path via a junction or symbolic link between the check and the delete.
Impact
An attacker could delete arbitrary files or directories as SYSTEM, and by chaining with a service crash and an RPC copy method, could achieve arbitrary file write and code execution as SYSTEM.
What the attacker needed
Avast Free Antivirus installed; Ability to create files and directories; Ability to set oplocks; Self-defense bypass for RPC access
The fix
The vulnerabilities were fixed by Norton/Avast after the author reported incomplete fixes and retested the final patches.
How it was found
- Create a directory with a restrictive DACL that denies FILE_ADD_FILE for SYSTEM and place a test EICAR virus file inside.
- Set an oplock on the Cleaner.log file and wait for the test virus to be quarantined.
- When the oplock triggers, remove the test virus and switch the parent directory to a mount point and native symbolic link pointing to the target file.
- Release the oplock, wait a few seconds, and confirm the target file was deleted.
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 Avast finds a virus, it deletes the file with high system privileges. The program first checks the file path for tricks, then deletes the file, but an attacker can swap the path in between so Avast deletes a different, important file. By combining this with a crash that restarts Avast and a copy feature, the attacker can write files anywhere and run code as the system user.
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.