We hacked Anki - 0 day exploit from studying someone elses flashcards
Anki's LaTeX handling allowed bypassing a blocklist to read files and write to the temp directory, and JavaScript in cards could exfiltrate media and credentials. An attacker could achieve remote code execution or steal user data by sending a malicious shared deck.
skerritt.blog
Published on skerritt.blog
Anki is the most popular flashcards program in the world. The Android app alone has 10 million downloads, and this is a third party app that someone created and isn't an official Anki application.
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 LaTeX blocklist was incomplete and could be bypassed with hex escapes, and JavaScript in cards had access to internal APIs and media files without sufficient sandboxing.
Impact
An attacker could read arbitrary files, write files, execute commands, and steal credentials, though some LaTeX RCE requires specific TeX distributions and file read is limited to plaintext and user permissions.
What the attacker needed
Victim imports a malicious deck; victim studies a card from the deck; Anki version before 24.04
The fix
The vulnerabilities were fixed in Anki versions 24.04 and later, as indicated by the CVE references.
How it was found
- Create a new note type and insert malicious Javascript into the card template.
- Create a card with LaTeX that uses hex escapes to bypass the blocklist.
- Import the deck into Anki and study the card to trigger the exploit.
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.
Anki is a flashcard app where you can import decks made by others. The report shows that a malicious deck can contain code that runs on your computer when you study it, letting an attacker read your files or take over your account.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.