Skip to content

GHSA-fwjx-9p69-h25h CVE-2026-73506 GO-2026-6111

Oh My Posh: Terminal escape sequence injection via unsanitized prompt segment data

Medium Go
Severity
6.1 / 10
Medium · CVSS 3.1
Exploit chance (EPSS)
0.18%
Chance of exploitation in the next 30 days. Higher than 7.46% of scored vulnerabilities.
Known exploited
No
Not in CISA's catalog
Weakness
CWE-150 Improper Neutralization of Escape, Meta, or Control Sequences
Fix
29.35.1
Upgrade github.com/jandedobbeleer/oh-my-posh to this version or later

Description

Summary

Oh My Posh renders dynamic, potentially attacker-controlled strings (the current directory name, Git commit metadata, environment variable values, command output) into the prompt without neutralizing raw terminal control characters. An attacker who controls one of these values can inject ANSI/OSC escape sequences that the victim's terminal executes on every prompt render. (This is separate from the path-segment command-execution report; it has a different root cause and fix.)

Details

src/terminal/writer.go, write(s rune): the literal characters of rendered segment content are emitted to the output buffer, and the only neutralization is a lookup in formats.EscapeSequences, which per shell contains only the shell's prompt-length markers (\ for bash, % for zsh, nothing for fish/pwsh/cmd/nu). Raw C0/C1 control bytes (ESC 0x1b, BEL 0x07, CSI, OSC) are written verbatim.

Oh My Posh's own styling is emitted through separate paths (writeEscapedAnsiString, writeColorise, builder.WriteString(formats.Hyperlink...)), so any control rune reaching write(s rune) originates from rendered data. trimAnsi is already applied to the console title (FormatTitle) but not to the prompt body.

Attacker-controlled sources (both verified)

  1. Current directory name (default config, Linux/macOS). Directory names may contain any byte except / and NUL, including 0x1b. The path segment renders the working directory in every theme.
  2. Git commit subject / author / upstream URL (cross-platform, including Windows). Git.Commit() runs git log -1 --pretty=format:...su:%s... and exposes .Commit.Subject, .Commit.Author.Name/.Email and .RawUpstreamURL; Git imposes no restriction on these, so they can carry raw escape sequences.

PoC

Git commit-subject vector (config: a single git segment with template {{ .Commit.Subject }}):

printf 'feat: \033]0;HACKED\007\033]52;c;ZWNobyBQV05FRA==\007 update' > msg.txt
git commit --allow-empty -F msg.txt
oh-my-posh print primary --config poc.omp.json --shell fish | xxd

Output (excerpt) shows the attacker's OSC 0 (set title) and OSC 52 (clipboard write) passed through unmodified, wrapped only in Oh My Posh's colors:

...255m feat: 1b5d 303b 4841 434b 4544 07 1b5d 3532 3b63 3b5a 574e ... 07 ...
              ESC ] 0 ; H A C K E D  BEL  ESC ] 5 2 ; c ; <base64>  BEL

The directory-name vector reproduces identically via the path segment.

Impact

The terminal interprets the injected sequences on every render, enabling, per emulator: clipboard hijacking (OSC 52 write, so a command placed in the clipboard runs when the victim pastes), prompt/screen spoofing, window-title manipulation, and terminal denial of service. Delivery is remote (repo/archive/share); execution is local when the prompt renders after cd.

Suggested fix: neutralize C0/C1 control characters in untrusted segment data before it reaches the terminal, at minimum the path segment (folder names) and the git segment (Commit.Subject, Commit.Author.*, RawUpstreamURL). trimAnsi already exists and is applied to the title; extending equivalent handling to segment data closes the gap. Filtering control runes in write(s rune) would also work as defense in depth (Oh My Posh's own styling never flows through that function), optionally behind an opt-out for users who deliberately embed escapes in their own templates.

Affected versions

Go

PackageVulnerableFixed in
github.com/jandedobbeleer/oh-my-posh
< 29.35.1
29.35.1
github.com/jandedobbeleer/oh-my-posh
< 29.35.1+incompatible
29.35.1+incompatible

How to fix

Move to the fixed version or later with your package manager, update the lockfile, and run your tests. If the package only arrives through another dependency, upgrade that dependency first. If none of its releases pulls a fixed version yet, force the version with your package manager's override.

github.com/jandedobbeleer/oh-my-posh Go → 29.35.1

go
go get github.com/jandedobbeleer/oh-my-posh@v29.35.1 && go mod tidy

Severity breakdown

CVSS 3.1 6.1

CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:L

Attack vector
Local
Attack complexity
Low
Privileges required
None
User interaction
Required
Scope
Changed
Confidentiality
Low
Integrity
Low
Availability
Low

Weakness

CWE-150: Improper Neutralization of Escape, Meta, or Control Sequences

The product receives input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could be interpreted as escape, meta, or control character sequences when they are sent to a downstream component.

How to prevent it
  • Developers should anticipate that escape, meta and control characters/sequences will be injected/removed/manipulated in the input vectors of their product. Use an appropriate combination of denylists and allowlists to ensure only valid, expected and appropriate input is processed by the system.
  • Implementation: Assume all input is malicious. Use an "accept known good" input validation strategy, i.e., use a list of acceptable inputs that strictly conform to specifications. Reject any input that does not strictly conform to specifications, or transform it into something that does. When performing input validation, consider all potentially relevant properties, including length, type of input, the full range of acceptable values, missing or extra inputs, syntax, consistency across related fields, and conformance to business rules. As an example of business rule logic, "boat" may be syntactically valid because it only contains alphanumeric characters, but it is not valid if the input is only expected to contain colors such as "red" or "blue." Do not rely exclusively on looking for malicious or malformed inputs. This is likely to miss at least one undesirable input, especially if the code's environment changes. This can give attackers enough room to bypass the intended validation. However, denylists can be useful for detecting potential attacks or determining which inputs are so malformed that they should be rejected outright.
  • Implementation: While it is risky to use dynamically-generated query strings, code, or commands that mix control and data together, sometimes it may be unavoidable. Properly quote arguments and escape any special characters within those arguments. The most conservative approach is to escape or filter all characters that do not pass an extremely strict allowlist (such as everything that is not alphanumeric or white space). If some special characters are still needed, such as white space, wrap each argument in quotes after the escaping/filtering step. Be careful of argument injection (CWE-88).
  • Implementation: Inputs should be decoded and canonicalized to the application's current internal representation before being validated (CWE-180). Make sure that the application does not decode the same input twice (CWE-174). Such errors could be used to bypass allowlist validation schemes by introducing dangerous inputs after they have been checked.
  • Implementation: When using output from an LLM, neutralize or strip escape codes before redirecting output to the terminal or other rendering engine that would process the codes. The neutralization could require that the character be printable and/or allowable whitespace, such as a carriage return or newline. Be deliberate about what to allow.
  • Build and Compilation: When using an LLM: during tokenizer training, suppress escape codes from the tokenizer's vocabulary. Depending on context, this could be accomplished by removing the codes from input to the tokenizer, or removing the map from the string to its token ID. It is generally unlikely that this removal would adversely affect the quality or correctness of what is generated, e.g. advice requests for terminal settings to change colors.

References

Timeline

  1. Published
  2. Last updated by the source
  3. Latest EPSS score
AdvisorySeverityWhy it's related
GHSA-4hmj-39m8-jwc7
OpenClaw has ACP CLI approval prompt ANSI escape sequence injection
Medium Same weakness, CWE-150
GO-2026-5067
Mattermost allows attackers to manipulate administrator terminals via crafted messages containing ANSI and OSC escape sequences
High Same weakness, CWE-150
GHSA-vfww-5hm6-hx2j
Apache Tomcat Vulnerable to Improper Neutralization of Escape, Meta, or Control Sequences
Critical Same weakness, CWE-150
GHSA-76r7-hhxj-r776
Active Record logging vulnerable to ANSI escape injection
Medium Same weakness, CWE-150
GHSA-ff77-26x5-69cr
Apache Tomcat Rewrite rule bypass
Critical Same weakness, CWE-150
GHSA-88g2-r9rw-g55h
gitoxide-core does not neutralize special characters for terminals
Low Same weakness, CWE-150
GHSA-m4pq-fv2w-6hrw
Deno's deno_runtime vulnerable to interactive permission prompt spoofing via improper ANSI stripping
Medium Same weakness, CWE-150
GHSA-vq67-rp93-65qf
Interactive `run` permission prompt spoofing via improper ANSI neutralization
High Same weakness, CWE-150
Is this in your code?

MergeHarbor checks every repository's dependencies against this database, ranks what matters by exploitability and reachability, routes it to the owning team and opens the fix pull request.

Check your repos with MergeHarbor