Summary
AFFiNE's custom URL handler incorrectly processes affine: links in a way that allows arbitrary code execution on the user's machine.
When a victim's browser invokes the AFFiNE application through a specially crafted affine: URL, the app can execute attacker-controlled code without additional user interaction.
Affected context
This vulnerability affects environments where:
- The AFFiNE desktop application is installed and registered as a handler for the affine: URL scheme
- Web browsers are allowed to invoke custom URL protocols on the operating system
- The application treats URL parameters as trusted instructions or scriptable input
Risk is elevated when users regularly browse untrusted sites or interact with user-generated content that can embed affine: links.
Exploit preconditions
- Attack surface: User workstations running the AFFiNE desktop app with the affine: protocol registered.
- Required access: Ability to embed or serve crafted affine: URLs on a webpage, email, chat, or other content channel.
- Trigger point: The victim's browser follows the affine: URL (via automatic redirect or a single click), which launches AFFiNE and passes it the crafted URL.
- Why exploitation is possible: The URL handler logic processes input parameters without sufficient validation, allowing attacker-controlled data to be interpreted as executable instructions or code within AFFiNE.
Why this happens
The core issue stems from treating data received through a custom URL scheme as executable or directly interpretable content.
Instead of strictly validating and constraining the actions allowed via affine: URLs, the handler logic permits attacker-controlled parameters to influence code paths or command execution.
This aligns with CWE-94: Improper Control of Generation of Code, where untrusted input is incorporated into executable code or interpreted as such by the application.
Potential impact
- Execution of arbitrary code with the privileges of the local user running AFFiNE
- Installation of malware or backdoors on the victim's machine
- Access to and exfiltration of local documents and data accessible to the user
- Lateral movement within the user's environment using their credentials or session
- Integrity compromise of AFFiNE workspaces and stored content
General mitigation guidance
Effective mitigation generally focuses on constraining what a custom URL handler is allowed to do and treating all external inputs as untrusted:
- Restrict the affine: protocol to a minimal, well-defined set of operations, avoiding any direct interpretation of parameters as code or commands.
- Apply strict validation, whitelists, and schema checks on all URL parameters before use.
- Avoid dynamic evaluation, template execution, or command construction that includes untrusted input.
- Design the handler so that potentially sensitive actions require explicit, in-app confirmation instead of silent execution.
- Run the application with least-privilege and ensure it does not rely on ambient system capabilities for tasks that might be triggered via URLs.
- Consider defensive defaults in OS-level integration, such as requiring user confirmation before opening affine: links from the browser.
How teams detect issues like this
Detection can focus on both code-level and behavioral indicators:
- Static analysis: Flag dynamic evaluation functions, command builders, or script injection points that consume custom protocol input.
- Code review: Treat custom URL handlers and OS integration layers as security-critical, checking for rigorous validation, parameter whitelisting, and absence of code generation from user-controlled data.
- Policy enforcement: Require security reviews for any new or modified protocol handlers and IPC endpoints that accept data from browsers or external applications.
- Runtime monitoring: Use endpoint security tools or OS logging to monitor for unusual process launches or scripts triggered via custom URL schemes.

