Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/term-commands/agents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,8 @@ async function launchTmuxSpawn(ctx: SpawnCtx): Promise<void> {

let paneId: string;
try {
const splitCmd = `tmux split-window -d ${splitTarget} -P -F '#{pane_id}' ${ctx.fullCommand}`;
const cwdFlag = ctx.cwd ? `-c '${ctx.cwd}'` : '';

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

security-critical critical

The ctx.cwd variable is used to construct a shell command without proper escaping, which can lead to a command injection vulnerability. If ctx.cwd contains special shell characters like a single quote, it can break the command or allow arbitrary code execution. Please escape ctx.cwd to prevent this. A similar escaping pattern is used in src/lib/tmux.ts.

Suggested change
const cwdFlag = ctx.cwd ? `-c '${ctx.cwd}'` : '';
const cwdFlag = ctx.cwd ? `-c '${ctx.cwd.replace(/'/g, "'\\''")}'` : '';

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Escape cwd when building tmux split command

Building cwdFlag as -c '${ctx.cwd}' injects an unescaped path into a shell command passed to execSync, so any --cwd (or resolved repo path) containing a single quote will break parsing (e.g., o'connor) and can also introduce shell-injection risk if the value is attacker-controlled. This makes genie spawn fail for valid filesystem paths in those environments; use argument-based process APIs or robust shell escaping for ctx.cwd before interpolation.

Useful? React with 👍 / 👎.

const splitCmd = `tmux split-window -d ${splitTarget} ${cwdFlag} -P -F '#{pane_id}' ${ctx.fullCommand}`;
paneId = execSync(splitCmd, { encoding: 'utf-8' }).trim();
} catch (err) {
console.error(`Failed to create tmux pane: ${err instanceof Error ? err.message : 'unknown error'}`);
Expand Down
Loading