[bug] LifeOSHooks sandbox breaks subagent Bash in auto mode

オープン
#2,733 コメント 2 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 5 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
53/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
typescript
領域
security, tooling

調査の方向性

Start with pluginPlan in hooks/SubagentGitSandbox.hook.ts and inspect wrapInline plus the local tests described in the issue. Verify exact recognition of a wrap for the current profile and that near matches, including a trailing command, are rejected. Done when exact wrapped commands are handled safely and the reported auto mode flow is verified end to end.

索引モデルが issue の本文から書いたものです。

説明

What happened

LifeOSHooks sandbox breaks subagent Bash in auto mode

Summary

Environment: LifeOS 8.761.0, Claude Code 2.1.322, macOS, auto mode, LIFEOS_SUBAGENT_SANDBOX=on, LifeOSHooks plugin loaded.

Problem. The plugin rewrites a subagent's Bash call into a sandbox-exec wrap after the auto-mode classifier has reviewed it. Claude Code then refuses the call: "a hook changed this call's input after auto mode reviewed it". Re-issuing the rewritten command, as the refusal suggests, fails the same way, because it gets wrapped again. Calls the classifier does not review (echo) still run. Git, tests and file writes do not, so subagents cannot do shell work in auto mode.

Cause. pluginPlan (the bridge's plan op) in hooks/SubagentGitSandbox.hook.ts always returns wrapInline(wrap, profile). Nothing recognises a command that is already that exact wrap.

Suggested fix. Treat a command that is exactly wrapInline(inner, profile) for the current profile as already sandboxed: return it unchanged, and give inner to the classic PreToolUse hooks. The match must be exact. A prefix check is a sandbox escape: <wrap>; touch .git/HEAD passes it, and the tail runs outside the sandbox (reproduced).

function unwrapExact(cmd: string, profile: string, shell = "/bin/zsh"): string | null {
  const head = `${SANDBOX_EXEC_BIN} -p ${shQuote(profile)} ${shell} -c `;
  if (!cmd.startsWith(head)) return null;
  const rest = cmd.slice(head.length);
  if (!/^'(?:[^']|'\\'')*'$/.test(rest)) return null; // one quoted word, nothing after it
  const inner = rest.slice(1, -1).replaceAll(`'\\''`, "'");
  return wrapInline(inner, profile, shell) === cmd ? inner : null;
}

Five local tests pass against the shipped wrapInline. They show that the wrap is not idempotent today, that an exact wrap is recognised, that a plain command, another profile or a trailing word is not, that the prefix-check escape is real, and that the real wrap denies it. Not yet verified: that auto mode then accepts the re-issued command end to end.

Workaround: default permission mode for subagent-heavy work.

Details

  • Kind: bug
  • LifeOS version: 8.761.0

Filed with the LifeOS /feedback command. The reporter approved this exact text before it was sent; paths, secrets and personal details were stripped locally.

主要言語
TypeScript
スター
19.9k
フォーク
2.5k
PR マージ指標
30日以内にマージされた PR はありません

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

danielmiessler/LifeOS のほかの issue

danielmiessler/LifeOS の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。