[bug] LifeOSHooks sandbox breaks subagent Bash in auto mode

Đang mở
#2,733 2 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 5 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
53/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
typescript
Lĩnh vực
security, tooling

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
TypeScript
Star
19.9k
Fork
2.5k
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của danielmiessler/LifeOS

Tất cả issue của danielmiessler/LifeOS

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.