Repository navigation
#658 [security][tools] --offline の外向きの通信を OS の隔離で遮断し、runtime の依存の導入を隔離の中で動かす(第 3 段) - #671
Merged
Kewton merged 2 commits intoOct 13, 2026
Conversation
…pendency setup Issue #658 (stage 3 of #502) adds the network layer and dependency-setup confinement. New behavior lives in the os_sandbox leaf module; dependency_setup and lib.rs carry only wiring. - SandboxPolicy gains `offline` and `dev_server_ports`. The run installs it through os_sandbox::install_with, so config.offline reaches the model Bash, verifier, and dependency-setup launches; lib.rs passes config.offline and the leaf-derived dev-server ports. os_sandbox::install keeps the non-offline default for other callers. - os_sandbox::dev_server_ports derives the allow list (the goal's requested port from planner::signals, else the profile default from planner::profile). - macOS Seatbelt appends an --offline network profile (deny network*, re-allow loopback TCP in/out/bind and unix-socket connects); verified against sandbox-exec (external connect gives EPERM, loopback and unix sockets work). - Linux Landlock handles AccessNet::ConnectTcp from ABI4 and re-allows the run's dev-server port with a NetPort rule; below ABI4 it records that the network is lexical-only in bash_sandbox_status while the write and read layers still apply. The network-rights/ABI handling is documented in the module and create_ruleset. - The Python sh -c and npm install launches call os_sandbox::wrap_dependency_setup (the leaf seam); required-unavailable fails the setup with the sandbox reason, auto runs it outside and the run status records it as not applied. - tests/issue502_os_sandbox_network.rs drives the network layer and the dependency-setup launch, gates ABI4 under CI (fail, not skip), and records the kernel/ABI to GITHUB_STEP_SUMMARY like the read test. - SECURITY.md and both cli-reference pages split the --offline explanation into "OS-blocked when the sandbox is applied" and "lexical-only". 判断: the Linux dev-server allow list is derived at run start in the leaf module from the goal's requested port (else the profile default), matching preflight, so a sandboxed command can reach the run's dev server while every other connect is denied. 読み替え: the English --offline/--sandbox table rows stay pinned to the CLI help text by tests/doc_drift.rs, whose source is out of scope, so the rewrite lives in the section prose. Co-authored-by: CommandCodeBot <noreply@commandcode.ai>
…nd offline Four review fixes for #658: - Set the dependency-setup child's stdin after the sandbox wrap, so on macOS (where seatbelt::wrap rebuilds the command) it stays null instead of inheriting the parent's stdin. A macOS applied test runs the check in a child process with a piped stdin, so an inherited stdin is visible. - Allow `network-bind (local unix-socket)` in the macOS --offline profile, so a unix socket can be created inside the isolation (the design allows unix sockets); outbound TCP/UDP stay denied. A macOS applied test binds and listens on a socket inside the tempdir and still checks the 192.0.2.1 connect is refused. - Correct the landlock module comment: the ABI4 port-scope and UDP limits are documented, not recorded in bash_sandbox_status; only a kernel below ABI4 is recorded there. - SECURITY.md: note the Linux fail-closed case -- when no dev-server port can be derived, every TCP connect is denied, localhost included. Co-authored-by: CommandCodeBot <noreply@commandcode.ai>
This was referenced Oct 13, 2026
Kewton
deleted the
feature/issue-658-security-tools-offline-os-runtime-3
branch
October 13, 2026 14:52
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
概要
#502 の第 3 段です(設計は 2026-10-11 に承認)。次の 2 つを入れます。
--offlineの run では、外向きの通信を OS の隔離で遮断します。pip install -e .、npm install --ignore-scripts)を、第 1・2 段の隔離の中で動かします。--offlineでない run のネットワークは変えません。字句検査も変えず、隔離より先に働きます。Refs #658
変更(develop 比 9 ファイル、+1250 −98、2 commit)
src/tools/os_sandbox.rs、葉モジュール)SandboxPolicyにofflineとdev_server_portsを足しました。install_with(mode, workspace, state_dir, offline, ports)を足しました。既存のinstallは今と同じ挙動のまま残しています(ネットワークは変えない)。dev_server_ports(profile, goal)が、許可する port を決めます。goal に書かれた port(planner::signals::requested_port_from_text)、なければ profile の既定(planner::profile::resolve_profile_runtime)です。preflight と同じ決め方です。wrap_dependency_setupは、依存の導入を包む継ぎ目です。seatbelt.rs):--offlineのときだけ、profile にネットワークの規則を足します。(deny network*)の後、loopback の TCP(connect・inbound・bind)と、unix socket(connect・bind)だけを許可します。landlock.rs):--offlineかつ ABI4(kernel 6.7)以上のときだけ、AccessNet::ConnectTcpを handle します。そのうえで、dev server の port をNetPortで許可します。bash_sandbox_statusの reason に「network is not confined … relies on lexical checks」と書き、書き込み・読み取りの隔離は今どおり適用します。src/minimal_loop/dependency_setup.rs、配線だけ):npm と python の 2 つの起動点をwrap_dependency_setupで包みます。stdin・stdout・stderr は wrap の後に設定します。requiredで隔離が使えないときは、既存の観測の Failed と、隔離の拒否の理由で正直に失敗します。autoで使えないときは、今どおり外で動き、「未適用」と記録します。--offlineのときは、今どおり導入の手前で止まります。src/lib.rs、配線だけ +10 −1):installの呼び出しをinstall_with(…, config.offline, os_sandbox::dev_server_ports(&config.profile, action_goal(&config.action)))にしました。SECURITY.mdと ja・en の cli-reference です。--offlineの説明を、「OS が遮断するもの(隔離が使えるとき)」と「字句検査だけのもの」に分けました。tests/issue502_os_sandbox_network.rs(新規)。外への接続は、TEST-NET-1(192.0.2.1)と、試験の中で立てる localhost だけです。CIがあるときは、landlock が未適用か ABI4 未満なら失敗します。kernel と ABI は job summary に 1 行書きます。bash.rs・bash_write_guard・offline_policy.rs・sensitive_path.rs)preflight.rs・runs.rs・Cargo.toml・Cargo.lock・deny.toml・.github/workflows/ci.yml検証
c938a227でcommandmate verifyが 15/15 passed でした。最終 commit の後に流し、worktree は clean です。cargo deny check:exit 0。cargo-zigbuild clippy --all-targets --target x86_64-unknown-linux-gnuは exit 0 です。--include-ignored)fifo=Trueで失敗し、unix socket の試験は bind が EPERM で失敗しました。CI=true)required、隔離の中)--offline:192.0.2.1:443は EACCES(python・node の fetch とも)。許可した port の localhost は通り、ほかの localhost の port は EACCES でした。--offlineでない run:外への接続は timeout で、OS は拒否しません。今と同じです。setup.pyから外への書き込みは PermissionError、外の fixture は不変)、キャッシュ済みの npm も成功しました。cargo build・next build・Playwright(--offlineで dev server のページを開く形を含む)は成功し、外へのtouchは拒否されました。required)--offline:外への接続は EPERM、localhost は通りました。--offlineでない run:今と同じでした。setup.pyから外への書き込みは拒否)と npm は成功しました。--jobs 1、--timeout 300)network_limitation_note → Noneです。ABI 8 では本物もNoneを返すので、この kernel では区別できません(純粋関数の側は caught)。レビュー
c938a227)--offlineで、unix socket の bind を許可しました(外向きの拒否は不変)。landlock.rsのコメントを、実装どおりに直しました。後続の論点
--offlineが効いていても、reason はネットワークに触れません(macOS はread isolation applied、Linux の ABI4 以上はNone)。[security][tools] OS の隔離の許可と記録の食い違い(外を指すキャッシュの symlink、降格の event、Linux の reason、展開の上限) #668 と同じ型です。ConnectTcpの対象かどうかは、この Docker の kernel では確かめられていません。~/.npmrcと private registry:依存の導入が隔離の中に入ったため、--offlineでない run の依存の導入でも、private registry の~/.npmrcは読めません([security][tools] OS の隔離の残り:$HOME の外の toolchain、GUI の delegate の試験と文書、macOS の rename、private registry #669)。~/.cache/pipは許可の一覧に無いため、pip はキャッシュなしで動きます(成功はします)。offline_policy.rs、doc_drift で固定)。cli-reference の表の行と合わせて直す必要があります。CI の runner の kernel と ABI
c938a227、runner は ubuntu-24.04)では、job のログで次を確かめました。issue502_os_sandbox_network:7 passed(linux_offline_refuses_outbound_and_allows_only_the_dev_server_portとdependency_setup_runs_inside_the_sandbox_and_cannot_write_outsideを含む)。issue502_os_sandbox_read:10 passed・2 ignored(ignored は heavy の 2 本)。issue502_os_sandbox_write:16 passed・1 ignored(heavy の 1 本)。CI=trueを置きます。そのため、landlock が未適用か ABI4 未満なら、network の試験は skip せずに失敗します。通ったので、runner で landlock の ABI4 以上が使え、ネットワークの隔離が適用されていました。issue502/658 landlock network: kernel=… abi=…)は job summary にだけ書かれます。job summary はghと API では取れず、ログにも出ないため(cargo testが通った試験の出力を捕まえるため)、ここには記録できていません。参考として、#656 [security][tools] Bash と検証コマンドの書き込みを Linux の landlock で閉じ込める(1b) #666 の同じ種類の runner の記録はkernel=6.17.0-1022-azure abi=7です。🤖 Generated with Claude Code