Summary
The togglex plugin in Jarun nnn uses crafted filenames in a shell command, which may allow command injection. If an attacker can place a suitably named file where the plugin processes it and a user invokes the plugin, injected commands may run with that user's privileges.
Affected context
The issue is described in the plugins/togglex plugin in Jarun nnn through version 5.3. It arises when filenames are passed through xargs -I into a script executed by sh -c. Risk depends on whether an attacker can introduce files into a location processed by the plugin and whether a user runs it in that environment.
Exploit preconditions
- Attack surface: The
togglexplugin's processing of filenames - Required access: Ability to place or influence a filename in a location the plugin processes
- Trigger point: A user invokes
togglexwhile the crafted filename is in scope - Why exploitation is possible: Filename content is inserted into a shell command that is interpreted by
sh
Why this happens
The plugin constructs a shell script using filename data and executes it through sh -c. Treating filenames as shell syntax rather than data creates an OS command injection weakness, mapped to CWE-78: Improper Neutralization of Special Elements used in an OS Command.
Potential impact
- An attacker may execute commands with the privileges of the user running the plugin.
- Commands could access or modify files available to that user.
- The affected user's account or workflows could be compromised.
- Further impact may be possible depending on the user's permissions and environment.
General mitigation guidance
Defensive approaches focus on keeping filenames out of shell-interpreted command strings.
- Prefer direct process execution APIs that pass arguments separately rather than invoking a shell.
- Treat filenames as untrusted data, regardless of their origin.
- Where shell execution cannot be avoided, use robust argument handling and avoid constructing scripts through string substitution.
- Apply least privilege to the account running the plugin and limit who can create files in processed locations.
How teams detect issues like this
- Use static analysis to identify shell execution APIs, especially
sh -c, combined with interpolated or substituted data. - Review plugin code for
xargssubstitutions or other patterns that place filenames into command strings. - Add code review checks and CI policies that discourage shell invocation when direct process APIs are available.
- Where appropriate, use automated code review tools to flag potentially unsafe command construction.

