Summary
Navi through version 2.24.0 does not properly escape cheatsheet variable values before substituting them into shell commands. An attacker who can place crafted file names in suggestion command directories may inject shell metacharacters and execute commands with the privileges of the victim running Navi.
Affected context
The vulnerability occurs in Navi's cheatsheet suggestion workflow when file names from configured suggestion command directories are incorporated into shell command strings. Risk depends on whether an attacker can create or influence files in those directories and whether a victim subsequently invokes the affected suggestion functionality.
Exploit preconditions
- Attack surface: Navi cheatsheet suggestion and command-substitution logic
- Required access: Ability to create or control a file name in a suggestion command directory
- Trigger point: Processing a matching suggestion and substituting its file name into a shell command
- Why exploitation is possible: File-name values are not sufficiently escaped before being interpreted by a shell
- Execution context: Injected commands run with the privileges of the user operating Navi
Why this happens
The underlying bug is an OS command injection caused by combining attacker-influenced file-name data with shell command text without applying context-appropriate escaping or avoiding shell interpretation. Shell metacharacters in the substituted value can therefore alter command parsing, which maps to CWE-78, Improper Neutralization of Special Elements used in an OS Command.
Potential impact
- An attacker may execute arbitrary commands as the victim user.
- Local files and environment data could be accessed or modified.
- User-level credentials or tokens could be exposed.
- The affected workstation or development environment could be further compromised.
- Commands could alter project files or other user-controlled resources.
General mitigation guidance
Mitigation generally focuses on removing shell interpretation from
attacker-influenced data and reducing trust in file names.
Common defensive patterns include:
- Prefer direct process-execution APIs with argument arrays rather than constructing shell command strings.
- Apply strict, context-aware validation when file names must enter command-related workflows.
- Treat directory contents and file names as untrusted input, even when they are locally sourced.
- Restrict write access to suggestion command directories and separate trusted content from user-controlled content.
- Run the application with the minimum filesystem and process privileges required.
- Use allowlists for supported commands and enforce security checks before substitution or execution.
How teams detect issues like this
Detection approaches may include:
- Static analysis rules for shell command construction using file names or other external strings.
- Code review checks for string concatenation, interpolation, or template substitution followed by shell execution.
- Tests using shell metacharacters in file names to verify that values remain data rather than commands.
- Repository and filesystem policies limiting who can write to directories consumed by suggestion features.
- Runtime monitoring for unexpected child processes launched by Navi or unusual command activity.
Automated code review and software composition analysis tools may help identify related command-injection patterns.

