Hi Damien (@dae) and community,
I am opening this thread to discuss the feasibility and design of a runtime sandboxing mechanism for Anki Desktop.
The Problem: Supply Chain Vulnerability Currently, Anki’s add-on ecosystem operates on a high-trust model. While this flexibility is Anki’s greatest strength, it is also a significant security liability.
-
The Risk: An add-on runs with the full permissions of the user. A malicious actor—or a legitimate developer whose AnkiWeb credentials are compromised—could push an update that instantly encrypts a user’s
~/Documentsfolder (ransomware), exfiltrates browser session cookies, steals money from user bank accounts or crypto wallets. Today with LLMs, writing malware became easier then ever before. -
The Ease of Attack: Because there is no permission scoping (e.g., “Add-on X wants Internet access”), a malicious update effectively grants remote code execution (RCE) on thousands of machines instantly. As Anki grows in popularity, the incentive for such supply-chain attacks increases.
The Proposal: Opt-in Privilege Dropping I am not proposing a full rewrite or moving to the strict OS App Stores (which would break too many things). Instead, I’d like to explore implementing a “Self-Sandboxing” step at startup. This is a standard security practice.
The core idea is to allow Anki to initialize normally, but then “lock the door” before loading any add-ons.
Proposed Architecture (Draft): I am investigating using OS-native, dependency-free APIs to drop write privileges for the Anki process at runtime.
-
Linux: Using
Landlock(viactypes, no new dependencies). -
macOS: Using
sandbox_init(Seatbelt) with a blacklist profile. -
Windows: Using
Job ObjectsorAppContainerrestrictions.
The Workflow:
-
Anki starts, loads profiles, and initializes the GUI.
-
(New Step) Anki checks for an
--experimental-sandboxflag. -
If present, Anki invokes the OS API to permanently revoke its own ability to write to files outside of
baseandtempfolders, and netowrk access beyond https://ankiweb.net/ for syncing. -
Anki loads add-ons.
- Result: If a compromised add-on tries to encrypt
~/Documents, the OS kernel denies the write.
- Result: If a compromised add-on tries to encrypt
Long-Term Vision: A Permission Manifest System While the immediate goal is a binary “Sandbox On/Off” switch, I believe this architectural change paves the way for a more granular, user-friendly permission system in the future (similar to Android or Chrome extensions).
If we can successfully implement the plumbing for privilege dropping, we could eventually explore:
-
Add-on Manifests: Developers declare their needs in a
manifest.json(e.g.,["network:api.openai.com", "clipboard-write"]). -
User Consent: AnkiWeb could display these requests prominently (“This add-on wants to access the Internet”).
-
Enforcement: On startup, Anki would read the manifest and configure the sandbox specifically for that add-on requested permission, knowing the user knowingly allowed it when installing the module.
I realize this requires server-side changes and is out of scope for now, but establishing the client-side sandboxing capabilities is the necessary first step toward that future.
Questions for the Team:
-
Has this specific approach (runtime privilege dropping via ctypes) been explored or rejected before?
-
Are there specific technical blockers (e.g., specific Qt helper processes or IPC mechanisms) that you anticipate would break under this model?
-
If I were to develop a Proof of Concept (POC) for Linux/macOS first, would you be open to reviewing it and merging as an opt-in hardening feature?
-
Do you have other ideas to move towards a more secure anki ecosystem?
I want to emphasize that my goal is not to impose restrictions on general users or break existing add-ons, but to provide a safety layer for security-conscious users who want to mitigate the risk of running third-party code. And slowly, pave the way for more secure anki for everyone.
Looking forward to your thoughts.