Skip to content

実装: Claude Code / GitHub Actions の Secret 到達面を上流で制限する secure-secret-boundary を導入する #412

Closed

Description

@squne121

Machine-Readable Contract

contract_schema_version: v1
issue_kind: implementation
parent_issue: "#242"
goal_ref: "agent_session_manifest / telemetry pipeline に Secret 値が到達しない upstream boundary を Claude Code / hooks / GitHub Actions 側で fail-closed に固定する"
change_kind: workflow

Parent Issue

#242

Parent Goal Ref

  • Goal: Claude Code の運用効果測定で扱う manifest / telemetry pipeline から Secret 値を排除し、presence / metadata のみ扱う安全境界を deterministic に固定する
  • Desired Destination: #402 の hook / CI wiring が Secret 値へ到達しない前提で実装できる状態にする

Current Validated Scope

  • .claude/settings.json の permissions.deny / permissions.ask による sensitive path と高リスク command の上流制御
  • .claude/hooks/secret_boundary_guard.sh と対応 test による PreToolUse fail-close guard
  • .github/workflows/session-manifest.yml の secret-safe workflow contract(presence boolean のみ許容、pull_request_target 禁止、write permission 禁止)
  • docs/dev/session-recording-policy.md の Secret boundary policy 明文化

Remaining Parent Gaps

  • #402 の hook / CI wiring 実装そのもの(manifest producer wrapper、artifact upload、hook ordering)
  • secret scanning / push protection 本体の導入
  • manifest validation gate を required check に昇格する enforcement

Outcome

Claude Code / hook / GitHub Actions の measurement pipeline が Secret 値を入力・出力・artifact 化せず、presence boolean と metadata だけを扱う fail-closed boundary と structural test が追加されている状態。

In Scope

  • .claude/settings.json
    • .env, .env.*, secrets/**, credential path, local token store に対する permissions.deny
    • gh secret, printenv, env, set, export -p, .env 読み取り系 command に対する deny(ask は non-interactive 実行・承認疲れ・PR override により Secret 防壁として不十分)
  • .claude/hooks/secret_boundary_guard.sh
    • PreToolUse stdin JSON から高リスク command(cat .env, printenv, env, gh secret, python -c 'import os', node -e 'console.log(process.env)' 等)を検知し、exit code 2 で block
    • Read/Grep/Glob/Edit/Write の path input に .env, .env.*, secrets/**, ~/.netrc, ~/.aws/credentials 等が含まれる場合も exit code 2 で block
    • stderr は secret-like value / env dump / file content を含まない(固定文言のみ)
  • .claude/hooks/tests/**
    • guard の block/pass 条件と stderr safety を固定する smoke / structural test
  • .github/workflows/session-manifest.yml
    • secrets. を一切参照しない(presence boolean を含む)
    • Secret 名・Secret 存在情報は public artifact の metadata となり Secret 情報漏洩になり得る
    • permissions: contents: read または permissions: {} に限定
    • pull_request_target / issues: write / pull-requests: write / write-all を禁止
  • docs/dev/session-recording-policy.md
    • Secret value は measurement pipeline へ渡さない
    • GitHub Secrets は value ではなく presence / metadata のみ扱う

Out of Scope

  • Secret 値の取得・復号・表示・hash 化
  • GitHub Issue / PR comment への Secret 関連 dump
  • push protection / secret scanning の導入そのもの
  • cloud provider credential 管理の一般化
  • #402 の manifest producer wrapper / hook ordering / artifact upload 実装そのもの

Acceptance Criteria

  • AC1: .claude/settings.json に .env, .env.*, secrets/**, credential path, local token store を対象にした permissions.deny がある
  • AC2: .claude/settings.json に gh secret, printenv, env, set, export -p, .env 読み取り系 command への deny がある(ask は Secret 防壁として不十分)
  • AC3: .claude/hooks/secret_boundary_guard.sh が PreToolUse stdin JSON を解釈し、以下を exit code 2 で block する: (a) Bash の cat .env/printenv/env/gh secret/python -c 'import os'/node -e 'console.log(process.env)' 等の高リスク command、(b) Read/Grep/Glob/Edit/Write の path input に .env, .env.*, secrets/**, ~/.netrc, ~/.aws/credentials 等が含まれる場合
  • AC4: guard の block stderr に secret-like value / env dump / file content が含まれないことを test で検証できる
  • AC5: .github/workflows/session-manifest.yml は secrets. を一切参照しない(presence boolean を含む)。Secret 名・Secret 存在情報は public artifact の metadata となり Secret 情報漏洩になり得る
  • AC6: .github/workflows/session-manifest.yml は permissions: contents: read または permissions: {} を使い、write-all, issues: write, pull-requests: write を使わない
  • AC7: .github/workflows/session-manifest.yml は pull_request_target を使わない
  • AC8: manifest / measurement workflow は Issue / PR comment に manifest や secret metadata を投稿しない
  • AC9: manifest schema または producer output contract に secret_policy.value_exposed: false 相当の明示フィールド、または同等の non-exfiltration contract がある
  • AC10: .claude/hooks/tests/test_secret_boundary_contract.py の sentinel fixture テストが SECRET_SENTINEL を注入し、manifest / log / artifact に raw / prefix / suffix / sha256 / sha1 / md5 / base64 / base64url / hex / URL encode / JSON escaped 形式で出現しないことを assert する
  • AC11: docs/dev/session-recording-policy.md に「GitHub Secret は値を取得しない。presence / metadata のみ扱う」と明記される
  • AC12: #402 から本 Issue が upstream security sibling として参照されている
  • AC13: .claude/hooks/tests/test_secret_boundary_contract.py が以下を機械的に assert する: .claude/settings.json に PreToolUse secret_boundary_guard hook が存在する / guard は malformed stdin で exit 2 / guard の stderr に command・path・env 値を echo しない / .github/workflows/session-manifest.yml に pull_request_target が存在しない / workflow の permissions が contents: read または {} / workflow に secrets. が存在しない

Verification Commands

# AC1
# preflight-scope: runtime_only
$ jq -e '(.permissions.deny // []) as $deny | ($deny | index("Read(./.env)")) and ($deny | index("Read(./.env.*)")) and ($deny | index("Read(./secrets/**)"))' .claude/settings.json

# AC2
# preflight-scope: runtime_only
$ jq -e '(.permissions.deny // []) | map(select(startswith("Bash(") and test("gh secret|printenv|env|set|export|cat .*\\.env"))) | length > 0' .claude/settings.json
$ ! rg -Pn '"ask".*(?:gh secret|printenv|env|set|export)' .claude/settings.json

# AC3
# preflight-scope: runtime_only
$ test -x .claude/hooks/secret_boundary_guard.sh
# preflight-scope: pr_review_only
$ printf '{"hook_event_name":"PreToolUse","tool_name":"Bash","tool_input":{"command":"printenv"}}' | .claude/hooks/secret_boundary_guard.sh; test "$?" -eq 2

# AC4
# preflight-scope: runtime_only
$ uv run pytest .claude/hooks/tests/ -q -k "secret_boundary_guard and stderr"

# AC5
$ ! rg -n 'secrets\.' .github/workflows/session-manifest.yml

# AC6
$ ! rg -n 'write-all|issues:\s*write|pull-requests:\s*write' .github/workflows/session-manifest.yml
# preflight-scope: pr_review_only
$ rg -n 'permissions:' .github/workflows/session-manifest.yml

# AC7
$ ! rg -n 'pull_request_target' .github/workflows/session-manifest.yml

# AC8
$ ! rg -n 'gh issue comment|gh pr comment|issues:\s*write|pull-requests:\s*write' .github/workflows/session-manifest.yml

# AC9
$ rg -n 'secret_policy|value_exposed' docs/schemas/agent-session-manifest.md docs/schemas/agent-session-manifest.schema.json scripts tests

# AC10
$ uv run pytest .claude/hooks/tests/test_secret_boundary_contract.py -v -k "sentinel"

# AC11
$ rg -n 'presence / metadata|Secret は値を取得しない|value を pipeline に渡さない' docs/dev/session-recording-policy.md

# AC12
# preflight-scope: pr_review_only
$ gh issue view 402 --json body --jq .body | rg 'secure-secret-boundary|upstream security sibling|Secret 到達面'

# AC13
$ uv run pytest .claude/hooks/tests/test_secret_boundary_contract.py -v

Allowed Paths

  • .claude/settings.json
  • .claude/hooks/secret_boundary_guard.sh
  • .claude/hooks/tests/
  • .github/workflows/session-manifest.yml
  • docs/dev/session-recording-policy.md
  • docs/schemas/agent-session-manifest.md
  • docs/schemas/agent-session-manifest.schema.json
  • docs/dev/secret-policy.md

Stop Conditions

  • Allowed Paths 外の変更が必要と判明した場合
  • In Scope の固定契約を越えて #402 の hook / CI wiring 実装そのものを同時に抱え込む必要が出た場合
  • 新規 Issue の起票が必要と判断した場合(measurement pipeline 以外の security domain に広がる場合)
  • 後続 Phase / 別スコープへの波及が判明した場合(push protection / secret scanning 本体導入など)
  • nested SubAgent delegation が必要になった場合
  • 外部サービス利用・権限昇格・既存 workflow の write permission 追加が必要になった場合
  • 動作検証 AC の VC が SKIP(exit 77)を返した場合(uv または pytest が実行環境に未インストール)

Required Skills

  • Claude Code permissions / hooks
  • GitHub Actions workflow security
  • Secret handling policy design

Background

Notes for Reviewer

  • managed settings が利用可能なら allowManagedPermissionRulesOnly / disableBypassPermissionsMode を優先候補として評価する
  • secret_policy.value_exposed: false を manifest schema 側へ入れる場合は additive change に留め、既存 consumer compatibility を壊さない
  • #402 の implementation は本 Issue 完了後でも可能だが、少なくとも body 上は upstream boundary を dependency / sibling として参照した状態に揃える
  • Secret boundary contract の実装後は以下の構造的 assert が成立すること:
    • session-manifest workflow: secrets. 参照ゼロ / pull_request_target 禁止 / contents: read または {}
    • PreToolUse guard: Bash + Read/Grep/Glob/Edit/Write を fail-closed に検査、stderr は固定文言のみ
    • sentinel fixture: raw/hash/base64/hex/urlencoded 形式が manifest/log/artifact に出現しないことを機械的に検証

Runtime Verification Applicability

decision: immediate
applicable_acs: [AC3, AC4, AC10, AC13]
execution_environment:
  tools: [uv, pytest, jq, rg]
  auth: none
  network: none
skip_conditions: |
  uv または pytest が実行環境に未インストールの場合は exit 77 で SKIP する。
  jq / rg 未インストールの場合も SKIP exit 77 を返す。
fallback_policy: |
  フォールバックなし。pytest / jq / rg の pass/fail をそのまま判定に使う。
  fallback 経由の成功は PASS と見なさない。
artifact_requirements: |
  artifacts/runtime-verification-AC<N>-<timestamp>.log
  worktree-local。main に commit しない。
rationale: |
  AC3/AC4/AC10/AC13 は uv run pytest で即時実行可能。
  AC1/AC2/AC5/AC6/AC7/AC8 は jq/rg 静的ファイル検査で決定論的に検証可能。

Delivery Rule

  • 1 Issue = 1 PR
  • worktree は .claude/worktrees/issue-<番号>-<slug>/
  • Draft PR 既定

Source

source: issue_refinement_loop
origin_issue: "#402"
anchor_comment_urls:
  - "https://github.com/squne121/loop-protocol/issues/402#issuecomment-4540292983"
  - "https://github.com/squne121/loop-protocol/issues/402#issuecomment-4540747789"
dedupe_key: "secure-secret-boundary-for-agent-session-measurement"
created_by: codex
created_at: "2026-05-26T00:00:00Z"

Activity

  1. added
    phase/implementation
    agent/implementer
    enhancement
    kind/implementation
    area/ai-ops
    area/security
    follow-up
    on May 26, 2026
  2. added 2 commits that reference this issue on May 27, 2026
  3. squne121 commented on May 29, 2026

    @squne121
    OwnerAuthor

    総合判定: REQUEST_CHANGES

    #412 の狙いは妥当です。#402/#426 で session manifest の hook/CI artifact 化が進み、#412 はその前段で Secret 値が manifest/telemetry/log/artifact に入らない境界を作る sibling issue になっています。ただし現行の #412 契約は、「Secret 値を取らない」ことの実装保証が弱く、presence boolean・hook・検証コマンドのいずれも抜け道が多いため、このまま実装に入ると「安全そうに見えるが実際は漏れる」設計になります。([GitHub]1)

    参照した関連文脈

    #412 は parent issue #242 の Secret/Session Recording 境界を受け、#402 の hook/CI manifest 生成を安全に成立させるための上流境界です。#402 は Secret 管理を #412 に明示的に切り出しており、PR #426 でも #412 は out of scope とされています。つまり #412 は単なる .claude/settings.json 追加ではなく、#242 の Secret Policy SSOT、#402/#426 の artifact 生成面、producer/schema の validation 面を接続する責務を持ちます。([GitHub]2)

    現在 main の .claude/settings.json は Stop/SubagentStop/PostToolUse の session manifest producer は持ちますが、Secret 用の PreToolUse guard はまだありません。また deny/ask は assets/LICENSES などに限定され、Secret 到達面を包括的に閉じる状態ではありません。([GitHub]3)

    Blocker 1: secrets.NAME != '' の presence boolean は「安全な公開情報」とは限らない

    #412 は GitHub Actions で Secret 値を使わず presence boolean だけ扱う契約にしていますが、これは危険です。GitHub 公式ドキュメント上、Secrets は if: で直接参照できず、未設定 secret は空文字として評価されるため、存在判定には制約があります。さらに GitHub Actions artifacts は public repository では read access を持つユーザーがダウンロード可能で、既定 retention もあります。つまり artifact に出る presence boolean や secret 名は、値でなくても公開配布物として扱うべきです。([GitHub Docs]4)

    修正要求: #412 の AC5 は、原則 session-manifest.yml に secrets. を一切出さないに変更すべきです。どうしても存在情報が必要なら、Secret 名を列挙せず、docs/dev/secret-policy.md の current_secrets_mode 由来の固定 enum だけを manifest に出す設計にしてください。BUTLER_API_KEY や deploy provider 名のような Secret 名そのものも、今後の配布・運用計画を漏らす metadata になり得ます。([GitHub]5)

    Blocker 2: docs/dev/secret-policy.md が allowed paths から漏れている

    #412 は Secret boundary を導入する issue ですが、既存の Secret Inventory / no-secret boundary の SSOT は docs/dev/secret-policy.md です。この文書は現在 current_secrets_mode: none、GitHub Secrets なし、deploy secrets なし、Secret 導入時の Decision Gate を定義しています。ところが #412 の allowed paths にはこの SSOT が含まれていません。([GitHub]5)

    修正要求: allowed paths に docs/dev/secret-policy.md を追加するか、#412 の成果物がこの文書を一切変更しない理由を契約上明記してください。現実的には追加が必要です。Secret 境界を .claude/ と workflow だけで閉じると、#242 の政策面と実装面が乖離します。([GitHub]2)

    Blocker 3: PreToolUse guard の対象が狭すぎる

    Claude Code hooks では、実行前に止められるのは PreToolUse です。PostToolUse はツール実行後なので、Secret 漏洩防止には遅すぎます。公式 docs でも exit code 2 が blocking error とされ、PreToolUse では tool call をブロックできます。stderr は Claude に戻るため、guard 自身のエラー文にも Secret や危険コマンド全文を出してはいけません。([Claude API Docs]6)

    修正要求: secret_boundary_guard.sh は Bash だけでなく、少なくとも Read / Grep / Glob / Edit / Write の path input も検査対象にすべきです。.env は cat .env だけでなく Read tool、rg . .env, grep, sed, awk, tail, find -exec, xargs, bash -lc, python -c 'import os', node -e 'console.log(process.env)' などで到達できます。.claude/settings.json の permission deny だけでは表現力が足りないため、PreToolUse で正規化後の command/path を fail-closed で判定する必要があります。([Claude API Docs]6)

    Blocker 4: ask は Secret 防壁ではない

    #412 は env / printenv / gh secret などを ask/deny に入れる方針ですが、Secret 境界に ask を使うのは弱いです。人間承認疲れ、非対話実行、設定変更 PR により、境界が運用依存になります。Claude Code の permission model では deny/ask/managed settings の優先関係があり、allow は deny/ask を上書きできない一方、repo 内設定だけに依存すると PR で緩められます。([Claude API Docs]7)

    修正要求: Secret 値・Secret 名・Secret ファイル・env dump への到達は ask ではなく deny + PreToolUse exit 2 に寄せてください。ask を許すなら、対象は Secret 値へ到達しない安全な metadata 操作だけに限定し、その metadata が artifact/log/comment に出ないことを別途検証してください。([GitHub Docs]8)

    Blocker 5: 現行 producer の secret detection は AC10 を満たせない

    #377/#404 の producer は --strict-redaction と secret-like pattern 検出を持ちますが、実装は OpenAI/GitHub token、PRIVATE KEY、.env、一部 env assignment などのパターン検出が中心です。#412 の AC10 は「値・部分値・hash・base64 が manifest/log/artifact に出ない」ことを要求していますが、正規表現ベースの token 形状検出だけでは、任意 Secret、短い prefix/suffix、SHA-256、base64url、URL encode、JSON escape などを検出できません。([GitHub]9)

    修正要求: AC10 は sentinel fixture ベースにしてください。テスト時に SECRET_SENTINEL="lp_test_secret_...long_random..." を注入し、artifact/log/manifest に対して raw、prefix、suffix、sha256、sha1、md5、base64、base64url、hex、URL encode、JSON escaped を全探索する検証を追加すべきです。--no-validate や --allow-local-path が hook/CI 経由で使われていないことも構造検査してください。([GitHub]10)

    Blocker 6: 検証コマンドが shallow grep 依存で、YAML/JSON 契約を保証しない

    #412 の verification は rg / jq 断片が中心ですが、これは「たまたま文字列がある」ことしか見ません。workflow YAML の全 scalar に secrets. が混じっていないか、pull_request_target がないか、permissions が read-only か、hook ordering が PreToolUse か、guard が fail-closed かは、構造検査しないと保証できません。#426 でも pnpm version 未固定や Safety Claim Matrix 欠落でレビュー差し戻しが発生しており、#412 で同じ粒度の甘さを繰り返すべきではありません。([GitHub]1)

    修正要求: tests/test_secret_boundary_contract.py か Node-based structural checker を追加し、以下を機械的に assert してください。

    - .claude/settings.json に PreToolUse secret_boundary_guard が存在する
    - Stop/SubagentStop producer より前に policy/secret guard が走る
    - guard は malformed/missing stdin で exit 2
    - guard stderr に command/path/env 値を echo しない
    - workflow に pull_request_target が存在しない
    - workflow permissions が contents: read または {}
    - workflow 全 scalar に secrets. が存在しない、または allowlist された presence-only 表現だけ
    - artifact/log/manifest に sentinel の raw/partial/hash/base64/encoded 形が出ない
    

    高品質化した受け入れ条件案

    #412 の acceptance criteria は次のように締め直すべきです。

    secret_boundary_contract:
      default_secret_context: "no GitHub Actions secrets referenced"
      public_surfaces:
        - workflow log
        - GitHub Actions artifact
        - issue/pr comment
        - git committed files
      forbidden_outputs:
        - secret value
        - secret partial value
        - secret hash
        - secret base64/base64url/hex/urlencoded/jsonescaped transform
        - raw env dump
        - .env content
        - local credential file content
      claude_enforcement:
        event: PreToolUse
        behavior: fail_closed
        block_exit_code: 2
        stderr_policy: constant_message_only
      manifest_policy:
        secret_policy.value_exposed: false
        secret_policy.source: docs/dev/secret-policy.md
        secret_names_exposed: false

    この形なら #242 の Secret Policy、#402/#426 の manifest artifact 化、#377/#401 の producer/schema と接続できます。単に「.claude/settings.json に deny を足した」だけでは、#412 の親目的である telemetry/manifest pipeline からの Secret 排除を満たしたとは言えません。([GitHub]2)

    実装レビューコメントとしての結論

    REQUEST_CHANGES
    
    #412 は必要な issue だが、現行契約は Secret 値の非到達を十分に保証していない。
    特に以下は blocker:
    
    1. GitHub Actions secrets の presence boolean を artifact に出す設計は、値でなくても公開 metadata 漏洩になり得る。
    2. Secret Policy の SSOT である docs/dev/secret-policy.md が allowed paths から漏れている。
    3. Claude Code の Secret 防壁は PreToolUse exit 2 fail-closed でなければならず、PostToolUse/ask/regex grep では不足。
    4. producer の既存 secret-like regex は AC10 の partial/hash/base64/encoded leak 検出を満たせない。
    5. verification が shallow grep で、workflow/settings/schema/artifact を構造的に検査していない。
    
    修正方針:
    - session-manifest workflow は原則 secrets.* を一切参照しない。
    - Secret presence が必要なら docs/dev/secret-policy.md 由来の public-safe enum のみ出す。
    - .claude/hooks/secret_boundary_guard.sh は PreToolUse で Bash/Read/Grep/Glob/Edit/Write を fail-closed に検査する。
    - stderr は固定文言のみ。
    - sentinel secret fixture を使い、raw/partial/hash/base64/base64url/hex/urlencoded/jsonescaped が manifest/log/artifact に出ないことをテストする。
    - YAML/JSON structural checker を追加し、pull_request_target/write permission/secrets.* 参照/guard ordering を機械的に落とす。
    

    公開ページで確認できる範囲では、#412 自体にはまだ紐づく PR/branch は見当たらず、関連実装・レビュー文脈は #402/#426 側が中心です。したがって現時点のレビュー対象は「実装済み PR」ではなく、issue contract の不足を先に潰すレビューとして扱うのが妥当です。([GitHub]1)

  4. squne121 commented on May 29, 2026

    @squne121
    OwnerAuthor

    issue-refinement-loop 完了

    LOOP_TERMINATION_RESULT_V1:
      termination_reason: approved
      max_iterations: 3
      iterations_used: 2
      blockers_history:
        - iteration: 0
          blockers:
            - "B1: AC5 の presence boolean 漏洩リスク"
            - "B2: docs/dev/secret-policy.md が Allowed Paths 未収録"
            - "B3: guard の対象が Bash のみ(Read/Grep/Glob 未検査)"
            - "B4: ask は Secret 防壁として不十分"
            - "B5: AC10 が shallow pattern 検出のみ"
            - "B6: VC が shallow grep 依存"
        - iteration: 1
          blockers:
            - "C11: decision: immediate に runtime-verification: true タグなし"
    
    FOLLOW_UP_MATERIALIZATION_RESULT_V1:
      schema_version: 1
      materialized_by: issue-refinement-loop
      follow_up_issues: []
      note_only_observations: []

    適用した改善

    • AC2: ask → deny(Secret 防壁は deny + PreToolUse exit 2 のみ)
    • AC3: Bash のみ → Read/Grep/Glob/Edit/Write path input も検査対象に拡張
    • AC5: presence boolean 許容 → secrets. を一切参照しない(Secret 名も公開 metadata になり得る)
    • AC10: shallow pattern → sentinel fixture ベース(raw/hash/base64/hex/urlencoded 全形式)
    • AC13 (新規): test_secret_boundary_contract.py による構造的 assert
    • Allowed Paths: docs/dev/secret-policy.md 追加(Secret Policy SSOT と実装の乖離防止)
    • VC: $ プレフィックス追加、sentinel / structural test コマンド追加
    • Runtime Verification Applicability: decision: immediate、<!-- runtime-verification: true --> タグ付与(AC3/AC4/AC10/AC13)
  5. squne121 commented on May 29, 2026

    @squne121
    OwnerAuthor

    Contract Review: BLOCKED (2026-05-30T00:00:00Z)

    CONTRACT_REVIEW_RESULT_V1:
      status: blocked
      generated_at: "2026-05-30T00:00:00Z"
      generated_by: issue-contract-review
      issue_url: https://github.com/squne121/loop-protocol/issues/412
      checks:
        template_compliance: pass
        state_label: ok
        allowed_paths_present: pass
        vc_present: pass
        stop_conditions_complete: pass
        vc_preflight:
          passed: false
          vc_failed_as_expected: 9
          vc_passed_unexpectedly: 2
          vc_unrunnable: 3
          vc_expected_pass: 0
          vc_skipped: 0
          classifications:
            - ac: AC1
              command: "jq -e '...index(Read(./.env))...' .claude/settings.json"
              exit_code: 1
              category: unknown
              scope_class: baseline_fail_expected
              confidence: low
              decision: human_judgment
            - ac: AC2
              command: "jq -e '...|test(\"gh secret|printenv|env|set|export|cat .env\")...' .claude/settings.json"
              exit_code: 0
              category: unexpected_pass
              scope_class: baseline_fail_expected
              confidence: medium
              decision: blocked
              fix_hint: "Write(assets/**) に含まれる 'set' サブストリングが regex にマッチした false positive"
            - ac: AC3
              command: "test -x .claude/hooks/secret_boundary_guard.sh"
              exit_code: 1
              category: unknown
              scope_class: baseline_fail_expected
              confidence: low
              decision: human_judgment
              fix_hint: "test -x は preflight が expected_baseline_fail と自動分類できない"
            - ac: AC3
              command: "printf '{...}' | .claude/hooks/secret_boundary_guard.sh; test \"$?\" -eq 2"
              exit_code: null
              category: compound_command_disallowed
              scope_class: baseline_fail_expected
              confidence: high
              decision: blocked
            - ac: AC4
              command: "uv run pytest .claude/hooks/tests/ -q -k \"secret_boundary_guard and stderr\""
              exit_code: 5
              category: regression_gate
              scope_class: baseline_fail_expected
              confidence: medium
              decision: blocked
              fix_hint: "新規 test file は未作成のため pytest exit 5(no tests)。regression_gate 扱いで blocked"
            - ac: AC6
              command: "rg -n 'permissions:' .github/workflows/session-manifest.yml"
              exit_code: 0
              category: unexpected_pass
              scope_class: baseline_fail_expected
              confidence: medium
              decision: blocked
              fix_hint: "permissions: は既に workflow に存在する(positive check → baseline pass が期待動作)"
            - ac: AC12
              command: "gh issue view 402 --json body --jq .body | rg '...'"
              exit_code: null
              category: compound_command_disallowed
              scope_class: baseline_fail_expected
              confidence: high
              decision: blocked
        ac_verifiability: pass
        product_spec_check:
          applicability: not_applicable
          decision: pass
        worktree_branch_collision: clear
      next_action: propose_refinement_loop
      blocked_reasons:
        - "VC preflight blocked: AC2/AC3/AC4/AC6/AC12 の VC 設計を修正が必要"
        - "Runtime Verification Applicability: decision: immediate に必要な applicable_acs / execution_environment / skip_conditions / fallback_policy / artifact_requirements が未記載"

    不足項目と修正指針

    VC preflight blocked (5件)

    AC2: jq regex の false positive

    • 現状: test("gh secret|printenv|env|set|export|cat .env") が Write(assets/**) の "set" サブストリングにマッチ
    • 修正: regex に Bash\( prefix を要求するか、アンカー付き pattern を使う
      # 修正例
      $ jq -e '[(.permissions.deny // []) | .[] | select(test("Bash\\(gh secret|Bash\\(printenv|Bash\\(printenv|Bash\\(env|Bash\\(set |Bash\\(export"))] | length > 0' .claude/settings.json

    AC3: compound command (pipe) が preflight 非対応

    • 現状: printf '{...}' | .claude/hooks/... は pipe で blocked
    • 修正: 以下を VC コマンド前行に追加(PR レビュー時のみ確認)
      # preflight-scope: pr_review_only
      $ printf '{...}' | .claude/hooks/secret_boundary_guard.sh; test "$?" -eq 2

    AC4: 新規テストが regression_gate 扱いで blocked

    • 現状: uv run pytest .claude/hooks/tests/ を regression_gate として分類、exit 5(no tests)で blocked
    • 修正: # preflight-scope: runtime_only を追加
      # preflight-scope: runtime_only
      $ uv run pytest .claude/hooks/tests/ -q -k "secret_boundary_guard and stderr"

    AC6: positive check が unexpected_pass

    • 現状: rg -n 'permissions:' .github/workflows/session-manifest.yml は既存 workflow が permissions を持つため baseline pass
    • 修正: # preflight-scope: regression_gate を追加(既存 permissions の維持を確認する regression guard)
      # preflight-scope: regression_gate
      $ rg -n 'permissions:' .github/workflows/session-manifest.yml

    AC12: compound command (pipe) が preflight 非対応

    Runtime Verification Applicability: decision: immediate に必要なフィールド不足

    decision: immediate には以下のフィールドが必要です(policy: docs/dev/runtime-verification-policy.md):

    ## Runtime Verification Applicability
    
    ```yaml
    decision: immediate
    applicable_acs: [AC3, AC4, AC10, AC13]
    execution_environment:
      tools: [uv, pytest]
      auth: none
      network: none
    skip_conditions: |
      uv または pytest が未インストールの場合: exit 77 で SKIP
    fallback_policy: |
      フォールバックなし。pytest pass/fail を正として扱う
    artifact_requirements: |
      artifacts/runtime-verification-AC<N>-<timestamp>.log
      (worktree-local、main に commit しない)
    rationale: |
      AC3/AC4/AC10/AC13 は uv run pytest で即時実行可能。
      AC1/AC2/AC5/AC6/AC7/AC8 は jq/rg 静的ファイル検査で決定論的に検証可能。
    
    また `## Stop Conditions` に以下を追記する必要があります:
    
    • 動作検証 AC の VC が SKIP(exit 77)を返した場合(uv/pytest 未インストール)
    
    ## 推奨アクション
    
    `issue-refinement-loop` を起動して上記修正を Issue 本文に反映してください。
    
    修正後、`issue-contract-review` を再実行して `status: go` になることを確認してから `impl-review-loop` を再開してください。
    
  6. squne121 commented on May 29, 2026

    @squne121
    OwnerAuthor

    issue-refinement-loop 完了

    LOOP_TERMINATION_RESULT_V1:
      termination_reason: approved
      max_iterations: 3
      iterations_used: 2
      blockers_history:
        - iteration: 0
          blockers:
            - "B1–B6: anchor comment (squne121, 2026-05-29) の Secret boundary contract 修正"
            - "C4/C9/C11: VC format / Runtime Verification Applicability"
        - iteration: 1
          blockers:
            - "VC preflight blocked: AC2 false positive / AC3/AC12 compound / AC4 regression_gate 誤分類 / AC6 unexpected_pass"
            - "Runtime Verification Applicability: 必須フィールド不足(applicable_acs 等)"
    
    FOLLOW_UP_MATERIALIZATION_RESULT_V1:
      schema_version: 1
      materialized_by: issue-refinement-loop
      follow_up_issues: []
      note_only_observations: []

    適用した改善(iteration 0 + anchor-comment-driven Step 4)

    iteration 0(squne121 anchor から)

    • AC2 ask → deny
    • AC3 Bash + Read/Grep/Glob/Edit/Write path input 検査追加
    • AC5 secrets. 完全禁止
    • AC10 sentinel fixture ベース更新
    • AC13 structural test assert 新規追加
    • Allowed Paths に docs/dev/secret-policy.md 追加
    • decision: immediate + <!-- runtime-verification: true --> タグ付与

    iteration 1(issue-contract-review BLOCKED anchor から)

    • AC2 jq regex false positive 修正(startswith("Bash(") 追加)
    • AC3/AC12 compound VC に # preflight-scope: pr_review_only
    • AC4 新規 pytest に # preflight-scope: runtime_only
    • AC6 positive check に # preflight-scope: pr_review_only
    • AC1/AC2/AC3 jq/test-x に # preflight-scope: runtime_only
    • Runtime Verification Applicability: applicable_acs / execution_environment / skip_conditions / fallback_policy / artifact_requirements 追加
    • Stop Conditions に SKIP exit 77 条件追加

    VC preflight 最終結果

    status: pass
    expected_fail: 9 / unexpected_pass: 0 / blocked: 0 / human_judgment: 0 / skipped: 7
    
  7. squne121 commented on May 29, 2026

    @squne121
    OwnerAuthor

    Contract Snapshot (2026-05-29T23:43:04Z)

    CONTRACT_REVIEW_RESULT_V1:
      status: go
      generated_at: "2026-05-29T23:43:04Z"
      generated_by: issue-contract-review
      issue_url: https://github.com/squne121/loop-protocol/issues/412
      checks:
        template_compliance: pass
        state_label: ok
        allowed_paths_present: pass
        vc_present: pass
        stop_conditions_complete: pass
        vc_preflight:
          passed: true
          vc_failed_as_expected: 9
          vc_passed_unexpectedly: 0
          vc_unrunnable: 0
          vc_expected_pass: 0
          vc_skipped: 7
          classifications:
            - ac: AC1
              command: "jq -e '...' .claude/settings.json"
              scope_class: runtime_only
              classification: skipped
              decision: go
              verification_owner: impl-review-loop
              runtime_verification_required: true
            - ac: AC2
              command: "jq -e '... startswith(\"Bash(\") ...' .claude/settings.json"
              scope_class: runtime_only
              classification: skipped
              decision: go
              verification_owner: impl-review-loop
              runtime_verification_required: true
            - ac: AC2
              command: "! rg -Pn '\"ask\"...' .claude/settings.json"
              scope_class: baseline_fail_expected
              classification: expected_fail
              decision: go
            - ac: AC3
              command: "test -x .claude/hooks/secret_boundary_guard.sh"
              scope_class: runtime_only
              classification: skipped
              decision: go
              verification_owner: impl-review-loop
              runtime_verification_required: true
            - ac: AC3
              command: "printf '{...}' | .claude/hooks/..."
              scope_class: pr_review_only
              classification: skipped
              decision: go
              verification_owner: pr-review-judge
              runtime_verification_required: false
            - ac: AC4
              command: "uv run pytest .claude/hooks/tests/ -q -k ..."
              scope_class: runtime_only
              classification: skipped
              decision: go
              verification_owner: impl-review-loop
              runtime_verification_required: true
            - ac: AC5
              command: "! rg -n 'secrets\.' .github/workflows/session-manifest.yml"
              scope_class: baseline_fail_expected
              classification: expected_fail
              decision: go
            - ac: AC6
              command: "! rg -n 'write-all|issues:\s*write|...' ..."
              scope_class: baseline_fail_expected
              classification: expected_fail
              decision: go
            - ac: AC6
              command: "rg -n 'permissions:' ..."
              scope_class: pr_review_only
              classification: skipped
              decision: go
              verification_owner: pr-review-judge
              runtime_verification_required: false
            - ac: AC7
              command: "! rg -n 'pull_request_target' ..."
              scope_class: baseline_fail_expected
              classification: expected_fail
              decision: go
            - ac: AC8
              command: "! rg -n 'gh issue comment|...' ..."
              scope_class: baseline_fail_expected
              classification: expected_fail
              decision: go
            - ac: AC9
              command: "rg -n 'secret_policy|value_exposed' ..."
              scope_class: baseline_fail_expected
              classification: expected_fail
              decision: go
            - ac: AC10
              command: "uv run pytest .claude/hooks/tests/test_secret_boundary_contract.py -v -k sentinel"
              scope_class: baseline_fail_expected
              classification: expected_fail
              decision: go
            - ac: AC11
              command: "rg -n 'presence / metadata|...' docs/dev/session-recording-policy.md"
              scope_class: baseline_fail_expected
              classification: expected_fail
              decision: go
            - ac: AC12
              command: "gh issue view 402 ... | rg '...'"
              scope_class: pr_review_only
              classification: skipped
              decision: go
              verification_owner: pr-review-judge
              runtime_verification_required: false
            - ac: AC13
              command: "uv run pytest .claude/hooks/tests/test_secret_boundary_contract.py -v"
              scope_class: baseline_fail_expected
              classification: expected_fail
              decision: go
        ac_verifiability: pass
        product_spec_check:
          applicability: not_applicable
          decision: pass
        worktree_branch_collision: clear
      next_action: implement_issue
      blocked_reasons: []
      warnings: []

    • Outcome: Claude Code / hook / GitHub Actions の measurement pipeline が Secret 値を入力・出力・artifact 化せず、presence boolean と metadata だけを扱う fail-closed boundary と structural test が追加されている状態。
    • Worktree: .claude/worktrees/issue-412-claude-code-github-actions-secret-secure
    • Branch: worktree-issue-412-claude-code-github-actions-secret-secure
    • VC preflight: baseline fail = 9, 想定外 pass = 0, 実行不可 = 0, skipped = 7 (runtime_only/pr_review_only)
  8. squne121 commented on May 29, 2026

    @squne121
    OwnerAuthor

    implement-issue: 実装完了 (2026-05-29T23:51:10Z)

  9. added a commit that references this issue on May 30, 2026
  10. squne121 commented on May 30, 2026

    @squne121
    OwnerAuthor

    implement-issue: iteration-1 blockers fix 完了 (2026-05-30T00:09:20Z)

    ブロッカー対応サマリ

    ID 内容 対応
    B1 settings.json deny に env/set 系がない Bash(env)/Bash(env *)/Bash(set)/Bash(set *) を permissions.deny に追加
    B2 secret_boundary_guard.sh の grep -P 依存(macOS fail-open) grep -E (POSIX ERE) + case 文に置き換え
    B3 secret_policy schema が unsafe mode 許容 value_exposed を const: false に固定、mode を presence_only のみ許容
    B4 AC10 テストが sha256/sha1/partial leak 未検証 _encode_variants に sha256/sha1/prefix/suffix partial を追加、pytest.skip を fixture artifact 生成に変更
    B5 sed/awk/python 等の迂回路が未検出 guard に sed/awk/perl/python/.env source 検出を追加、bypass regression テスト 4 件追加

    Verification Results

    • pytest (18/18 PASS)
    • pnpm typecheck: PASS
    • pnpm lint: PASS
    • pnpm test: 179/179 PASS
    • pnpm build: PASS
  11. added 2 commits that reference this issue on May 30, 2026
  12. cschanhniem commented on Jun 18, 2026

    @cschanhniem

    Fail-closed on secrets is the right default, and the cleanest way to implement it without touching the agent's own logic is a policy layer that sits upstream of every agent action. AGENTOWNERS does that at the GitHub level: the .github/AGENTOWNERS.yml declares that Claude Code requires explicit maintainer approval before acting on any path that touches secrets or config, and the Action blocks execution until that approval is recorded. https://github.com/cschanhniem/AGENTOWNERS

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/implementerarea/ai-opsarea/securityenhancementfollow-upkind/implementationphase/implementation

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions