Repository navigation
fix: no-sudo local-dev 向け trusted uv resolver に standard user-local lane を復元する - #2281
Merged
Merged
Conversation
…ane を復元する Issue #2276 の decision record(no-sudo を固定制約として account-home `~/.local/bin` を canonical local-dev trust lane として再許可する)を `_resolve_trusted_executable("uv", ...)` に実装する。 - real OS account home(`pwd.getpwuid(os.getuid()).pw_dir`)から `.local/bin` を解決する `_os_account_home()` / `_trusted_account_home_uv_dir()` を追加し、 `_safe_path_entries()` の候補に含める。ambient `HOME` 環境変数は参照しない ため、`HOME` spoofing で trust path を攻撃者側へ移動できない。 - 再許可した lane も既存の `pyproject.toml` [tool.uv].required-version による exact version pin 検証を通し、wrong-version は fail-closed で拒否する。 - same-UID attacker containment を主張しないよう docstring を書き換える。 - `docs/dev/workflow.md` に Controlled / Not Controlled の区分を明記する セクションを追加し、決定の経緯を記録する。 - 新規 positive/negative テストを追加し、旧設計(`.local/bin` 全除外)を 前提にしていた既存テストのアサーションを更新する。 Closes #2280 Relates to #2276
Contributor
Preview URLPreview removed (PR #2281 closed). |
11 tasks done
…S対応)
adversarial security review で、_safe_path_entries() に追加した account-home
`.local/bin` lane が uv 以外の executable 名(特に _resolve_trusted_executable
("git", ...) 経由の git resolution)にも無条件で渡っていたことが判明した。
_validate_trusted_executable_version は uv 以外では no-op のため、real
account home に同一 UID が置いた偽 git 等が無検証で trust される regression
だった(Issue #2251 が閉じた CWE-427 exposure の git への再オープン)。
_safe_path_entries(executable_name) にパラメータ化し、account-home lane は
executable_name == "uv" のときのみ候補に含める。_resolve_trusted_executable
は _safe_path_entries(name) を呼び、git/ssh 用の _sanitize_env /
sanitized_git_subprocess_env / _resolve_trusted_ssh_command は引き続き
account-home を含まない _safe_path_entries() を呼ぶ。
adversarial regression test を追加:
- test_safe_path_entries_excludes_account_home_for_non_uv_names
- test_resolve_trusted_executable_git_never_selects_account_home_fake
Issue #2280 の AC2/AC9 を Scope Delta で修正し AC11 を新設した。
Relates to #2280 #2281
前コミットで _safe_path_entries に executable_name 引数を追加したが、
test_skill_runtime_preflight_bytecode_cache.py が
`monkeypatch.setattr(real_exec, "_safe_path_entries", lambda: [...])` で
0引数版を前提に monkeypatch しており、TypeError で 2 test が CI で fail した。
_safe_path_entries() は 0引数のまま維持し(呼び出し互換性を保つ)、
account-home lane の uv 専用化は _resolve_trusted_executable 内で
name == "uv" のときだけ [*_trusted_toolchain_dirs("uv"),
*_trusted_account_home_uv_dir(), *_SYSTEM_STANDARD_PATH_DIRS] を
直接組み立てる形に変更した。順序も hostedtoolcache → account-home →
system の意図した順に修正した(前コミットでは account-home が誤って
hostedtoolcache より前に来ており、hostedtoolcache lane regression test
2件を壊していた)。
テストを _safe_path_entries(name) 呼び出し前提から
_trusted_account_home_uv_dir() / _resolve_trusted_executable() 直接呼び出し
前提に更新し、Issue #2280 AC11 の VC も実際のテスト名に合わせて修正した。
squne121
marked this pull request as ready for review
August 21, 2026 11:51
This was referenced Aug 21, 2026
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.
概要
Issue #2276(decision record: no-sudo を固定制約として uv trust boundary を再検討する)の決定を実装する。
scripts/agent-guards/skill_runtime_exec.pyの trusteduvresolver に、標準 account-local~/.local/bin/uvを no-sudo local-dev 向け positive lane として再許可する。Issue #2251 / PR #2261(merged, commitdbe38ed3)が導入した account-home 除外を、下記 Threat Model の下で部分的に revert する。Threat Model(脅威モデル)
PATH汚染、偽HOMEによる trust path 誘導、CWD/project 配下の fake executable、uv --versionの pin 不一致。account-home 判定は ambient
HOME環境変数からではなくpwd.getpwuid(os.getuid()).pw_dir(実 OS account identity)から導出するため、HOME=/tmp/evilのような spoofing で trust path を攻撃者側へ移動できない。変更内容
_os_account_home()/_trusted_account_home_uv_dir()を追加し、real account home の.local/binを_safe_path_entries()の候補に含める。_validate_trusted_executable_version(pyproject.tomlの[tool.uv].required-versionexact pin)による fail-closed 検証を通す。wrong-version はuv_version_mismatchで拒否。_safe_path_entries()等の docstring から same-UID attacker containment の主張を除去。docs/dev/workflow.mdに Controlled / Not Controlled の区分を明記するセクションを追加。Tests(テスト内容)
scripts/agent-guards/tests/test_trusted_toolchain_isolated_home.py:HOMEenv spoof では real account home の trust path は動かない(fake HOME 側の.local/binは選ばれない)uvは fail-closeduv_version_mismatch.local/bin全除外)前提だったテストを新仕様に更新.claude/skills/issue-refinement-loop/tests/test_operator_selected_scope_reframe.py:test_sanitize_env_trust_root_real_subprocess_ignores_home_override_ac3のアサーションを、real account home の.local/binは許可・env-spoofed HOME 由来の.local/binのみ拒否、という新仕様に合わせて更新(Scope Delta: issue コメント)Runtime Verification Evidence(実行時検証の証跡)
no-sudo のこのローカル開発機(
/opt/hostedtoolcache/uv不在)で、実装後の resolver が実際に~/.local/bin/uv(version0.11.29、pyproject.tomlの pin と一致)を解決できることを直接確認済み:実装前(この変更を revert した状態)では
uv_not_foundで fail-closed していた availability regression が、sudo なしで解消されることを実証した。Verification Commands(検証コマンド、全 AC が PASS 済みであることを確認済み)
関連
関連: Issue #2276(decision record)。本 PR は Issue #2280 の実装であり、マージ後に以下の記述により自動的に close される。
Closes #2280