/

CVE-2026-21853

Severity:

HIGH RISK

(8.8)

Code Injection in AFFiNE Desktop Handler

CVE-2026-21853

Analyzed

Vulnerability type

Category:

Code Injection

CWE:

CWE-94

Impact:

Remote Code Execution on Client Systems

Severity:

HIGH RISK

(8.8)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

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.

Sources

SourceLink
github.comgithub.com/toeverything/AFFiNE/commit/c9a4129a3e9376b688c18e1dcd6c87a775caac80
github.comgithub.com/toeverything/AFFiNE/pull/13864
github.comgithub.com/toeverything/AFFiNE/security/advisories/GHSA-67vm-2mcj-8965

Frequently asked

questions

Yes. An attacker can host or embed a crafted affine: URL on a website or in other content. When the victim's browser invokes the URL and launches AFFiNE, attacker-controlled code can execute, provided the application is installed and registered as the affine: handler.

The attacker only needs to deliver a malicious affine: link to the victim—commonly via a webpage, embedded content, or messaging. No prior access to the victim's machine is required beyond the victim having AFFiNE installed and interacting with the malicious link.

Limit the capabilities of the custom URL scheme to a small set of non-dangerous actions and enforce strict input validation. Ensure that any data from the protocol handler cannot flow into dynamic evaluation, command construction, or file operations without robust validation and, where appropriate, explicit user consent.

Treat all external integration points (custom protocols, deep links, IPC endpoints) as untrusted entry points. Apply consistent security patterns: validate and sanitize inputs, avoid generating or executing code from user-controlled data, design with least-privilege, and mandate security reviews for all OS-level integration features.

Find out what's already
exploitable in your codebase.