-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256
NEFARIOUSPLAN-CANONICAL-V1
{"body_md":"## The resolver was written for a root the operating system owned\n\nNode.js's CommonJS module resolution is documented as Algorithm 4 in the [Modules: CommonJS modules](https://nodejs.org/api/modules.html#all-together) reference. For `require('utf-8-validate')` called from `
/file.js`, the resolver computes the lookup-path list as the `node_modules` directory at ``, then `/..`, then `/../..`, and so on rootward. At each level it tests, in order:\n\n1. `/node_modules/utf-8-validate.js`\n2. `/node_modules/utf-8-validate/package.json`, then the `main` field\n3. `/node_modules/utf-8-validate/index.js`\n\nThe first match wins. The walk does not stop at the application's install directory. It does not stop at the user profile. It does not stop at any boundary the application opted into. It stops at the root of the filesystem, because that is where there is no parent to walk into.\n\nThe algorithm was authored against Unix, where the rootward walk terminates at `/`. On Unix, `/node_modules/` does not exist by default and creating it requires `root`. The terminal node of the walk is administratively owned. The implicit allowlist on the lookup-path list is \"every node from `` up to a node only `root` can write to.\" Node.js did not install that allowlist as code. The platform installed it as the filesystem's ACL on `/`.\n\nWindows inherits the resolver. Node.js on Windows walks rootward from the loader's directory to the drive root, generating `C:\\<...>\\node_modules\\` at every level along the way and `C:\\node_modules\\` at the end. The terminal node of the walk is `C:\\`. The drive root is not administratively owned.\n\n## `C:\\` admits standard users at the directory grain\n\nThe default discretionary ACL on `C:\\` on Windows 10 and Windows 11 grants the `Authenticated Users` SID the `FILE_ADD_SUBDIRECTORY` right. The ACL also grants `BUILTIN\\Users` read and traverse through the existing tree, and grants `CREATOR OWNER` full control inherited into anything those users create. The composition is one sentence: a standard user cannot create files at `C:\\`, but can create directories there, and inherits full control over the directories they create.\n\n```\n> icacls C:\\\nC:\\ NT AUTHORITY\\SYSTEM:(OI)(CI)(F)\n BUILTIN\\Administrators:(OI)(CI)(F)\n BUILTIN\\Users:(OI)(CI)(RX)\n NT AUTHORITY\\Authenticated Users:(M) <-- AppendData / AddSubdirectory\n NT AUTHORITY\\Authenticated Users:(OI)(CI)(IO)(M)\n CREATOR OWNER:(OI)(CI)(IO)(F)\n```\n\n`mkdir C:\\node_modules` succeeds for any standard user. The user becomes the owner of `C:\\node_modules`. Any file the user writes inside is theirs to read, replace, and delete. No prompt. No elevation. No installer.\n\nThat is the gap. Node's resolver assumed the rootward walk terminated at administratively-owned territory. On Windows it terminates at territory the standard user claims by `mkdir`.\n\n## The chain\n\nThe PoC published by `0x18F` on 2026-06-10 is one Python harness and one JavaScript payload. The payload is three lines:\n\n```javascript\n// node_modules/utf-8-validate.js\nconst { exec } = require('child_process');\nexec('start cmd.exe /k echo CVE-2026-0776');\nmodule.exports = { validate: () => true };\n```\n\nLine 1 imports `child_process` from Node's standard library, available because the payload is being loaded by Discord's bundled Node runtime. Line 2 spawns `cmd.exe` with the `/k` switch so the window stays open and the demonstration is visible. Line 3 returns an object whose `validate` method always returns true, which is the shape `utf-8-validate` exports. Discord's downstream caller of `require('utf-8-validate')` (the `ws` WebSocket library, which Discord uses for its gateway connection) receives a module that satisfies the contract, calls `validate()` on inbound frames, gets `true` every time, and continues. The exploit lives entirely above the WebSocket stack's expectations.\n\nThe Python harness is the planting and launch:\n\n```python\nDESTINATION_FOLDER = Path(r\"C:\\node_modules\")\nsource_folder = current_dir / \"node_modules\"\n...\nshutil.copytree(source_folder, DESTINATION_FOLDER)\n...\nsubprocess.Popen([\n str(discord_update),\n \"--processStart\",\n \"Discord.exe\"\n])\ntime.sleep(10)\nshutil.rmtree(DESTINATION_FOLDER)\n```\n\nThe harness copies the local `node_modules\\utf-8-validate.js` into `C:\\node_modules\\`, launches Discord through `%LOCALAPPDATA%\\Discord\\Update.exe --processStart Discord.exe` (the Squirrel-based launcher Discord ships, the same launcher the desktop shortcut invokes), sleeps ten seconds for the Electron process to initialize and resolve its dependencies, then removes `C:\\node_modules\\` before exiting. The cleanup is the anti-forensic detail. The payload sits on disk only for the window in which Discord's main process imports `ws` and `ws` calls `require('utf-8-validate')`. After that import, Node has cached the module reference in memory; the file on disk no longer needs to exist.\n\nWhen `Discord.exe` starts, the Electron main process loads `resources\\app.asar` and imports the dependencies the asar declares. `ws` is one of them. `ws` declares `utf-8-validate` as an optional native dependency that improves performance when installed and is silently absent otherwise. Discord 1.0.9196's bundle ships `ws` without bundling the native build of `utf-8-validate`. The `try { require('utf-8-validate') } catch { ... fall back to JS ... }` inside `ws` issues the `require`. Node's resolver, given that name, walks rootward in the real filesystem, generates `C:\\node_modules\\utf-8-validate.js`, finds it, and loads it. The payload's top-level `exec('start cmd.exe...')` runs inside the Discord process. The `validate: () => true` export satisfies the `ws` contract. The WebSocket stack continues. The shell stays open.\n\nThe attacker now has code execution inside a process that runs as the Discord user, with the Discord user's session token in memory, with Discord's IPC channel open to every other Discord window the user has, and inside a Microsoft-signed Electron binary. Application-control policies (AppLocker, WDAC, ASR rules) that allowlist `Discord.exe` by signature do not catch the planted code, because the planted code is loaded by the signed binary's own Node runtime under its own image trust.\n\n## Every Electron application on Windows ends the same walk\n\n`utf-8-validate` is an optional native dependency of `ws`, which is the default WebSocket client for Node.js and the default WebSocket client for Electron applications that maintain real-time connections. The list of Electron applications that ship `ws` includes Slack, Microsoft Teams, VS Code, Notion, Postman, GitHub Desktop, Twitch, Figma, WhatsApp Desktop, and most of the rest of the category. The list of those that ship `utf-8-validate` natively is shorter, because the dependency is optional and many bundlers omit it. Every one of the omissions calls `require('utf-8-validate')` and lets Node walk rootward.\n\nThe bug is not Discord's alone. The bug is the composition of three design choices made by three different parties. Node.js walks rootward to the filesystem root because that is what its module resolution algorithm has always done. Electron inherits Node's resolver without scoping it to the application's install directory, because the resolver's behavior is part of Node's documented contract and pinning it to a per-application root would break other resolution patterns Electron applications rely on. Windows defaults the drive root to permit `Authenticated Users` create-subdirectory, because the drive root is the user's filesystem and the OS treats it as user-owned territory. Each choice is reasonable in isolation. Composed, they hand any standard local user a primitive: drop a file at `C:\\node_modules\\.js` and wait for the next Electron application to start.\n\nThe race is for who plants first. Once `C:\\node_modules\\` exists with one user as its owner, no other standard user can plant inside it without that user's cooperation. The operational pattern follows: malware that lands as a standard user (a phishing dropper, an unprivileged script, a tampered installer) creates `C:\\node_modules\\utf-8-validate.js` and exits. The next Electron application the victim launches loads the planted file. The malicious code now runs inside a signed application's process, persistent for the lifetime of that process, with whatever credentials the host application holds.\n\nThe CWE on the CVE record reads CWE-427, Uncontrolled Search Path Element. The search path is Node.js's. The element is the drive root.\n\n## What a patch addresses, and what it does not\n\nDiscord can close the Discord-shaped CVE by pre-creating `C:\\node_modules\\` at install time with an ACL that denies write to non-administrators. The Squirrel installer Discord ships runs as the user installing Discord, not as an administrator; the per-user installation flow Discord chose specifically so that users could install Discord without elevation cannot defensively claim a path that requires elevation to claim. The patch shape that closes Discord's exposure either requires changing Discord's installer to be elevated (a model Discord has declined for over a decade) or requires shipping a custom Node loader inside the Electron runtime that scopes module search to the application's install root.\n\nOnly the second closes the primitive. The first closes Discord and leaves the same primitive open for every Electron application that ships next to Discord on the same machine. The second changes what `require()` does in a process Node thinks it owns the search behavior of.\n\nNode.js itself has no incentive to change the resolver. The Unix-shaped assumption is correct on Unix, where the primitive does not exist. Changing the rootward walk to terminate at the user-home boundary would break system-wide module installations on Unix and would not affect Discord's exposure unless Electron pinned to a patched Node, which Electron does not. The resolver's behavior is documented and load-bearing for the rest of the Node ecosystem; changing it for Windows alone would fork the contract on the platform that needs the fork most.\n\nThe primitive belongs to the composition. CVE-2026-0776 names Discord because Trend Micro's submission tested Discord. The same primitive runs in every Electron application on Windows that calls `require('')` from a context where `` is not resolved inside the application bundle. This catalog files the shape as [search-walks-to-user-writable](/patterns/search-walks-to-user-writable), the recurring class where a hierarchical name resolver walks past a trust boundary the deployment platform draws in a different place than the algorithm's authoring platform did. Discord is the first exhibit. It will not be the last.\n\nPoC: [0x18F/CVE-2026-0776](https://github.com/0x18F/CVE-2026-0776)","closing_line":"The resolver walked rootward looking for a `node_modules` nobody had created yet. A standard user created one.","hook_md":"Discord 1.0.9196 calls `require('utf-8-validate')` from inside its Electron bundle, transitively through `ws`. Node.js's CommonJS resolver walks rootward from the loader's directory, emits one candidate `node_modules\\` path at each parent, and terminates at the drive root. The list ends with `C:\\node_modules\\utf-8-validate.js`. Trend Micro's PoC for CVE-2026-0776 (ZDI-CAN-27057) is a three-line JavaScript file placed at that path by a standard user who needed no privileges to put it there. On Unix the rootward search terminates at a node the user does not own. On Windows it terminates at a node the user does.","post_id":626,"slug":"discord-cve-2026-0776-node-walks-to-c-node-modules","title":"CVE-2026-0776: Discord 1.0.9196's `require()` Walks Rootward To `C:\\node_modules\\`. Every Standard User Can Write There.","type":"initial","unreadable_sentence":"On Unix the rootward search terminates at a node the user does not own. On Windows it terminates at a node the user does."}
-----BEGIN PGP SIGNATURE-----
iHUEARYIAB0WIQRf0htP5+SjynlxywneZjl4jgkQJgUCateh/QAKCRDeZjl4jgkQ
JldKAQDsADbfoW30w6Nf6W4vziRysJlvtLHHAyyn9CgSqx5sdgEAidUou8iPeB6m
kZ5RJ/EfF1BHB/zqNCIOGYprm/oGqAA=
=pVs4
-----END PGP SIGNATURE-----