Workspace confirmation emits the raw working directory to the terminal #82

Open
opened 2026-11-21 19:09:18 +01:00 by motoko · 0 comments
Collaborator

What

bin/azkaban builds the default-workspace confirmation with the raw
working directory (bin/azkaban:248 at 01e9109):

if ! IFS= read -r -p "No directory specified. Use current directory (${current_directory})? [Y/n] " answer; then

read -p writes the prompt to the terminal, and the terminal interprets
escape sequences inside it. Nothing bounds the displayed
current_directory to printable characters.

Scenario

A tool the user runs — unpacking an archive, a clone, a generated cache
— creates a directory whose name carries terminal control bytes, e.g.
mkdir $'proj\e]0;PWNED\a'. Launching azkaban codex from inside it
with no workspace argument prints the confirmation and emits the name
verbatim, so the crafted name writes to the terminal: it can rewrite the
window title, or inject text into the terminal's stream through the
connected terminal's escape protocol.

Severity is low: it needs the user to start a client interactively in a
crafted directory, and the target is the user's own terminal.

Smallest fix

Bound the value shown in the prompt to printable characters, keeping the
untouched path for everything else. The display is only ever printed,
while the workspace choice uses the real current_directory:

display="${current_directory//[^[:print:]]/?}"

and interpolate display in the prompt only.

Scope

The launcher's other confirmations interpolate only a tag validated
against ^[a-z0-9]+([._-][a-z0-9]+)*$ and the literal
Dockerfile.<client> names, so they do not reach this.

Seen at 01e9109 while security-reviewing #81; the prompt predates that
change and the finding is outside it.

## What `bin/azkaban` builds the default-workspace confirmation with the raw working directory (`bin/azkaban:248` at `01e9109`): ```bash if ! IFS= read -r -p "No directory specified. Use current directory (${current_directory})? [Y/n] " answer; then ``` `read -p` writes the prompt to the terminal, and the terminal interprets escape sequences inside it. Nothing bounds the displayed `current_directory` to printable characters. ## Scenario A tool the user runs — unpacking an archive, a clone, a generated cache — creates a directory whose name carries terminal control bytes, e.g. `mkdir $'proj\e]0;PWNED\a'`. Launching `azkaban codex` from inside it with no workspace argument prints the confirmation and emits the name verbatim, so the crafted name writes to the terminal: it can rewrite the window title, or inject text into the terminal's stream through the connected terminal's escape protocol. Severity is low: it needs the user to start a client interactively in a crafted directory, and the target is the user's own terminal. ## Smallest fix Bound the value shown in the prompt to printable characters, keeping the untouched path for everything else. The display is only ever printed, while the workspace choice uses the real `current_directory`: ```bash display="${current_directory//[^[:print:]]/?}" ``` and interpolate `display` in the prompt only. ## Scope The launcher's other confirmations interpolate only a tag validated against `^[a-z0-9]+([._-][a-z0-9]+)*$` and the literal `Dockerfile.<client>` names, so they do not reach this. Seen at `01e9109` while security-reviewing #81; the prompt predates that change and the finding is outside it.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
claudiomaradonna/azkaban#82
No description provided.