Ankitects Anki Flask Invalid Path Reflected Cross-Site Scripting (XSS) vulnerability
A reflected cross-site scripting vulnerability in Anki's Flask server allows a malicious flashcard to execute JavaScript in an authorised context, bypassing API access controls. This enables an attacker to read arbitrary files from the victim's system and exfiltrate them.
Originally disclosed on Cisco Talos
An reflected XSS vulnerability exists in the handling of invalid paths in the Flask server in Ankitects Anki 24.04. A specially crafted flashcard can lead to JavaScript code execution and result in an arbitrary file read.
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
The Flask server reflects the requested path into an error page without sanitising it, allowing script injection.
Impact
An attacker could read arbitrary files from the victim's system and exfiltrate them, but the exploit requires the victim to review a malicious card.
What the attacker needed
Victim imports and reviews a malicious flashcard
The fix
The vulnerability was fixed in a vendor patch release.
How it was found
- Create a flashcard containing JavaScript that adds a hidden iframe pointing to a crafted URL.
- The URL path begins with /_anki/pages/ and includes an XSS payload.
- When the card is reviewed, the iframe loads and the reflected XSS executes in an authorised context.
- Use the API to call addImageOcclusionNote with a path to a sensitive file, which copies it to the media folder.
- Read the file via the media server and send its contents to the attacker.
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.
Anki is a flashcard app that runs a small web server on your computer. A malicious flashcard can trick that server into running harmful JavaScript code, which can then read files on your computer and send them to an attacker.
What is XSS?
Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.