| Title | https://github.com/Anil-matcha/ open-duet commit 7684521 Protection Mechanism Failure |
|---|
| Description | Newline in a Bash command bypasses the git risk classifier, auto-approving a hidden git push
Affected versions: confirmed on commit 76845213b104816799fa465225b3962054070032.
## Summary
`classify_bash_command` in `backend/app/services/github_classifier.py` only splits a Bash command on `&&`, `;`, and `|` before looking for the riskiest git verb in it. A command joined by a literal newline instead (e.g. a command whose text is `git status` followed by a newline then `git push origin --force main`) is parsed by `shlex.split` as one token stream, and `_git_verb` returns only the first verb it finds (`status`), so the whole command is classified `(read, github, git.status)` even though it also contains a `push`. This classification feeds directly into the live `PermissionRequest` hook endpoint that approves or denies the Bash tool call before the Claude CLI executes it, so a standing "always allow" rule for ordinary `git status` calls silently auto-approves a hidden `git push` riding along in the same command.
## Details
`backend/app/routers/permission.py` exposes `POST /permissions/check/{user_id}/{task_id}`, the live `PermissionRequest` hook the Claude CLI calls before every tool call it would otherwise ask a person about:
```python
def _classify(tool_name: str, body: dict) -> tuple[str, str | None, str | None]:
if tool_name == "Bash":
command = body.get("tool_input", {}).get("command", "")
classified = classify_bash_command(command)
if classified is not None:
return classified
return TOOL_BUCKETS.get(tool_name, "system"), None, None
```
`classify_bash_command` in `backend/app/services/github_classifier.py`:
```python
_SEGMENT_SPLIT_RE = re.compile(r"&&|;|\|")
def classify_bash_command(command: str) -> tuple[str, str, str] | None:
bucket: str | None = None
matched_verb: str | None = None
for segment in _SEGMENT_SPLIT_RE.split(command):
try:
tokens = shlex.split(segment)
except ValueError:
continue
verb = _git_verb(tokens)
if verb is None:
continue
if verb in _PUBLISH_VERBS:
candidate = "publish"
elif verb in _READ_VERBS:
candidate = "create"
if bucket is None or _BUCKET_RANK[candidate] >= _BUCKET_RANK[bucket]:
bucket = candidate
matched_verb = verb
if matched_verb is None:
return None
return bucket, "github", f"git.{matched_verb}"
```
and `_git_verb`:
```python
def _git_verb(tokens: list[str]) -> str | None:
if not tokens or tokens[0] != "git":
return None
i = 1
while i < len(tokens):
token = tokens[i]
if token.startswith("-"):
i += 2 if token in _GLOBAL_FLAGS_WITH_SEPARATE_VALUE else 1
continue
return token
return None
```
`_SEGMENT_SPLIT_RE` does not include `\n`. A command string containing a literal newline is passed to `shlex.split` as a single segment, since `shlex.split` treats `\n` as ordinary whitespace between tokens, same as a space. For a command whose text is `git status` then a newline then `git push origin --force main`, that single `shlex.split` call yields `['git', 'status', 'git', 'push', 'origin', '--force', 'main']`. `_git_verb` sees `tokens[0] == 'git'` and returns the very next non-flag token, `status`, as the verb for the whole segment, never noticing the second `git push` further along in the same token list.
The resulting `(bucket="read", connector="github", tool="git.status")` is looked up against the user's `PermissionRule` table. Any standing "always allow" rule the user created for that exact triple, by once approving a plain `git status` call with "always" in the approval UI, now resolves this compound command to `allow` with no prompt.
## Steps To Reproduce
(available upon request)
## Impact
A user who has ever approved a single ordinary `git status` (or any other read-bucket git verb) with "always allow" is exposed to any later Bash tool call whose command text chains that same read-only verb with a destructive one (`push`, or any other git mutation) using a newline instead of `;`, `&&`, or `|`. Such a call auto-approves with no prompt, executing the destructive action as if the user had approved it, with no record in the approval history that a push occurred. Since Bash tool calls in this app originate from an LLM agent's own generated commands, this is directly reachable by prompt injection: content the agent reads from an untrusted source can instruct it to emit a newline-joined command, silently escalating a narrow, previously-granted read permission into an unattended `git push` (including a forced push or a push to an unintended remote/branch).
|
|---|
| Source | ⚠️ https://github.com/Anil-matcha/open-duet/issues/157 |
|---|
| User | carfeii (UID 97470) |
|---|
| Submission | 11/06/2026 18:01 (22 days ago) |
|---|
| Moderation | 11/29/2026 03:35 (22 days later) |
|---|
| Status | Accepted |
|---|
| VulDB entry | 445143 [Anil-matcha open-duet up to 0.8.1 Git Risk Classifier github_classifier.py classify_bash_command input validation] |
|---|
| Points | 20 |
|---|