# GHSA-MGQC-MQJP-6V7Q: x/ansi: DecodeSequence crashes on an oversized CSI or DCS sequence, resulting in a panic

- Database: GitHub
- Severity: CVSS 8.7 (High)
- Published: 2026-11-25
- Modified: 2026-11-25

## Affected versions

- github.com/charmbracelet/x/ansi (Go): from 0.2.0, fixed in 0.11.10
- charm.land/wish/v2 (Go): from 2.0.0, fixed in 2.0.6
- charm.land/bubbletea/v2 (Go): from 2.0.0, fixed in 2.1.3

## Description

### Summary

A terminal control sequence with too many parameters makes `DecodeSequence` panic. On Wish v2, that happens only after a session is open, and only if that session runs Bubble Tea. The in-process Bubble Tea middleware takes down the whole Wish process. `wish/recover` does not stop it. Starting Bubble Tea with `wish.Command` (a PTY or a plain pipe) crashes that child program and leaves the Wish process running.

### Details

`github.com/charmbracelet/x/ansi.DecodeSequence` stores CSI and DCS parameters in a fixed buffer, 32 entries by default. Extra parameters are supposed to be ignored. This function does not check the buffer size, so one more parameter panics.

Wish itself does not parse those sequences. The panic happens only when the open session is a Bubble Tea v2 program, which runs this decoder on every input byte.

Two ways of hosting that program behave differently:

- **Bubble Tea middleware**, in the Wish process. The decoder runs on a background goroutine. `wish/recover` only wraps the session goroutine, so it never sees this panic. The Wish process exits, and every other session on it dies with it. Checked with the middleware wrapped by `recover.Middleware()`: the process still exits with status 2.
- **`wish.Command`**, as a separate program. With a real PTY, or with no PTY so the SSH session is piped to the program's standard input, the same sequence panics the child. The Wish process stays up and still accepts new connections.

A session that only copies bytes, and does not run Bubble Tea, does not panic.

The bytes are read only after the SSH session has started. A wrong password or key is rejected at login and never reaches the decoder. A server with no authentication starts that session for any client.

### Proof of concept

Open a session on a Wish v2 server that serves Bubble Tea, then send a CSI or DCS sequence with more than 32 parameters.

- No authentication: any client can do this as soon as the session starts. The middleware server process exits.
- Password or public-key authentication: a failed login does nothing. After a successful login, the same sequence crashes the middleware server.
- `wish/recover` around the middleware does not change that.
- The same sequence against `wish.Command` running a Bubble Tea program crashes that program and leaves the Wish process running. This is true both when the command is attached to a PTY and when the session is piped to it with no PTY.

A normal short escape sequence does not crash either setup.

The below set of bash commands produces an 83-byte sequence that results in a panic. Adjust the port and user as necessary:

```bash
params=$(printf '1;%.0s' {1..40})
payload=$(printf '\033[%su' "$params")
{ sleep 0.5; printf '%s' "$payload"; sleep 0.5; } | ssh -tt -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o PreferredAuthentications=none -o BatchMode=yes -p 2222 probe@127.0.0.1
```

### Impact

Denial of service against the Bubble Tea session. With the in-process middleware, one session crashes the entire Wish process. On a server with no authentication, that is unauthenticated and remote. On a server that requires a key or password, the client must log in first. There is no memory corruption and no data leak.

If the server requires a key or password, privileges become **Low** and the **CVSS 4.0 score drops to 7.1 (PR:L)**.

With `wish.Command`, only that user's program exits. Other sessions keep running.

## References

- https://github.com/charmbracelet/wish/security/advisories/GHSA-mgqc-mqjp-6v7q

Page: https://cve.now/GHSA-MGQC-MQJP-6V7Q

Wrong or missing data? Send feedback: POST https://cve.now/api/v1/feedback (see https://cve.now/agents#feedback).
