Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.
Sources: National Vulnerability Database, CISA KEV, Exploit-DB
CVE-2026-105220 Overview
CVE-2026-105220 is a cross-site scripting (XSS) vulnerability in Twine 2 desktop versions through 2.12.0. The flaw resides in the importStories() function, which executes markup embedded in imported story files inside the editor window. An attacker can craft a malicious story file that invokes the twineElectronopenWithScratchFile IPC bridge to write and open a .bat file. This action results in arbitrary code execution under the context of the current user. The weakness is categorized under CWE-79.
Critical Impact
A single malicious Twine story file can achieve local arbitrary code execution on the victim's machine via the Electron IPC bridge.
Affected Products
- Twine 2 desktop versions up to and including 2.12.0
- Electron main process components: src/electron/main-process/scratch-file.ts
- Story import utility: src/util/import.ts
Discovery Timeline
- 2026-10-04 - CVE-2026-105220 published to NVD
- 2026-10-06 - Last updated in NVD database
Technical Details for CVE-2026-105220
Vulnerability Analysis
Twine 2 desktop is an Electron-based editor for interactive fiction. The importStories() function in src/util/import.ts historically parsed imported HTML by assigning user-controlled content to the innerHTML property of a div element. This approach triggers execution of inline scripts and event handlers when the editor renders the imported content.
Because the editor runs inside Electron with an IPC preload bridge, attacker-controlled script gains access to window.twineElectron. The exposed openWithScratchFile(data, filename) method sends arbitrary data and filename arguments to the main process over the open-with-scratch-file channel. The main process then writes the attacker-supplied content to disk and opens it. By specifying a .bat filename, the attacker triggers execution of batch commands through the operating system shell.
Root Cause
The root cause is twofold. First, importStories() renders untrusted HTML through innerHTML, allowing script execution during import (CWE-79). Second, the Electron preload exposes a general-purpose file-write-and-open primitive, openWithScratchFile, without restricting the file type. Together, these flaws turn an XSS primitive into local code execution.
Attack Vector
The attack requires user interaction. The victim must open a malicious .html story file inside the Twine 2 desktop editor. Once imported, embedded JavaScript executes in the renderer context and calls the IPC bridge to drop and launch an executable script.
// Vulnerable import path (pre-patch)
const nodes = document.createElement('div');
nodes.innerHTML = html; // Executes inline markup from untrusted story file
// Patched version uses DOMParser to avoid script execution
const nodes = new DOMParser().parseFromString(html, 'text/html').body;
Source: GitHub commit 8e8a2be
// Preload bridge change restricts the IPC method to HTML only
- openWithScratchFile(data: string, filename: string) {
- ipcRenderer.send('open-with-scratch-file', data, filename);
+ openHtmlWithScratchFile(data: string, filename: string) {
+ ipcRenderer.send('open-html-with-scratch-file', data, filename);
},
Source: GitHub commit 3a9af28
Detection Methods for CVE-2026-105220
Indicators of Compromise
- Creation of unexpected .bat, .cmd, or script files in Twine temporary or scratch directories.
- Twine.exe or the Electron renderer process spawning cmd.exe, powershell.exe, or other interpreters.
- Imported .html story files containing <script> tags that reference twineElectron.openWithScratchFile.
Detection Strategies
- Hunt for process creation events where the parent process is the Twine Electron binary and the child is a shell or scripting interpreter.
- Inspect downloaded or shared .html story files for inline JavaScript invoking IPC bridge functions such as openWithScratchFile or open-with-scratch-file.
- Monitor file-write telemetry for executables emitted from the Twine process into user-writable temporary paths.
Monitoring Recommendations
- Enable endpoint telemetry for user-mode process trees originating from Electron applications on developer workstations.
- Log and alert on .bat or .cmd files written and immediately executed within a short time window.
- Collect and retain file hashes of imported Twine story files for retrospective hunting against the IOCs above.
How to Mitigate CVE-2026-105220
Immediate Actions Required
- Upgrade Twine 2 desktop to a release that includes commits 3a9af28 and 8e8a2be, which supersede version 2.12.0.
- Do not import .html story files received from untrusted sources until the patched build is installed.
- Audit shared story repositories and asset drops for files containing script tags or references to twineElectron.
Patch Information
The maintainer resolved the vulnerability in two commits. Commit 8e8a2be replaces the innerHTML assignment in src/util/import.ts with DOMParser.parseFromString, which does not execute scripts. Commit 3a9af28 renames and restricts the IPC bridge to openHtmlWithScratchFile, limiting file-opening to HTML content. Additional context is available in the VulnCheck Advisory on TwineJS and GitHub Issue #1706.
Workarounds
- Open suspect story files in a browser or text editor rather than the Twine 2 desktop application.
- Run Twine 2 desktop inside a sandbox or disposable virtual machine when handling third-party content.
- Restrict execution of .bat and .cmd files from user temporary directories via application control policies.
# Example Windows AppLocker rule to block scripts from user temp paths
New-AppLockerPolicy -RuleType Path -User Everyone -Action Deny \
-Path "%LOCALAPPDATA%\Temp\*.bat" -RuleNamePrefix "BlockTwineScratchBat"
Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.
Sources: National Vulnerability Database, CISA KEV, Exploit-DB

