Summary
A command injection flaw in Notepad++ allows attacker-controlled entries in shortcuts.xml to be executed directly via the Run menu without validation.
If an attacker can modify the <Command> tag within <UserDefinedCommands>, they can run arbitrary executables or scripts when the user triggers the corresponding menu item, enabling stealthy persistence on the system.
Affected context
This vulnerability occurs when Notepad++ loads user-defined commands from the shortcuts.xml configuration file and exposes them through the Run menu.
It is relevant in environments where shortcuts.xml can be modified by local users, malware, or other processes, and where Notepad++ is routinely used with the Run menu.
The risk is higher on systems where the application is executed with elevated or highly trusted user privileges and configuration files are not integrity-protected.
Exploit preconditions
- Attack surface: Local desktop environment via Notepad++ configuration (shortcuts.xml)
- Required access: Ability to write or tamper with the <UserDefinedCommands> section, specifically the <Command> tag text in shortcuts.xml
- Trigger point: A user clicks the crafted Run menu entry or otherwise invokes the associated user-defined command from within Notepad++
- Why exploitation is possible: Notepad++ reads the command text from XML and passes it directly to ShellExecute without validation, sanitization, or restriction, allowing arbitrary command execution.
Why this happens
The root cause maps to CWE-78 (OS Command Injection): user-controlled input is passed as a command or executable path to an operating system launcher API without sufficient validation or constraints.
Notepad++ parses the <Command> text from shortcuts.xml into UserCommand._cmd and later calls ShellExecute on this value, implicitly trusting configuration content as safe commands.
This design treats external configuration as trusted instructions, failing to restrict allowable paths, arguments, or execution targets, which enables arbitrary OS-level command execution when a malicious entry is clicked.
Potential impact
- Malicious commands may be executed in the context of the Notepad++ user.
- Attackers could establish persistence via benign-looking Run menu items.
- Local malware or adversaries could launch further payloads or tools silently.
- Sensitive data could be exfiltrated or modified by executed scripts or binaries.
- System integrity can be degraded if commands are run with elevated privileges.
General mitigation guidance
Effective mitigation focuses on reducing trust in configuration-driven commands and restricting what can be executed from within the application.
Pattern-based approaches include:
- Constraining Run menu entries to a curated set of allowed executables or command templates, rather than arbitrary strings from configuration.
- Validating and normalizing command paths from shortcuts.xml, rejecting entries that include unexpected arguments, special characters, or non-whitelisted locations.
- Treating configuration files as untrusted input by applying strict parsing rules, schema validation, and limiting the scope of what user-defined commands can do.
- Reducing the privileges under which Notepad++ runs, so that any executed commands inherit a low-privilege context.
- Providing secure-by-default settings that disable or limit user-defined commands unless explicitly enabled in a controlled manner.
How teams detect issues like this
High-level detection can rely on a mix of configuration review and behavioral analysis:
- Static analysis or configuration scanners that flag applications passing configuration-derived strings into ShellExecute or similar OS command APIs.
- Code review practices that look for direct use of OS execution functions wired to user or configuration inputs, and require validation or whitelisting layers.
- Policy enforcement around desktop applications that restrict arbitrary command execution features, especially those sourced from easily writable configuration files.
- Monitoring shortcuts.xml and similar files for unexpected changes, especially additions of new <UserDefinedCommands> pointing to suspicious executables or script interpreters.
- Endpoint security tools can alert on unusual process trees where Notepad++ spawns shells, interpreters, or administrative utilities.

