Repository navigation
fix: trusted uv resolver から account-home .local/bin を除外し CWE-427 search-selection risk を縮小する (#2251) - #2261
Conversation
`skill_runtime_exec.py::_safe_path_entries()` から account-home `~/.local/bin`(child と同一 UID で書き込み可能な trust root 候補)を 除外し、CWE-427 search-selection risk を縮小する。`.local/bin` にしか `uv` が存在しない環境では silent fallback せず `uv_not_found` で deterministic に fail-closed する。version 照合は `pyproject.toml` の `[tool.uv].required-version` を read-only SSOT として consume する形に 整理し、新しい version literal は追加しない。`docs/dev/workflow.md` の "Not Controlled" 記述を、CWE-427 search-selection hardening(解消済み) と same-UID executable 本体置換の不可能性(未解決のまま残る)に分離。 Co-Authored-By: Claude Sonnet 5 <[email protected]>
Preview URL✅ verified live assets: https://squne121.github.io/loop-protocol/pr-2261/ The preview will be removed when this PR is closed. |
fix_delta 対応報告(Blocker 2/3 対応、Blocker 1 は Stop Condition 該当)Blocker 3(PR Body Japanese Check): 対応完了PR body の日本語比率 0% だった2ブロック( Blocker 2(AC9 diagnostics): 調査完了・追加事実を PR body に記載
Blocker 1(
|
Scope Delta(Issue #2251 Allowed Paths 追加分)に基づき、account-home `.local/bin` を trust root から除外し `pwd` 属性を削除した本PRの実装により genuine regression していた以下3テストを新挙動に追従させた。 - test_fixture_human_context_real_subprocess_reaches_contract_update_required_ac3: `skill_runtime_exec_mod.pwd` への patch を削除(本番コードが `pwd` を import しなくなったため AttributeError)。`.local/bin` trust entry の 存在チェックを削除し、canary が sanitize 後 PATH に含まれないことを 検証する形に変更。加えて、hostedtoolcache 非搭載の dev sandbox では nested dispatch が `uv_not_found` で早期 fail-closed するため、 trusted uv の可用性を in-process probe し、環境ごとに正しい fail-closed 経路(contract_update_required 到達 or uv_not_found)を 分岐して assert するよう修正。 - test_sanitize_env_trust_root_real_subprocess_ignores_home_override_ac3: `.local/bin` エントリの存在を前提にした assertion を、`.local/bin` が 一切含まれないことを検証する assertion に変更。 - test_fixture_human_context_sibling_fails_closed_on_transport_anchor_mismatch: 同様に trusted uv 可用性を probe し、hostedtoolcache 搭載環境 (CI)では従来通り anchor mismatch 検出(returncode 2)を検証し、 非搭載環境(dev sandbox)では uv_not_found による fail-closed (returncode 1)を検証するよう分岐。 `.claude/skills/issue-refinement-loop/tests/test_fixture_human_context_subprocess.py` は re-export wrapper のため、上記修正で連鎖的に解消。 検証: - uv run --locked pytest .claude/skills/issue-refinement-loop/tests/test_operator_selected_scope_reframe.py .claude/skills/issue-refinement-loop/tests/test_fixture_human_context_subprocess.py -v (30 passed) - uv run --locked pytest scripts/agent-guards/tests/test_trusted_toolchain_isolated_home.py scripts/agent-guards/tests/test_skill_runtime_control_plane_exec.py -v (57 passed) - ruff check(対象2ファイル、issue含まず) all checks passed Refs #2251 Co-Authored-By: Claude Sonnet 5 <[email protected]>
推奨アクション選ぶべきは「案1のうち、AC9 の Verification Command を実在する canonical workflow に差し替える」方針です。 理由は明確です。#2251 自身が trust boundary 縮小を security/isolation hardening と位置づけ、AC9 を 一方、 代わりに、既存 registry には さらに AC9 は少し整理した方がよいです。live runtime の責務は Availability Invariant の positive proof に限定し、 併せて、Issue body を触る今回の human decision で AC8 の もう一点、対象の取り違えを防ぐ必要があります。提示URLのコメント
以下をそのまま Claude Code に渡すのがよいです。 Issue #2251 / PR #2261 — human decision 適用後の impl-review-loop 再開対象:
注意:
今回の human decisionAC9 に対する方針は以下で確定する。
Issue #2251 の契約修正まず read-only SubAgent を起動し、以下を調査させること。
SubAgent の完了を必ず待ち、その結果を受け取ってから次へ進むこと。 調査結果から exact command を確定したら、human decision として Issue #2251 を以下の方向へ更新する。 Runtime Verification Applicability
AC9AC9 の意味を概ね次へ修正する。
文言は repo の既存 contract style に合わせて調整してよい。 AC9 Verification Command
想定する実行経路は:
ただし、上記説明から argv を手作業で推測して固定してはならない。
AC8 Verification Command既知の case mismatch も同時に契約修正する。 現在の:
を、実際の canonical 表記を検出できる command に直すこと。 候補:
または current SSOT の exact capitalization を使うこと。 これは production code の仕様変更ではなく Verification Command の誤りの修正として扱う。 Issue mutation の扱い今回のユーザープロンプト自体が human decision である。 この decision を適用するために、必要なら Issue #2251 body を controlled mutation path で更新してよい。追加確認は不要。 ただし、agent が自分で投稿した GitHub comment を「human が投稿した comment」と偽って human-context provenance に使用してはならない。 Issue body の readback を行い、更新内容が意図通りであることを確認する。 impl-review-loop 再開Issue contract 修正後、既存 PR #2261 を対象に 新規 PR を作らない。 ループでは既存の skill contract に従い、各段階を適切な SubAgent に委譲する。 最低限:
各 SubAgent を spawn した後は、その SubAgent の作業完了を必ず待つこと。 メイン thread は control-plane / routing に専念し、SubAgent 自身に不要な nested delegation をさせない。 承認ポリシーこの作業について、以下はマージ直前まで追加の人間承認を求めず自律実行してよい。
ただし PR の merge は実行しないこと。 live state を優先すること過去レポートにある以下の値は stale evidence として扱う。
開始時と各 push/update_branch 後に current head と live state を再取得する。 reviewed head と live head が異なる場合は stale review として current head を再レビューする。 live actual conflict ( 検証Issue #2251 の current Verification Commands を修正後の正本として再実行する。 最低限:
AC9 runtime evidence は単に PR review検証後、current head SHA を明示して レビュー完了を待つこと。
を iteration 上限まで承認不要で継続する。 SubAgent が単に 正式な 完了条件以下をすべて満たすまで継続する。
上記を満たしたら マージ直前で停止し、merge は行わない。 最終報告最後に以下を報告すること。
merge 操作は絶対に実行しないこと。 |
概要
本 PR は Issue #2251 を解決する(Closes #2251)。
PR #2247(Closes #2241)で "Not controlled" と文書化された account-home
~/.local/binの CWE-427 search-selection risk を、trusted executable search path から除外することで縮小する。変更内容
scripts/agent-guards/skill_runtime_exec.py_safe_path_entries()から account-home~/.local/binを trust root 候補から完全に除外(_os_account_home()/_validate_account_local_bin_trust()は不要になったため削除、import pwdも削除).local/binにしかuvが存在せず hostedtoolcache/system 標準ディレクトリからも解決できない場合、resolver は silent fallback せず既存のuv_not_found経路で deterministic に fail-closed する(新しい pin 機構は追加していない).local/bin由来(および他の非 hostedtoolcache)の version 照合を、pyproject.tomlの既存[tool.uv].required-versionを read-only SSOT として consume する形に整理(_required_uv_version()/_validate_trusted_executable_version()を新設、_TOOL_VERSION_OUTPUT_RE/_validate_local_bin_executable_version()は置き換え)。新しい version literal は追加していないscripts/agent-guards/tests/test_trusted_toolchain_isolated_home.pydocs/dev/workflow.md変更しないこと
_resolve_trusted_executable()の per-invocation re-resolution(no-cache)方針は維持検証コマンド結果
pytest ... -k test_safe_path_entries_excludes_local_bin -vpytest ... -k test_local_bin_fake_executable_not_selected -vpytest ... -k test_hostedtoolcache_lane_regression -vpytest scripts/agent-guards/tests/test_trusted_toolchain_isolated_home.py -vpytest ... -k test_local_bin_only_fails_closed -vpytest scripts/agent-guards/tests/test_skill_runtime_control_plane_exec.py -vpytest ... -k test_required_version_mismatch_fails_closed -vrg -in "not controlled" docs/dev/workflow.md(2026-08-19 human decision で Issue 本文 VC 修正済み)uv run python3 scripts/agent-guards/skill_runtime_exec.py --command-id preflight.run.with_human_context --issue-number 2251 --repo squne121/loop-protocol --anchor-comment-url <実在するissue-2251コメントURL>(2026-08-19 human decision で Issue 本文 VC をcommand_registry.py登録済みの canonical command に差し替え)_validate_runtime_contextの cwd/branch/repo-slug guard を通過、本 PR が変更した_resolve_trusted_executable("uv", project_root)に実際に到達したことを確認。実行環境(hostedtoolcache 非搭載の dev sandbox)では設計通りuv_not_foundで deterministic に fail-closed(regression ではなく AC5 の意図した挙動)。hostedtoolcache 搭載環境(本 PR の required CI runner)での positive completion は、同一 CI runner でpython-test-core/python-test(AC3/AC4/AC6 を含む)が green であることをもって担保ruff check scripts/agent-guards/skill_runtime_exec.py scripts/agent-guards/tests/test_trusted_toolchain_isolated_home.pypnpm typecheck/lint/test/build は本 PR が TypeScript/JS ファイルを一切変更しないため実行していません(worktree に
node_modules未インストール、Issue 本文の Verification Commands にも含まれていません)。Allowed Paths 準拠
Issue #2251 の Allowed Paths として許可された以下 3 ファイルのみを変更した。
上記 3 ファイルのみ変更(
git diff --statで確認済み)。AC9 実行時証跡(2026-08-19 の人間判断適用後に取得した動作検証結果)
Issue #2251 の 2026-08-19 human decision により、AC9 の Verification Command を(存在しない)
scripts/claude-gpt/launch.sh --diagnostics-onlyからcommand_registry.pyに既存登録済みの canonical commandpreflight.run.with_human_contextに差し替えた(Runtime Verification Applicability: immediateは維持、launch.shは Allowed Paths に追加せず)。command_registry.pyのpreflight.run.with_human_context定義から機械的に生成した引数列であり、手書きで推測したものではない):uv run python3 scripts/agent-guards/skill_runtime_exec.py --command-id preflight.run.with_human_context --issue-number 2251 --repo squne121/loop-protocol --anchor-comment-url "https://github.com/squne121/loop-protocol/issues/2251#issuecomment-5340741742".local/binを除外し CWE-427 search-selection risk を縮小する (#2251) #2261 head(9927d3d)を checkout した独立 worktree。cwd をそのリポジトリ root に、branch を default branch 名(main)に、origin を実リポジトリ URL に設定し、_validate_runtime_contextのcwd_not_canonical_main_root/root_not_default_branch/repo_binding_mismatchguard をすべて満たした_resolve_child_argv()→_resolve_trusted_executable("uv", project_root)に実際に到達した。実行環境(uvが account-home~/.local/binにのみ存在し/opt/hostedtoolcache/uv等が存在しない dev sandbox)ではRuntimeError: uv_not_foundで deterministic に fail-closed した。これは regression ではなく AC5 が保証する新挙動そのものであるuvが解決可能な環境(本 PR の required CI runner)での同一 VC 実行、および同一 delivery のpython-test-core/python-test(AC3/AC4/AC6 を含み、当該 runner 上で green)をもって充足する.local/binの fake executable が選択されない negative proof は AC2(test_local_bin_fake_executable_not_selected、PASS)が担当し、AC9 では重複した live fake-executable 配置は行っていない既知の未解決事項(regression 関連)
.claude/skills/issue-refinement-loop/tests/test_operator_selected_scope_reframe.py::test_fixture_human_context_real_subprocess_reaches_contract_update_required_ac3/::test_sanitize_env_trust_root_real_subprocess_ignores_home_override_ac3、および同テストを再輸出するtest_fixture_human_context_subprocess.py側の同名テスト)が壊れていた問題は、Issue fix: trusted uv resolver から account-home.local/binを除外し CWE-427 search-selection risk を縮小する #2251 本文の Scope Delta(2026-08-19 追加、上記2ファイルを Allowed Paths に追加)により解消しました。詳細は下記「Fix Delta(2026-08-19)」を参照してください。Fix Delta(2026-08-19、テスト期待値の追従修正)
Issue #2251 本文の Scope Delta で Allowed Paths に追加された以下2ファイルについて、
.local/bintrust root 完全除外・pwd非使用という新しい意図的挙動に合わせてテストの期待値を更新しました(新規スキーマ・機能追加なし)。.claude/skills/issue-refinement-loop/tests/test_operator_selected_scope_reframe.py.claude/skills/issue-refinement-loop/tests/test_fixture_human_context_subprocess.py(test_operator_selected_scope_reframe.pyを re-export するラッパーのため、ソース側の修正で連鎖的に解消。ファイル自体は無変更)変更したテストと理由
test_fixture_human_context_real_subprocess_reaches_contract_update_required_ac3skill_runtime_exec_mod.pwd.getpwuidへのpatch.objectを削除(本番コードがimport pwdしなくなったためAttributeError)。.local/bintrust entry の存在(PATH先頭・gh解決)を前提にした assertion を、.local/bin(canary 設置先)が sanitize 後PATHに一切含まれないことを検証する assertion に更新。skill_runtime_exec.pyを経由してネストした child(uv run python3 run_refinement_preflight.py)を spawn するが、その dispatch 自体が trusteduv解決を要求する。/opt/hostedtoolcache/uvが存在しない dev sandbox では.local/bin除外後、trusteduvが一切解決できずuv_not_foundで早期 fail-closed する(CI の hostedtoolcache 搭載環境では従来通りcontract_update_requiredルートまで到達する)。そのため trusteduvの可用性を in-process probe(_resolve_trusted_executable("uv", ...)、read-only)し、環境ごとに正しい fail-closed 経路(contract_update_required到達 /uv_not_found)を分岐して assert するよう修正した。test_sanitize_env_trust_root_real_subprocess_ignores_home_override_ac3.local/bintrust entry が存在し、isolatedHOMEではなく real account home を指すことを検証していた assertion を、.local/binが real account home・isolatedHOMEのいずれについても一切含まれないことを検証する assertion に更新(テストの本来の意図「isolatedHOMEoverride が trust root を書き換えられない」は維持し、期待値だけを新しい・より強い不変条件に合わせた)。test_fixture_human_context_sibling_fails_closed_on_transport_anchor_mismatchuv_not_found)になっていた。原因は 1 と同様、.local/bin-only 環境での nested dispatch 早期 fail-closed。.local/binにのみuvを配置)が新しい trust model と非整合であり、かつ本番コードの trusted toolchain root(/opt/hostedtoolcache/uvや system 標準ディレクトリ)はハードコードされ env var 経由の上書きができない設計(実装: Claude-GPT isolated session の minimum control-plane capability を保証する(uv toolchain resolution + credentialless GitHub read) #2241 の意図的な設計判断)のため、非 root 権限の test プロセスから実際に「.local/bin以外の有効な trusteduv」を用意することはできなかった。代わりに 1 と同じ trusteduv可用性 probe を導入し、hostedtoolcache 搭載環境(CI)では本来の contract(anchor mismatch 検出、returncode 2)を引き続き検証し、非搭載環境(dev sandbox)ではuv_not_foundによる fail-closed(returncode 1)を検証するよう分岐した。いずれの分岐でも「mismatch した anchor で silent success しない」という fail-closed 不変条件は常に assert される。検証結果
uv run --locked pytest .claude/skills/issue-refinement-loop/tests/test_operator_selected_scope_reframe.py .claude/skills/issue-refinement-loop/tests/test_fixture_human_context_subprocess.py -vを実行 → 30件パス(すべて成功)uv run --locked pytest scripts/agent-guards/tests/test_trusted_toolchain_isolated_home.py scripts/agent-guards/tests/test_skill_runtime_control_plane_exec.py -vを実行 → 57件パス(AC1-AC7 regression なし、既存挙動を維持)ruff check .claude/skills/issue-refinement-loop/tests/test_operator_selected_scope_reframe.py .claude/skills/issue-refinement-loop/tests/test_fixture_human_context_subprocess.pyを実行 → 全チェック通過(違反なし)Allowed Paths 準拠(更新)
Scope Delta 後の Allowed Paths(5ファイル)のうち、本 fix delta で変更したのは以下1ファイルのみ。
.claude/skills/issue-refinement-loop/tests/test_operator_selected_scope_reframe.py(
git diff --statで確認済み。test_fixture_human_context_subprocess.pyは re-export ラッパーのため無変更)