Skip to content

実装: visual-impact-policy-trusted の trusted-side re-derivation で forged-self-consistent artifact bypass を fail-closed に修正する #2091

Closed

Description

@squne121

Machine-Readable Contract

contract_schema_version: v1
issue_kind: implementation
parent_issue: "none"
goal_ref: "visual-impact-policy-trusted の trusted-consumer 検証境界における forged-self-consistent artifact bypass(affected_surfaces 自己申告受容・evidence: {} coherent forgery・load_registry_text() missing-ref-object 混同)を、trusted-side re-derivation により fail-closed に修正する"
change_kind: code

Parent Issue

なし(単独改善。#2090 の調査結果を実装する follow-up)

Parent Goal Ref

  • Goal: なし(親 Issue なし)
  • Desired Destination: なし(親 Issue なし)

Current Validated Scope

  • scripts/agent-ops/resolve_visual_impact.py の verify_trusted_artifact() と load_registry_text() を修正する
  • docs/dev/visual-impact.schema.json の VISUAL_IMPACT_DECISION_V1 / evidence $def を修正する
  • scripts/agent-ops/tests/test_visual_impact_trusted_consumer.py に adversarial fixture を追加する
  • .github/workflows/visual-impact-trusted-consumer.yml に trusted-side re-derivation に必要な checkout step 等の変更を行う

Remaining Parent Gaps

Background

Refs #2090

research issue #2090(https://github.com/squne121/loop-protocol/issues/2090)の調査により、`scripts/agent-ops/resolve_visual_impact.py` の verify_trusted_artifact()(1324行目付近)と load_registry_text()(125行目付近)に、trusted-consumer 検証境界を bypass 可能な設計上の gap が確認された。

control-plane が repo を直接検証済みの事実:

  • verify_trusted_artifact() は producer 自己申告の affected_surfaces(decision.get("affected_surfaces", []))をそのまま受け取り、独立に PR diff / docs/dev/visual-surfaces.yml registry から再計算・再照合していない。affected_surfaces: [] を含む decision(component_vrt_report_check_run_id: null、artifact_id/artifact_digest: null)を producer が生成すれば、reasons リストが常に空になり ok=True を返す(bypass経路1)
  • evidence.get("evidence_manifest_digest") が truthy な場合のみ digest 整合性チェックが実施される(1373行目付近)。evidence: {}(空 object、digest claim なし)を提示すれば、正しい surface_id を並べるだけで検証を完全にすり抜けられる("evidence: {} coherent forgery"、bypass経路2)
  • docs/dev/visual-impact.schema.json の evidence $def には required フィールドがなく、affected_surfaces 配列にも minItems 制約がない
  • load_registry_text()(125行目付近)は git show <ref>:path が非ゼロ終了した場合、常に「ref に registry が存在しなかった」ものとして synthetic empty registry(existed_at_ref=False)を返し、commit object がローカルに存在しない場合(shallow checkout 等)と file が本当に存在しない場合を区別できない
  • .github/workflows/visual-impact-trusted-consumer.yml の checkout step は ref: を指定せず base/default branch のみ checkout するため、trusted-side re-derivation で live head の commit object を扱う際、shallow checkout に該当 commit object が無いケースが実際に起こりうる
  • 既存テスト(scripts/agent-ops/tests/test_visual_impact_trusted_consumer.py)は「producer が success を偽装したが artifact が不整合・欠落」の negative control のみをカバーしており、「producer が decision と evidence を意図的に整合させて偽造する」forged-self-consistent artifact ケース(evidence: {} coherent forgery を含む)は未カバー

Outcome

verify_trusted_artifact() が trusted verdict を決定する全入力(head_sha・base_sha・PR body digest・changed-path digest・base/head registry・policy_version)を trusted side で独立に再取得・再計算し、producer 自己申告の affected_surfaces および evidence: {} coherent forgery による bypass を fail-closed に拒否するように scripts/agent-ops/resolve_visual_impact.py が修正され、load_registry_text() が missing-ref-object と missing-file を区別して fail-closed に扱うように修正され、adversarial fixture(affected_surfaces: [] / evidence: {} coherent forgery / missing commit ref object / >3000 files incomplete diff / stale base)を含むテストが scripts/agent-ops/tests/test_visual_impact_trusted_consumer.py に追加され、真に visual impact が無い PR の affected_surfaces: [] PASS 判定を壊さない回帰テストも追加された状態で、PR が作成されている。

In Scope

  • verify_trusted_artifact() を trusted-side re-derivation 方式に拡張する: affected_surfaces の再導出だけに限定せず、head_sha に加え base_sha、PR body digest、changed-path digest、base/head registry、policy_version を trusted side で独立取得・再計算し、producer 自己申告の decision と突合する
  • evidence: {} coherent forgery を確実に FAIL させる: evidence object 自体に最低限の required フィールド、または surface ごとの証跡必須化のいずれかの方式を実装する
  • component-VRT CheckRun の App identity / conclusion の live API 再照合を補助証拠として扱う設計(単独の trust root にしない)を実装する。full-SHA pinned reusable workflow 等 immutable な trusted evidence producer への移行が本 Issue の範囲で実現可能であれば実装し、範囲を超える場合は Scope Delta または follow-up として明記する
  • load_registry_text()(125行目付近)の git show <ref>:path 非ゼロ終了時の扱いを修正する: missing-ref-object(commit object がローカルに存在しない、例: shallow checkout)と missing-file(file が ref に存在しない)を区別し、missing-ref-object は fail-closed(例外 raise または明示的なエラー verdict)とする
  • live PR diff を REST files API で取得する設計を採用する場合、単一ページ 3,000 files 上限による incomplete-set リスクに対処する(unknown な場合は FAIL とする、または既存の producer 側 git diff --name-status semantics を trusted side に移植する)
  • .github/workflows/visual-impact-trusted-consumer.yml に trusted-side re-derivation が必要とする checkout step(例: live head の fetch)を追加する
  • docs/dev/visual-impact.schema.json の evidence $def に最低限必要な required フィールドを追加する(affected_surfaces への minItems: 1 の追加は禁止。理由は Out of Scope 参照)
  • adversarial fixture を scripts/agent-ops/tests/test_visual_impact_trusted_consumer.py に追加する:
    • affected_surfaces: [](自己申告そのものが空)
    • evidence: {} coherent forgery(surface_id は正しいが digest claim がない)
    • missing commit ref object(shallow checkout 等で git show が非ゼロ終了するケース)
    • >3000 files の PR や incomplete diff
    • stale base(base_sha が live PR の実際の base と乖離しているケース)
    • 真に visual impact が無い PR で affected_surfaces: [] が正しい PASS 結果であることを確認する回帰テスト

Out of Scope

  • PR fix: visual-impact-trusted-consumer.yml の gh api --output 未対応バグを修正する (#2076) #2085(.github/workflows/visual-impact-trusted-consumer.yml の --output バグ修正)自体の変更(既に merge 済み、commit ee641da)
  • untrusted ZIP 展開の resource bound 強化(別途 P1 follow-up)
  • visual-impact-policy-trusted を branch protection の required_status_checks に昇格させること
  • docs/dev/visual-impact.schema.json に minItems: 1 を追加するだけの表面的な修正(本当に visual impact が無い PR の空集合を壊すため禁止)

Acceptance Criteria

  • AC1: verify_trusted_artifact() が producer 自己申告の affected_surfaces に加えて、trusted side で独立に再計算した base_sha/PR body digest/changed-path digest/base-head registry/policy_version のいずれかと突合するロジックを持つ
  • AC2: affected_surfaces: [] を含む forged decision(component_vrt_report_check_run_id: null、artifact_id/artifact_digest: null)が ok=False として拒否される
  • AC3: evidence: {}(digest claim なし)だが affected_surfaces の surface_id が正しい forged decision が ok=False として拒否される
  • AC4: load_registry_text() が missing-ref-object(commit object 不存在)と missing-file(file が ref に存在しない)を区別し、missing-ref-object の場合は synthetic empty registry を返さず fail-closed に扱う
  • AC5: 真に visual impact が無い PR(affected_surfaces: [] が正しい結果であるケース)が引き続き PASS する回帰テストが存在する
  • AC6: docs/dev/visual-impact.schema.json の affected_surfaces に minItems: 1 が追加されていない(AC5 の回帰を壊さないことの契約側の裏付け)
  • AC7: 上記 adversarial fixture 5 種(AC2/AC3/AC4 相当のケースに加え >3000 files incomplete diff・stale base)が scripts/agent-ops/tests/test_visual_impact_trusted_consumer.py に追加されている

Verification Commands

# AC1
# baseline-expect: pass
$ rg -n "base_sha" scripts/agent-ops/resolve_visual_impact.py
# AC2
$ rg -n "def test_affected_surfaces_empty_forgery_rejected" scripts/agent-ops/tests/test_visual_impact_trusted_consumer.py
# AC3
$ rg -n "def test_evidence_empty_coherent_forgery_rejected" scripts/agent-ops/tests/test_visual_impact_trusted_consumer.py
# AC4
$ rg -n "def test_missing_ref_object_fail_closed" scripts/agent-ops/tests/test_visual_impact_trusted_consumer.py
# AC5
$ rg -n "def test_no_visual_impact_empty_surfaces_pass" scripts/agent-ops/tests/test_visual_impact_trusted_consumer.py
# AC6
$ rg -c "minItems" docs/dev/visual-impact.schema.json
# AC7
$ uv run --locked pytest scripts/agent-ops/tests/test_visual_impact_trusted_consumer.py -v

Allowed Paths

  • scripts/agent-ops/resolve_visual_impact.py
  • docs/dev/visual-impact.schema.json
  • scripts/agent-ops/tests/test_visual_impact_trusted_consumer.py
  • .github/workflows/visual-impact-trusted-consumer.yml

Stop Conditions

  • Allowed Paths 外の変更が必要と判明した場合
  • In Scope の固定契約(キー集合・スキーマ・型定義)の変更が必要になった場合
  • 新規 Issue の起票が必要と判断した場合(スコープ分割が発生する場合)
  • 後続 Phase / 別スコープへの波及が判明した場合
  • nested SubAgent delegation が必要になった場合
  • 外部サービス利用・権限昇格・既存テスト大規模改変が必要になった場合

Required Skills

なし

Required Design References

  • docs/dev/visual-impact.schema.json
  • docs/dev/secret-policy.md

Scope Delta(任意)

N/A

Notes for Reviewer

Activity

  1. added
    enhancement
    phase/implementation
    triage-required
    agent/implementer
    on Aug 11, 2026
  2. squne121 commented on Aug 11, 2026

    @squne121
    OwnerAuthor

    実装完了報告

    AC 結果(全て実測)

    • AC1: PASS — verify_trusted_artifact() が TrustedRederivation(base_sha/PR body digest/changed-path digest/registry blob sha/policy_version)と producer 自己申告を突合
    • AC2: PASS — test_affected_surfaces_empty_forgery_rejected(resolve_trusted_minimum() による独立再計算で affected_surfaces: [] 過小申告を拒否)
    • AC3: PASS — test_evidence_empty_coherent_forgery_rejected(evidence: {} coherent forgery を無条件拒否)
    • AC4: PASS — test_missing_ref_object_fail_closed / test_missing_ref_object_never_silently_empty_registry_in_resolve(MissingRefObjectError で missing-ref-object と missing-file を区別・fail-closed)
    • AC5: PASS — test_no_visual_impact_empty_surfaces_pass(legitimate affected_surfaces: [] の誤 reject なし)
    • AC6: PASS — docs/dev/visual-impact.schema.json に minItems 追加なし(無変更)
    • AC7: PASS — adversarial fixture 5種を含む 26 tests 全 PASS

    テスト結果

    • scripts/agent-ops/tests/test_visual_impact_trusted_consumer.py: 26 passed
    • 関連 visual-impact consumer test(9 file): 74 passed(regression 無し)
    • pnpm typecheck / pnpm lint / pnpm test(112 files / 1872 tests) / pnpm build: 全 PASS
    • uv run --locked ruff check .claude/scripts scripts schemas .claude/skills: PASS
    • actionlint: PASS
    • git diff --check: PASS

    CI 結果

    残存 follow-up

    security assumptions(残存する前提)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent/implementerenhancementphase/implementationtriage-required

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions