Repository navigation
Closed
Labels
agent/implementerAI implementer agentarea/ai-opsAI operations and agent tooling areaarea/securitySecurity areaenhancementNew feature or requestfollow-up後続 Issue として切り出された follow-upkind/implementationImplementation issuephase/implementationImplementation phase
Description
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: workflowParent Issue
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 によるPreToolUsefail-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.denygh secret,printenv,env,set,export -p,.env読み取り系 command に対するdeny(askは non-interactive 実行・承認疲れ・PR override により Secret 防壁として不十分)
.claude/hooks/secret_boundary_guard.shPreToolUsestdin JSON から高リスク command(cat .env,printenv,env,gh secret,python -c 'import os',node -e 'console.log(process.env)'等)を検知し、exit code 2 で blockRead/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.ymlsecrets.を一切参照しない(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がPreToolUsestdin 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にPreToolUsesecret_boundary_guardhook が存在する / 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 -vAllowed Paths
.claude/settings.json.claude/hooks/secret_boundary_guard.sh.claude/hooks/tests/.github/workflows/session-manifest.ymldocs/dev/session-recording-policy.mddocs/schemas/agent-session-manifest.mddocs/schemas/agent-session-manifest.schema.jsondocs/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
- Source comment: 実装: agent_session_manifest/v1 producer を .claude/settings.json hooks と .github/workflows で自動 invoke する #402 (comment)
- Split decision: 実装: agent_session_manifest/v1 producer を .claude/settings.json hooks と .github/workflows で自動 invoke する #402 (comment)
#402は manifest producer の hook / CI wiring を主責務とし、Secret / token management は本文上も out of scope であるため、本 Issue を upstream security sibling として分離する- GitHub Secrets は API / UI で name / visibility / updated_at などの metadata は扱えるが、value は返らない。この性質を運用 contract に取り込み、measurement pipeline では value を扱わない
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 に出現しないことを機械的に検証
- session-manifest workflow:
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"Metadata
Metadata
Assignees
Labels
agent/implementerAI implementer agentarea/ai-opsAI operations and agent tooling areaarea/securitySecurity areaenhancementNew feature or requestfollow-up後続 Issue として切り出された follow-upkind/implementationImplementation issuephase/implementationImplementation phase
Activity
fix(#402): iteration 3 — exec-form, best-effort exit 0, stable-key du…
feat(#402): wire agent_session_manifest/v1 producer to hooks and CI (#…
squne121 commentedon May 29, 2026
総合判定: 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だけでなくReadtool、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 してください。高品質化した受け入れ条件案
#412 の acceptance criteria は次のように締め直すべきです。
この形なら #242 の Secret Policy、#402/#426 の manifest artifact 化、#377/#401 の producer/schema と接続できます。単に「
.claude/settings.jsonに deny を足した」だけでは、#412 の親目的である telemetry/manifest pipeline からの Secret 排除を満たしたとは言えません。([GitHub]2)実装レビューコメントとしての結論
公開ページで確認できる範囲では、#412 自体にはまだ紐づく PR/branch は見当たらず、関連実装・レビュー文脈は #402/#426 側が中心です。したがって現時点のレビュー対象は「実装済み PR」ではなく、issue contract の不足を先に潰すレビューとして扱うのが妥当です。([GitHub]1)
squne121 commentedon May 29, 2026
issue-refinement-loop 完了
適用した改善
ask→deny(Secret 防壁は deny + PreToolUse exit 2 のみ)Read/Grep/Glob/Edit/Writepath input も検査対象に拡張secrets.を一切参照しない(Secret 名も公開 metadata になり得る)test_secret_boundary_contract.pyによる構造的 assertdocs/dev/secret-policy.md追加(Secret Policy SSOT と実装の乖離防止)$プレフィックス追加、sentinel / structural test コマンド追加decision: immediate、<!-- runtime-verification: true -->タグ付与(AC3/AC4/AC10/AC13)squne121 commentedon May 29, 2026
Contract Review: BLOCKED (2026-05-30T00:00:00Z)
不足項目と修正指針
VC preflight blocked (5件)
AC2: jq regex の false positive
test("gh secret|printenv|env|set|export|cat .env")がWrite(assets/**)の "set" サブストリングにマッチBash\(prefix を要求するか、アンカー付き pattern を使うAC3: compound command (pipe) が preflight 非対応
printf '{...}' | .claude/hooks/...は pipe で blockedAC4: 新規テストが regression_gate 扱いで blocked
uv run pytest .claude/hooks/tests/を regression_gate として分類、exit 5(no tests)で blocked# preflight-scope: runtime_onlyを追加AC6: positive check が unexpected_pass
rg -n 'permissions:' .github/workflows/session-manifest.ymlは既存 workflow が permissions を持つため baseline pass# preflight-scope: regression_gateを追加(既存 permissions の維持を確認する regression guard)AC12: compound command (pipe) が preflight 非対応
gh issue view 402 ... | rg '...'は pipe で blocked# preflight-scope: pr_review_onlyを追加(実装: agent_session_manifest/v1 producer を .claude/settings.json hooks と .github/workflows で自動 invoke する #402 リンクは PR レビュー時に人間が確認)Runtime Verification Applicability: decision: immediate に必要なフィールド不足
decision: immediateには以下のフィールドが必要です(policy:docs/dev/runtime-verification-policy.md):squne121 commentedon May 29, 2026
issue-refinement-loop 完了
適用した改善(iteration 0 + anchor-comment-driven Step 4)
iteration 0(squne121 anchor から)
ask→denysecrets.完全禁止docs/dev/secret-policy.md追加decision: immediate+<!-- runtime-verification: true -->タグ付与iteration 1(issue-contract-review BLOCKED anchor から)
startswith("Bash(")追加)# preflight-scope: pr_review_only# preflight-scope: runtime_only# preflight-scope: pr_review_only# preflight-scope: runtime_onlyapplicable_acs/execution_environment/skip_conditions/fallback_policy/artifact_requirements追加VC preflight 最終結果
squne121 commentedon May 29, 2026
Contract Snapshot (2026-05-29T23:43:04Z)
.claude/worktrees/issue-412-claude-code-github-actions-secret-secureworktree-issue-412-claude-code-github-actions-secret-securesqune121 commentedon May 29, 2026
implement-issue: 実装完了 (2026-05-29T23:51:10Z)
.claude/worktrees/issue-412-claude-code-github-actions-secret-secureworktree-issue-412-claude-code-github-actions-secret-securefix(#412): address iteration-1 blockers for secret boundary guard (B1…
squne121 commentedon May 30, 2026
implement-issue: iteration-1 blockers fix 完了 (2026-05-30T00:09:20Z)
worktree-issue-412-claude-code-github-actions-secret-secure29ffe44ブロッカー対応サマリ
Verification Results
fix(#412): address B1-B4 blockers from PR #495 review
feat(#412): secret boundary guard — fail-closed PreToolUse hook + den…
cschanhniem commentedon Jun 18, 2026
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