Ledger CLI Account Directive Use-After-Free Vulnerability
A use-after-free vulnerability in Ledger CLI's account parsing allows a crafted journal file to cause arbitrary code execution. An attacker can convince a user to load a malicious journal file to trigger the vulnerability.
Originally disclosed on Cisco Talos
An exploitable use-after-free vulnerability exists in the account parsing component of the Ledger-CLI 3.1.1. A specially crafted ledger file can cause a use-after-free vulnerability resulting in arbitrary code execution.
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 report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the parser incorrectly manages a std::unique_ptr, releasing an object while a pointer to it is still retained and later dereferenced.
What the attacker needed
Victim loads a malicious journal file
How it was found
- Create a journal file with an account directive line starting with a number.
- Include a deferred posting by placing content between '<' and '>' before the next account directive.
- Run the ledger binary with the crafted file and a command such as register or xml.
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 report has not been written yet. The Original tab links to the source.
A use-after-free happens when a program frees memory but keeps using it, like deleting a file but still opening it. Here, a malformed journal file makes Ledger CLI free an object but later use it, which can let an attacker run their own code. The attacker needs the victim to open a malicious journal file.
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.