Skip to content
Memory corruption Write-up Advanced

F-Secure Anti-Virus: Remote Code Execution via Solid RAR Unpacking

An uninitialized memory bug in 7-Zip's RAR decoder, used by F-Secure antivirus, allowed an attacker to control a decoder's state and achieve remote code execution. By crafting a malicious RAR archive, an attacker could execute arbitrary code as NT AUTHORITY\SYSTEM when the archive was scanned.

landave.io

Published on landave.io

As I briefly mentioned in my last two posts about the 7-Zip bugs CVE-2017-17969, CVE-2018-5996, and CVE-2018-10115, the products of at least one antivirus vendor were affected by those bugs. Now that all patches have been rolled out, I can finally make the vendor’s name public: It is F-Secure with all of its…

The author, on landave.io

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 an uninitialized memory usage in the RAR1 decoder's LongLZ function, where attacker-controlled arrays ChSetB and NToPlB are used without initialization, leading to a controlled read-write primitive.

What the attacker needed

Victim visits a malicious web page; F-Secure product with unpatched 7z.dll; file size under 5MB for automatic scan

The fix

F-Secure fixed the vulnerability by updating their products via automatic update channel, and the author proposed mitigation measures such as sandboxing the engine and enabling modern Windows exploitation mitigations.

How it was found

  1. Place a Rar3 decoder object in constant distance after the Rar1 decoder containing the read-write primitive.
  2. Use the Rar3 decoder to extract the payload into the _window buffer.
  3. Use the read-write primitive to swap the Rar3 decoder’s vtable pointer with the _window pointer.
  4. Use the read-write primitive to write a function pointer to the end of the Rar3 window buffer.
  5. Use PutByte and CopyBlock operations to construct a valid address by combining chosen bytes with copied bytes from the function pointer.
  6. Use the read-write primitive to swap a pointer of the form +0xc**** into LCount, increment it to +0xd****, and swap it into the window buffer.

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.

Antivirus software scans files for threats, but sometimes the code that unpacks compressed files has a flaw. Here, a bug in the RAR unpacking code let an attacker take control of the program's memory and run their own commands with high privileges. The attacker only needed the victim to download a malicious RAR file, which the antivirus would automatically scan.

What is Memory corruption?

Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.

Similar reports

View all

Same bug class and techniques, clearest first.

Memory corruption

The lesson behind this report.

Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.