---
title: "OpenHands 1.5.0 still executes the branch name its own fix left unquoted"
slug: openhands-branch-name-command-injection
draft: false
date: "2026-11-24"
datetime: "2026-11-24T06:36:19Z"
updated: "2026-11-24"
description: "CVE-2026-33718’s fix quoted the caller’s path and the git show argument. The repository’s own branch name is still interpolated into a shell=True command in the same handler, on the version the…"
abstract: >-
  OpenHands’ Git diff handler builds shell strings. The fix for CVE-2026-33718 (GHSA-7h8w-hj9j-8rjw) quoted the caller’s path at git_handler.py:141 and the ref:path argument of git show in the new `_make_git_show_cmd`, and it left `git --no-pager rev-parse --verify {ref}` at git_diff.py:76 interpolated with shell=True. `ref` is `origin/<current branch>`, and git permits `;`, `"`, `>` and `#` in a ref name. We executed the released 1.5.0 sdist, the version the advisory calls patched, and 1.6.0: a branch named `main;id>"/tmp/oh-branch-marker";#` writes its marker while `get_git_diff()` returns a normal diff and `get_git_changes()` a normal change list. A clean branch and the advisory’s own path payload produce no marker. The handler is gone from 1.7.0, removed with the V0 runtime; the input ends there by removal, not by a quoting change.
authors:
  - name: EZO Labs Security
    url: https://ezolabs.net
section: environments
report_number: EZO-R-2026-13
lang: en
og:
  kicker: "EZO LABS // SECURITY"
  title:
    - "OpenHands 1.5.0 still"
    - "executes the branch name its"
    - "own fix left unquoted"
  foot:
    - "An independent write-up."
    - "Notes from the disclosure."
bibtex_key: openhandsbranchnamecommandinjection
revisions:
  - date: "2026-11-24"
    note: "First publication."
license: cc-by-4.0
---

## Summary

The published advisory names 1.5.0 as the patched release. On 1.5.0, the branch name the same handler reads is still a shell fragment.

## The gap

The repository’s own branch name is interpolated into a `shell=True` command, so a branch named `main;id>"/tmp/x";#` executes a second command while `get_git_diff()` returns a normal diff.

- `openhands/runtime/utils/git_diff.py:49-50, 76`: `get_valid_ref()` reads the repository’s branch name and interpolates `f'origin/{current_branch}'` into `run(f'git --no-pager rev-parse --verify {ref}', repo_dir)`.
- `openhands/runtime/utils/git_diff.py:35`: `run()` is `subprocess.run(args=cmd, shell=True)`.
- `openhands/runtime/utils/git_changes.py:36-37, 63, 81`: The sibling script repeats the same interpolation and `shell=True` pattern.
- `openhands/runtime/utils/git_handler.py:141`: The 1.5.0 fix quotes the caller’s `path` here and the `ref:path` argument at `git_diff.py:85-87`; it does not touch `git_changes.py` or the branch interpolation at `git_diff.py:76`.

## Reproduction

The PyPI sdists were loaded verbatim (1.5.0 sha256 `f056b253…`, 1.6.0 sha256 `883a5bc5…`); `GitHandler` and the scripts were run with the runtime’s `subprocess.run(args=cmd, shell=True)`; a `git` wrapper logged the argv git received.

With branch `main;id>"/tmp/oh-branch-marker";#`, `get_git_diff('victim.txt')` returns the normal two-line diff, exit 0, and writes the marker (sha256 `6e03bce1…`). The same branch through `get_git_changes()` returns `[{"status":"M","path":"victim.txt"}]` and writes the marker. 1.6.0 behaves identically; its three handler files are byte-identical to 1.5.0’s.

## Impact

A repository whose branch name contains shell metacharacters executes a command of the branch author’s choosing in the OpenHands runtime when a diff or change list is requested. The caller sees a normal diff; the second command runs silently.

## Affected versions

`openhands-ai` 1.5.0 and 1.6.0 ship the advisory’s named fix, and they are the two we executed; every earlier release that carries the same legacy runtime is affected too, and the unquoted interpolation is present in the 1.0.0, 1.1.0, 1.2.0, 1.2.1, 1.3.0 and 1.4.0 trees we read. `1.7.0` and later do not contain the handler. The advisory’s published range (`affected <= 1.4.0 / patched 1.5.0`) does not describe this input.

## Fix status

Quote the ref at `git_diff.py:76` and `git_changes.py:63`, or build the argv as a list and drop `shell=True`. The published 1.5.0 fix did not do this. No release quotes the branch name; 1.7.0 ends the input by deleting the handler.

## The vendor’s record

No vendor reply since the advisory was filed on 2026-10-30. The published `GHSA-7h8w-hj9j-8rjw` is the authority for the class; the finding is the same handler’s other shell input, which the fix’s own remediation note (“proper argument array handling or rigorous path sanitization … to prevent command chaining”) covers.

## Timeline

- 2026-10-30T18:51:38Z: Private report filed (`GHSA-wpxp-rv65-2h3j`)
- 2026-11-11T20:36:07Z: Publication ask posted (comment 369525)
- 2026-11-11T23:21:37Z: Class-anchored follow-up posted (comment 369706)
- 2026-11-12: Notice naming 2026-11-17T16:00Z as the planned publication
- 2026-11-24T06:36:19Z: This write-up published
- 2026-11-24: MITRE CNA-LR request submitted

## References

- Command Injection in Git Diff Handler: https://github.com/OpenHands/OpenHands/security/advisories/GHSA-7h8w-hj9j-8rjw
- Private report: https://github.com/OpenHands/OpenHands/security/advisories/GHSA-wpxp-rv65-2h3j

## Disclosure

This note is an independent write-up. It is published on 2026-11-24 as the public reference for a CVE request. The private advisory and this write-up describe the same defect; the vendor advisory named above is the authority where one exists.
