COINDEF: A Comprehensive Code Injection Defense for the Electron Framework

Zheng Yang, Simon Chung, Jizhou Chen, Runze Zhang, Brendan Saltaformaggio, Wenke Lee

IEEE Symposium on Security and Privacy 2025 · Day 3 · Systems Security and Access Control

Overview

The proliferation of desktop applications built on the Electron framework has brought convenience and cross-platform compatibility, but also introduced a critical security vulnerability: the potential for seemingly innocuous front-end code injections to escalate into full-fledged remote code execution (RCE). This talk, presented by Zheng Yang at IEEE S&P, introduces COINDEF, a novel defense mechanism designed to comprehensively protect Electron applications from such code injection attacks. The presentation opens with a stark reminder of this threat, citing a real-world incident where an attacker leveraged a malicious link in a chat application to gain internal network access and steal $300,000 USD, an attack made possible by the unique architecture of Electron-like platforms.

Watch on YouTube

Visual summary for COINDEF: A Comprehensive Code Injection Defense for the Electron Framework by Zheng Yang, Simon Chung, Jizhou Chen, Runze Zhang, Brendan Saltaformaggio, Wenke Lee
Visual summary for COINDEF: A Comprehensive Code Injection Defense for the Electron Framework by Zheng Yang, Simon Chung, Jizhou Chen, Runze Zhang, Brendan Saltaformaggio, Wenke Lee

Key moments

  1. 0:00 Introduction and Electron's security challenge
  2. 1:47 COINDEF's core idea: Abstract Syntax Tree enforcement
  3. 3:07 Leveraging JavaScript engine as a single choke point
  4. 4:17 COINDEF's two phases: profiling and enforcement
  5. 6:03 Evaluation of COINDEF on high-profile applications
  6. 7:20 Hybrid approach for comprehensive AST profile collection

COINDEF: A Comprehensive Code Injection Defense for the Electron Framework

Speakers: Zheng Yang; Simon Chung; Jizhou Chen; Runze Zhang; Brendan Saltaformaggio; Wenke Lee

Conference: IEEE S&P

YouTube: https://www.youtube.com/watch?v=lS3oopb8tU

Overview

The proliferation of desktop applications built on the Electron framework has brought convenience and cross-platform compatibility, but also introduced a critical security vulnerability: the potential for seemingly innocuous front-end code injections to escalate into full-fledged remote code execution (RCE). This talk, presented by Zheng Yang at IEEE S&P, introduces COINDEF, a novel defense mechanism designed to comprehensively protect Electron applications from such code injection attacks. The presentation opens with a stark reminder of this threat, citing a real-world incident where an attacker leveraged a malicious link in a chat application to gain internal network access and steal $300,000 USD, an attack made possible by the unique architecture of Electron-like platforms.

COINDEF addresses this pervasive problem by enforcing the integrity of the Abstract Syntax Tree (AST) at the most fundamental level: within the JavaScript engine itself. By monitoring and controlling how code is parsed and interpreted, COINDEF can detect and block malicious injections before they ever execute. The significance of this work cannot be overstated, given the widespread adoption of Electron in popular daily drivers such as VS Code, Evernote, and Slack. Securing these applications is paramount, and COINDEF offers a robust, low-overhead solution to mitigate a critical attack vector that has long plagued the ecosystem.

The research behind COINDEF provides a deep dive into the architectural challenges of securing hybrid applications and presents a practical, empirically validated defense. By combining a sophisticated understanding of JavaScript execution with a pragmatic approach to profiling and enforcement, COINDEF offers a blueprint for enhancing the security posture of countless Electron-based applications, protecting both user data and corporate networks from sophisticated code injection exploits.

Background

▶ Watch: Introduction and Electron's security challenge (0:00)

Electron and similar frameworks are designed to seamlessly bridge web technologies (HTML, CSS, JavaScript) with native operating system capabilities to deliver rich desktop experiences. This is achieved by embedding a Chromium browser engine for the UI and Node.js for native system interactions, making powerful APIs available to the front-end. While this architecture enables highly functional and responsive applications, it inherently introduces a significant security risk: a code injection vulnerability in the UI is no longer confined to the browser sandbox. Instead, it can directly leverage Node.js APIs to achieve remote code execution (RCE) on the underlying system. An attacker exploiting even a minor front-end flaw can potentially gain complete control over the user's device.

The core of this problem lies in how injected code is processed. As demonstrated with an EVAL example, legitimate user input (e.g., a color name like "red") is treated as data, resulting in changes only to the values within existing AST nodes. However, malicious input, such as a shell command, fundamentally alters the program's structure. This structural change manifests as a new or modified subtree within the AST, signaling an injection attempt. Prior work has often struggled to consistently identify and prevent these structural changes across the diverse execution environments within Electron.

COINDEF's foundational insight is that any injected code, whether benign or malicious, must pass through the JavaScript engine's interpretation pipeline. This makes the JavaScript engine a "single choke point" for all JavaScript execution, regardless of whether the code originates from DOM manipulation in the browser environment or dynamic execution in the native environment. By instrumenting the JavaScript engine, COINDEF can enforce AST integrity at the source, preventing injected code from ever reaching execution. This approach offers minimal performance overhead because JavaScript code is parsed only once before execution, allowing security checks to be integrated efficiently without significant runtime impact. Furthermore, instrumenting at this level allows COINDEF to capture valuable execution context, such as the originating process and call site, enabling context-aware security policies that make attacks even harder to achieve.

Key Findings

▶ Watch: Leveraging JavaScript engine as a single choke point (3:07)

COINDEF demonstrates a highly effective and practical solution for mitigating code injection attacks in Electron applications. Its core contribution is the enforcement of Abstract Syntax Tree (AST) integrity at the JavaScript engine level, a strategy that successfully blocks a wide range of real-world exploits with minimal performance overhead.

The evaluation against 20 documented attacks and 59 attack variants across popular Electron applications like VS Code, MS Teams, and Slack yielded compelling results. In its security-first mode, COINDEF achieved zero false negatives, meaning it successfully blocked every tested attack without exception. This robust protection ensures that critical threats cannot bypass the defense mechanism. While this strict mode did result in 17 false positives (12 from third-party remote content in chat applications and 5 from application self-updates), the talk explains that self-update false positives are easily managed by re-profiling the updated portions. For remote content, users can still safely access it via an external browser, making this limitation a reasonable trade-off for maximum security.

For scenarios prioritizing user experience, COINDEF's usability-first mode achieved zero false positives, allowing all legitimate features, including third-party remote content, to function as intended. Although this mode resulted in two false negatives where attacks initially executed, their impact was critically confined to an isolated execution environment, preventing them from escalating to the more privileged first-party context. COINDEF immediately blocked any attempts to escape this isolation, demonstrating its resilience even in a more permissive setting.

Crucially, COINDEF introduces negligible performance overhead. During application startup, 19 out of 20 tested applications experienced less than 1% runtime overhead, with Discord being the outlier at less than 9% (though still under 1 second in absolute terms). More importantly, during normal user interactions, COINDEF introduced no measurable runtime overhead once the code had been parsed and verified. This combination of strong security efficacy and minimal performance impact makes COINDEF a highly practical and deployable solution for real-world Electron applications.

Technical Deep Dive

▶ Watch: COINDEF's two phases: profiling and enforcement (4:17)

COINDEF's technical foundation rests on two primary pillars: AST integrity enforcement and a hybrid profiling approach, all executed by instrumenting the JavaScript engine.

The fundamental principle of AST integrity is that any legitimate modification to an application's behavior, particularly those driven by user input, should only affect the values of existing data nodes within the AST. Conversely, a malicious code injection will inevitably introduce structural modifications, such as new subtrees or altered node types, that deviate from the application's expected AST baseline. COINDEF leverages this distinction: it permits changes to data node values while immediately blocking any structural modifications, which are indicative of a code injection attempt.

The choice to instrument the JavaScript engine is strategic. As the universal interpreter for all JavaScript code within an Electron application, it represents a single, unavoidable choke point. By embedding security checks at this stage, COINDEF ensures that every piece of JavaScript, whether originating from the browser's DOM or the Node.js runtime, is subject to AST integrity verification before execution. This "parse-once, check-once" model contributes to COINDEF's minimal performance impact, as the overhead is primarily incurred during the initial script parsing, not during runtime execution. Furthermore, this instrumentation allows COINDEF to capture critical execution context, including process information, caller identity, and call site details, enabling more granular and context-aware security policies.

COINDEF operates in two distinct phases:

  1. Profiling (Learning Phase): Before enforcing security, COINDEF must first establish a baseline understanding of an application's legitimate AST structures. This is achieved through a hybrid profiling approach designed for comprehensive coverage:
  • Static Scanning: A customized command-line interface for the V8 engine is used to invoke COINDEF and statically analyze JavaScript code before execution. This provides an initial comprehensive understanding of the application's inherent structure.
  • Dynamic Interaction: To capture ASTs generated during runtime behavior, COINDEF leverages:
  • End-to-end UI testing cases: Existing automated tests are utilized to simulate real user interactions and explore various execution paths.
  • Intelligent Crawlers: These crawlers navigate through the application, triggering JavaScript execution and expanding the AST coverage.
  • Manual Efforts: In cases where automation isn't sufficient, human testers interact with the application to reach a "convergent state" where exercising the application no longer increases the covered AST paths. The time required for this phase varies: a few minutes for applications with robust E2E tests, 30 minutes for simple applications, and around four hours for large, complex applications to reach convergence. This hybrid strategy ensures a comprehensive and accurate AST baseline.
  1. Enforcement Phase: Once profiling is complete, COINDEF switches to enforcement mode. During runtime, it performs a multi-layered verification process:
  • Runtime Context Verification: Before even examining the AST structure, COINDEF verifies the execution context, including process information, caller identity, and call site details. This ensures that the code execution aligns with expected behavior based on the learned profiles.
  • AST Structure Verification: If the context is deemed legitimate, COINDEF then verifies the AST structure against its learned baselines. Any unexpected structural modifications, such as the introduction of new subtrees, are immediately flagged and blocked as potential injection attempts.

To manage exceptions and balance security with usability, COINDEF employs predefined security policies that result in two distinct enforcing modes:

  • Security-First Mode: This mode prioritizes maximum protection. It strictly enforces AST integrity, leading to zero false negatives. However, it may introduce false positives, particularly with untrusted third-party remote content or application self-updates. For self-updates, reprofiling is a straightforward solution. For remote content, the recommendation is to access it in an external browser, maintaining security without completely blocking access.
  • Usability-First Mode: This mode prioritizes minimizing disruptions to user experience. It allows some flexibility, particularly with remote content, resulting in zero false positives. While this flexibility might lead to a few false negatives (attacks that initially execute), COINDEF ensures they are confined to an isolated execution environment, preventing them from escalating to critical first-party code. Any attempt by an attack to "break out" of this isolation and enter a more privileged first-party context is immediately blocked. This mode is recommended for applications that frequently load remote content, such as chat applications.

Demo / Proof of Concept

▶ Watch: Evaluation of COINDEF on high-profile applications (6:03)

While the talk did not feature a live, interactive demonstration of COINDEF in action, the researchers provided a comprehensive and rigorous evaluation that serves as a robust proof of concept for its effectiveness. The team tested COINDEF against a diverse set of real-world Electron applications that represent prevalent code injection attack surfaces, including VS Code, MS Teams, Slack, Discord, and Evernote. These applications were chosen for their complexity and their susceptibility to a wide range of vulnerabilities, such as various types of cross-site scripting (XSS), client-side open redirects, and prototype pollution.

The evaluation methodology focused on three main categories of injection points:

  1. Chatting Messages: Where an attacker's network request or a victim's network response could be manipulated to execute unintended code.
  2. Remote Content: Untrusted web resources that might introduce malicious scripts.
  3. Markdown Files: Seemingly harmless text files that can embed HTML code for injection.

To rigorously assess COINDEF's capabilities, the researchers collected 20 documented attacks from cited sources. Furthermore, they designed an additional 59 attack variants specifically crafted to try and evade COINDEF's detection mechanisms. This extensive collection of attack vectors allowed for a thorough assessment of the system's resilience against both known exploits and novel evasion techniques.

The results of this evaluation, as detailed in the "Key Findings" section, clearly demonstrate COINDEF's ability to prevent real-world code injection exploits across these diverse scenarios while largely maintaining application functionality and user experience. The high function-level code coverage achieved across all applications (averaging 87%, ranging from 70% for the largest applications to 100% for smaller ones) further validates that COINDEF effectively monitors and enforces AST integrity across a significant portion of the application's codebase. This systematic testing against a large corpus of attacks and variants, rather than a single live demo, provides strong empirical evidence of COINDEF's practical utility and robust security guarantees.

Defensive Implications

▶ Watch: Hybrid approach for comprehensive AST profile collection (7:20)

The insights and mechanisms presented by COINDEF offer critical defensive implications for developers, security teams, and organizations building or deploying Electron applications. The primary takeaway is the urgent need to integrate Abstract Syntax Tree (AST) integrity enforcement as a fundamental layer of defense against code injection attacks that can escalate to RCE.

Developers of Electron applications should consider adopting AST-based defense mechanisms like COINDEF within their development lifecycle. This could involve integrating COINDEF's instrumentation into their build pipelines or runtime environments. The hybrid profiling approach is crucial for establishing robust and accurate AST baselines, so dedicated effort must be allocated to thoroughly profile applications using a combination of static analysis, automated UI testing, and manual interaction to ensure comprehensive coverage.

Organizations deploying Electron applications need to carefully evaluate their security posture and consider the trade-offs between COINDEF's security-first and usability-first modes. For mission-critical applications handling sensitive data or operating within highly privileged environments, the security-first mode, with its zero false negatives, is highly recommended, even if it requires managing occasional false positives related to remote content or self-updates. For public-facing or chat-heavy applications where seamless user experience with remote content is paramount, the usability-first mode offers a pragmatic balance, ensuring that even if an attack initially executes, its impact is strictly confined and prevented from escalating to critical application logic.

Furthermore, the emphasis on instrumenting the JavaScript engine highlights a broader defensive strategy: securing the core execution environment. This approach is more resilient than relying solely on application-level sanitization or input validation, which can often be bypassed. Security teams should advocate for deeper, architectural security controls that operate at fundamental execution layers, providing a more robust and systemic defense against evolving threats. Ultimately, COINDEF provides a blueprint for a future where Electron applications can leverage their powerful native capabilities without inherently exposing users to severe code injection risks.

Key Takeaways

  • Electron's Architecture Poses RCE Risk: The design of Electron applications, bridging web technologies with native system APIs, inherently creates a critical vulnerability where front-end code injection can easily escalate to remote code execution (RCE).
  • AST Integrity as a Powerful Defense: Enforcing the integrity of the Abstract Syntax Tree (AST) at the JavaScript engine level is a highly effective mechanism to detect and block malicious code injections before they execute, by distinguishing legitimate data changes from structural modifications.
  • Hybrid Profiling is Essential: Comprehensive and accurate AST baselines are crucial for effective enforcement. COINDEF achieves this through a hybrid profiling approach combining static analysis, dynamic interaction via automated UI tests and crawlers, and targeted manual efforts.
  • Dual Security Modes for Flexibility: COINDEF offers both a security-first mode (zero false negatives, minimal false positives) and a usability-first mode (zero false positives, confined false negatives), allowing organizations to choose the appropriate balance based on application criticality and user experience requirements.
  • Minimal Performance Overhead: By instrumenting the JavaScript engine and checking code only during its initial parsing, COINDEF introduces negligible runtime overhead (<1% for most apps, up to <9% for startup in one case) during normal application use, making it practical for real-world deployment.
  • Confined Impact Even in Permissive Mode: Even in the usability-first mode where some attacks might initially execute, COINDEF critically confines their impact to isolated environments, preventing them from escalating to compromise sensitive first-party application logic or system resources.

About the Speaker(s)

The primary presenter of this talk was Zheng Yang, who introduced himself as "Junyang." He is listed as one of the key contributors to COINDEF, alongside Simon Chung, Jizhou Chen, Runze Zhang, Brendan Saltaformaggio, and Wenke Lee. The presentation of such a detailed and technically robust solution at IEEE S&P, a premier security conference, indicates that Zheng Yang and his co-authors are accomplished researchers in the field of system security and software vulnerability. Their work focuses on developing practical and effective defenses against sophisticated attacks targeting modern application frameworks.

All talks from IEEE Symposium on Security and Privacy 2025