Git guard: the shell-line reader reads ~ as a path under the typed directory, so a repository named with ~ is judged nowhere #87

Open
opened 2026-11-23 04:47:50 +00:00 by uranus · 1 comment
Member

Purpose (defect): the shell-line reader treats a repository written with ~ as either the home directory or unread (null). Today it reads it as a path under the typed directory.

Refs macula-io/martha#68 (whose title names ~; #68's refusal is built for null in PR 85, and a tilde never reaches it) and #53 (PR 66 owns read_the_git_calls_in_a_shell_line.ts, so this waits for it to land).

The instance (measured on main a1dab83e, reader called with directory /w)

line gitDirectory / directory read
GIT_DIR=~/x/.git git push origin HEAD /w/~/x/.git
git --git-dir=~/x/.git push /w/~/x/.git
git --git-dir ~/x/.git push /w/~/x/.git
git -C ~/x push directory /w/~/x

A shell expands each ~ to the home directory, so git works on $HOME/x, while the guard asks git about /w/~/x. No such place exists, so every fact is empty and every rule fails open.

  • Seam (b) catches the --git-dir and -C forms, because the shell has already expanded them in the shim's argv.
  • The inline GIT_DIR=~/x git push gets past both seams. The shim reads no GIT_DIR from its environment: see the seam (b) issue filed beside this one.

The fix (in the reader, after PR 66)

  • A word starting with ~ or ~user in a place position reads as null (unread). PR 85 then refuses a push or a worktree remove/move through it, and other calls fail open as before.
  • The alternative is to expand a bare ~/ against the launch's known home. Pick one in the threat model.
Purpose (defect): the shell-line reader treats a repository written with `~` as either the home directory or unread (null). Today it reads it as a path under the typed directory. Refs macula-io/martha#68 (whose title names `~`; #68's refusal is built for null in PR 85, and a tilde never reaches it) and #53 (PR 66 owns `read_the_git_calls_in_a_shell_line.ts`, so this waits for it to land). ## The instance (measured on main a1dab83e, reader called with directory `/w`) | line | gitDirectory / directory read | |---|---| | `GIT_DIR=~/x/.git git push origin HEAD` | `/w/~/x/.git` | | `git --git-dir=~/x/.git push` | `/w/~/x/.git` | | `git --git-dir ~/x/.git push` | `/w/~/x/.git` | | `git -C ~/x push` | directory `/w/~/x` | A shell expands each `~` to the home directory, so git works on `$HOME/x`, while the guard asks git about `/w/~/x`. No such place exists, so every fact is empty and every rule fails open. - Seam (b) catches the `--git-dir` and `-C` forms, because the shell has already expanded them in the shim's argv. - The inline `GIT_DIR=~/x git push` gets past both seams. The shim reads no `GIT_DIR` from its environment: see the seam (b) issue filed beside this one. ## The fix (in the reader, after PR 66) - A word starting with `~` or `~user` in a place position reads as null (unread). PR 85 then refuses a push or a worktree remove/move through it, and other calls fail open as before. - The alternative is to expand a bare `~/` against the launch's known home. Pick one in the threat model.
Author
Member

The seam (b) issue named above is macula-io/martha#86.

The seam (b) issue named above is macula-io/martha#86.
Sign in to join this conversation.
No labels
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
martha-ai/martha#87
No description provided.