Skip to content

実装: security(latitude): telemetry credential / preload capture を封じ込め、Secret Inventory / Kill Switch を fail-closed 化する #1157

Closed

Description

@squne121

Machine-Readable Contract

contract_schema_version: v1
issue_kind: implementation
parent_issue: "#1153"
goal_ref: "Latitude Claude Code telemetry の credential・export・preload capture・local payload・active process・uninstall state を既存 Secret Inventory / session recording Kill Switch に接続し、実開発 session 可否をsecret非出力でfail-closed判定する"
change_kind: mixed

Parent Issue

#1153

Parent Goal Ref

EntireCLI / Latitude のprivate observationをpublic-safeなagent_run_reportへ接続する前に、現在導入済みとされるLatitude credential・Stop hook・BUN_OPTIONS preload・systemd user environmentを安全境界へ収容する。

Dependencies

本Issueは次をblockする。

Background

#1153は以下を導入済み状態として記載している。

  • Latitude API keyをローカルClaude Code設定へ追加済み
  • Latitude Stop hook導入済み
  • preload導入済み
  • systemd user environmentへBUN_OPTIONS導入済み
  • trace到達、hook共存、uninstall postconditionは未検証

既存Secret Inventoryではagent_local_secretはapp_secretへmappingされる。
既存session recording policyではapp_secret時のsession recordingは不許可である。

また、LATITUDE_CLAUDE_CODE_ENABLED=0 はexport hookを停止するが、preload capture停止の証明にはならない。
本Issue完了までは実開発sessionを実行しない。

Immediate Safety State

pilot_state: BLOCKED
real_development_session_allowed: false
runtime_inventory_status: pending
policy_consistent: false
synthetic_fixture_test_allowed: true
read_only_host_inventory_allowed: true
real_prompt_allowed: false
real_trace_export_allowed: false

Decision Boundary

本IssueはLatitude telemetryを許可するpolicy exceptionを導入しない。

Latitude credentialを保持したままreal pilotを行う場合は、本Issue完了後に別Child Issueを起票し、人間Decisionを経て以下を定義する。

  • credential category
  • storage boundary
  • captured processからのcredential分離方法
  • rotation owner
  • revoke手順
  • provider-side retention/delete手順
  • time-bounded pilot activation
  • automatic rollback
  • risk acceptance

承認Issueが存在しない場合、既存policyを維持し、real captureはBLOCKEDのままとする。

Outcome

以下が成立している状態。

  1. Secret Inventoryの記述とruntime stateが矛盾しない
  2. Latitudeのexport停止とcapture停止が別stateとして定義されている
  3. 既存runtime safety checkerがLatitude surfaceをsecret非出力で検査する
  4. partial uninstall、backup残留、active processへのpreload継承をfail closed検出する
  5. unpinned package/hook commandをblocked判定する
  6. Kill Switch後のpostconditionを機械検証できる
  7. unrelatedなClaude settings / hooksを破壊しない手順になっている
  8. 実API key、prompt、request body、local absolute pathをIssue・stdout・artifactへ出さない

Runtime Safety Result Contract

既存 .claude/scripts/check_session_recording_runtime_safety.py をcanonical entrypointとし、独立した第三のruntime checkerを増設しない。

--json 時は以下のschemaに従う。

schema: session_recording_runtime_safety/v2
decision: allow | deny
verdict: safe | blocked | fail_closed | not_applicable
inspection_complete: true | false
exit_code: 0 | 1 | 2

execution_profile: host | fixture
runtime_locus: linux | wsl | macos | windows_host | unknown

policy:
  source: docs/dev/secret-policy.md
  source_digest: sha256:<digest>
  current_secrets_mode: none | publish_secret | app_secret | unknown

components:
  entire:
    applicability: applicable | not_applicable | unknown
    verdict: safe | blocked | fail_closed | not_applicable
    reason_codes: []

  latitude:
    applicability: applicable | not_applicable | unknown
    verdict: safe | blocked | fail_closed | not_applicable

    containment_state: never_observed | active | contained | unknown
    credential_state: present | absent | unknown
    export_state: enabled | disabled | unknown
    capture_state: active | inactive | unknown
    local_storage_state: absent | present | unsafe_metadata | unknown
    active_process_state: preload_present | preload_absent | unknown
    destination_state: approved_cloud | approved_self_host | unapproved | unknown
    transport_state: https | plaintext | unknown
    diagnostic_logging_state: disabled | enabled | unknown
    exposure_state: none_observed | possible | confirmed | unknown
    uninstall_state: complete | incomplete | not_attempted | unknown
    remote_trace_state: absent_human_attested | present | unknown

    distribution:
      package_spec: string | null
      dist_integrity: string | null
      registry_signature_verified: true | false | null
      provenance_verified: true | false | null
      provenance_source_ref: string | null
      tarball_sha256: string | null
      installed_entrypoint_sha256: string | null
      preload_sha256: string | null
      resolution_source: local_lockfile | npm_cache | remote_fetch | unknown

    reason_codes: []
    checked_surfaces: []
    raw_values_emitted: false
    checked_at: ISO8601

checked_at: ISO8601

Execution Profile

execution_profile: host:

  • SRRS_* 環境変数による外部状態 override を拒否する
  • docs/dev/secret-policy.md を canonical YAML として直接読み、source_digest を出力する
  • policy が読めない、複数 block がある、schema 不一致の場合は fail_closed

execution_profile: fixture:

  • 明示的な --fixture-root または --test-mode フラグがある場合にのみ許可する
  • SRRS_* override は fixture mode でのみ有効

Sensitive Value Handling

credential value や environment 値の取り扱いを以下で固定する。

sensitive_value_handling:
  human_visible: forbidden
  stdout_or_stderr: forbidden
  artifact_or_snapshot: forbidden
  logging_or_hashing: forbidden
  equality_comparison_against_known_secret: forbidden
  bounded_in_memory_presence_scan: allowed
  persistence_after_scan: forbidden

subprocess の raw stderr をそのまま転送しない。--json 時は stdout を単一 JSON object のみとする。

Global Aggregation Truth Table

コンポーネント verdict から top-level verdict を次の優先順位で決定する。

1. 既知 blocker ≥ 1              → verdict=blocked,      exit=1
2. unknown ≥ 1, 既知 blocker=0   → verdict=fail_closed,  exit=2
3. 全 applicable コンポーネント safe → verdict=safe,        exit=0
4. 全コンポーネント not_applicable   → verdict=not_applicable, exit=0

blocked と fail_closed が同時の場合は blocked を優先し、inspection_complete=false を残す。

Verdict Rules

not_applicable:

  • Latitude credential、hook、preload、state、backup、active process indicator がすべて存在しない
  • unknown surface がない

safe:

  • 現行 policy 上 current_secrets_mode == none
  • credential field が存在しない
  • Latitude Stop hook が存在しない
  • BUN_OPTIONS preload が settings / systemd / environment.d / launchctl / active process に存在しない
  • local_storage_state が absent
  • settings backup に Latitude credential field が存在しない
  • unknown surface がない
  • containment_state が never_observed かつ exposure_state: none_observed かつ rotation/delete が不要

blocked:

  • 危険な既知状態を 1 件以上検出した
  • credential present
  • hook present
  • preload configured
  • active process が preload を継承
  • export disabled かつ capture active
  • local_storage_state が present または unsafe_metadata
  • backup に credential field present
  • distribution unpinned または integrity/provenance 不明
  • uninstall incomplete
  • policy mode mismatch
  • destination_state が unapproved
  • transport_state が plaintext または unknown
  • diagnostic_logging_state が enabled
  • exposure_state が possible または confirmed
  • containment_state が active

fail_closed:

  • 対象 surface を安全に検査できない
  • settings parse error / permission error
  • process environment inspection unavailable
  • systemd / launchctl state が判定不能
  • package version/integrity 不明
  • runtime_locus: unknown(WSL2 から Windows host が検査不能な場合)
  • policy YAML が読めない / schema 不一致
  • runtime state と policy state の対応が不明

Reason Codes

最低限、以下を固定する。

reason_codes:
  - latitude_credential_present
  - latitude_policy_mode_mismatch
  - latitude_stop_hook_present
  - latitude_preload_configured
  - latitude_preload_active_process
  - latitude_export_disabled_capture_active
  - latitude_local_storage_present
  - latitude_local_storage_unsafe_metadata
  - latitude_settings_backup_contains_credential_field
  - latitude_uninstall_incomplete
  - latitude_runtime_state_unknown
  - latitude_distribution_unpinned
  - latitude_distribution_provenance_unknown
  - latitude_remote_trace_state_unknown
  - latitude_destination_unapproved
  - latitude_transport_plaintext_or_unknown
  - latitude_diagnostic_logging_enabled
  - latitude_exposure_possible_or_confirmed
  - latitude_windows_host_not_inspected
  - latitude_srrs_override_rejected

Checked Surfaces

値や絶対 path ではなく、以下の logical surface 名だけを出力する。

checked_surfaces:
  - claude_user_settings
  - claude_project_settings
  - claude_local_settings
  - managed_claude_settings
  - enabled_plugin_hooks
  - active_skill_agent_hooks
  - latitude_settings_backup
  - latitude_stop_hook
  - settings_bun_options
  - shell_startup_environment
  - systemd_user_environment
  - systemd_environment_generators
  - environment_d_dropin
  - launchctl_environment
  - launch_agent_plist
  - current_shell_environment
  - process_parent_environment
  - latitude_intercept_preload
  - latitude_request_spool
  - latitude_state
  - active_claude_processes
  - package_distribution

WSL2 から Windows host(Desktop / IDE extension host / Windows process environment)が検査不能な場合は runtime_locus: unknown として fail_closed にする。

In Scope

  • docs/dev/secret-policy.md

    • 現在の credential state との整合
    • Latitude API key の agent_local_secret 分類
    • storage / rotation owner / revoke 条件
    • false current_secrets_mode: none の禁止
  • docs/dev/session-recording-policy.md

    • export pause / capture pause / uninstall / credential revoke の分離
    • preload active 時の Kill Switch 判定
    • real session start gate
    • partial uninstall 時の fail-closed
  • runtime checker

    • execution_profile: host で SRRS_* override を拒否する
    • docs/dev/secret-policy.md を canonical YAML として直接読み source_digest を出力する
    • sensitive_value_handling 規則を適用し credential value / full environment を emit しない
    • request spool / state は存在判定のみ行い本文を読まない
    • process environment は対象 key の存在判定のみ行い全 env を出力しない
    • WSL2/Linux の systemd user environment / environment.d を検査する
    • macOS launchctl / plist は fixture で検査する
    • active Claude process に継承された BUN_OPTIONS を検査する
    • managed policy / plugin hook / skill / agent frontmatter で定義された Latitude hook を検査する
    • shell startup file(.bashrc / .profile / .zshrc 等)の BUN_OPTIONS 設定を検査する
    • systemd environment generator の BUN_OPTIONS 設定を検査する
  • uninstall verification

    • official uninstall 実行結果を信用せず postcondition を再検査する

    • quiescent な二段階 postcondition を必須にする:

      1. 新規起動経路の BUN_OPTIONS / hook を停止
      2. Claude CLI / Desktop / IDE extension host / 関連 Bun process を停止
      3. active process inheritance を再検査
      4. settings / backup / state / spool / preload を検査・除去
      5. 静止後に 2 回目の read-only scan
      6. 2 回の結果が同一かつ対象 process が存在しない場合のみ contained
    • latitude_state / request spool の lstat(owner / mode / symlink / non-regular file)を検査する

    • settings backup の credential field 残留を検査する

    • unrelated hook / setting を保持する

    • file deletion を secure erase と表現しない

    • 漏洩可能性がある場合は revoke / rotate を優先する

  • distribution verification

    • exact version / integrity / preload digest
    • unpinned npx command 検出
    • npm registry signature / provenance 検証(npm audit signatures)
    • provenance_source_ref を distribution evidence へ記録する
    • LATITUDE_BASE_URL が未承認 origin / 非 HTTPS / parse 不能の場合は blocked
    • LATITUDE_DEBUG=1 は real session では blocked 対象
  • credential argv policy

    • real key を argv へ渡すことを禁止
    • 過去に argv 利用の可能性がある場合は exposure_state: possible
    • shell history を自動収集しない
    • rotation 完了まで real session を再開しない
  • fixtures / negative controls

  • package script / composite security gate 統合

    • security:session-recording:fixture — deterministic fixture checks
    • security:session-recording:host — --execution-profile host --json による live check
    • security:session-recording — fixture checks only(generic CI 向け)
  • parent 導入: EntireCLI + Latitude の観測データを agent_run_report に接続し、GitHub 経由の ChatGPT レトロ動線を確立する #1153 への BLOCKED 状態と closure evidence 記録

Out of Scope

  • 実 API key を使用した test
  • 実開発 prompt の実行
  • Latitude Cloud への trace 送信
  • provider-side trace 削除操作
  • API key の revoke / rotate 操作そのもの
  • Latitude 利用を許可する policy exception
  • EntireCLI checker の仕様変更
  • private source から agent_run_report への adapter
  • ChatGPT marker
  • self-host 構築
  • Latitude package の fork
  • Windows host からの直接検査(WSL2 からは不可; runtime_locus: unknown → fail_closed とする)

Current Validated Scope

本 Issue 着手時点で確認済みの前提状態:

Remaining Parent Gaps

(本 Issue 完了後、以下は #1153 の責務に戻す)

  • Latitude real pilot 可否の人間 Decision(Child A1 の責務)
  • 3 agent surface の capability 確定(Child B の責務)
  • private source → public-safe adapter(Child C0/C1 の責務)

Acceptance Criteria

  • AC0: 導入: EntireCLI + Latitude の観測データを agent_run_report に接続し、GitHub 経由の ChatGPT レトロ動線を確立する #1153 に pilot_state: BLOCKED、real_development_session_allowed: false が記録されている
  • AC1: Secret Inventory の current_secrets_mode、agent_local_secret_present、本文の Latitude credential 記述が機械的に矛盾しない
  • AC2: session recording policy が export 停止と capture 停止を別 state として定義している
  • AC3: session_recording_runtime_safety/v2 が Latitude component を出力する
  • AC4: settings / hook / BUN_OPTIONS / systemd / environment.d / launchctl / preload / request spool / backup / active process の各 surface を検査する
  • AC5: LATITUDE_CLAUDE_CODE_ENABLED=0 かつ preload active fixture が latitude_export_disabled_capture_active で blocked になる
  • AC6: Stop hook 削除済みでも active process が preload を継承している fixture が blocked になる
  • AC7: official uninstall 後に backup へ credential field が残る fixture が blocked になる
  • AC8: uninstall 途中失敗 fixture が latitude_uninstall_incomplete になる
  • AC9: unversioned / integrity 不明の hook command が latitude_distribution_unpinned になる
  • AC10: credential value、request body、prompt、tool I/O、full environment、local absolute path を stdout / JSON / test snapshot へ出さない
  • AC11: UUID 形式等、prefix を仮定できない credential value でも、LATITUDE_API_KEY field の存在を構造的に検出する
  • AC12: unrelated な Claude hooks / env / permissions を fixture 上で保持する
  • AC13: checker を 2 回実行して同一結果となり、host state を変更しない
  • AC14: security:session-recording が Latitude runtime check を含む
  • AC15: WSL2/Linux 上で read-only live inventory を実行し、secret 非出力の machine-readable verdict を取得する
  • AC16: remote trace state が確認不能な場合、PASS でなく unknown と人間 escalation を記録する
  • AC17: real pilot 再開には別 Issue の人間 Decision が必要であることが parent へ記録されている
  • AC18: top-level verdict が global aggregation truth table に従い、entire component が blocked でも latitude component が safe / not_applicable であることを個別に記録する
  • AC19: execution_profile: host で SRRS_* 環境変数 override を渡した場合に rejected として fail_closed を返す
  • AC20: sensitive_value_handling 規則を適用し、subprocess raw stderr を転送せず stdout が単一 JSON object である
  • AC21: managed policy / plugin hook / skill / agent frontmatter の Latitude hook 有無を検査し、不明な場合は fail_closed を返す
  • AC22: latitude_state / request spool の lstat(owner / mode / symlink / non-regular file)を検査し、unsafe metadata で blocked になる
  • AC23: LATITUDE_BASE_URL が未承認 origin または非 HTTPS の fixture が latitude_destination_unapproved で blocked になる
  • AC24: LATITUDE_DEBUG=1 fixture が latitude_diagnostic_logging_enabled で blocked になる
  • AC25: quiescent 二段階 postcondition を fixture で検証し、1 回目と 2 回目の scan 結果が同一で対象 process が存在しないことを確認する
  • AC26: npm registry signature / provenance が検証できない fixture が latitude_distribution_provenance_unknown で blocked になる
  • AC27: containment_state が never_observed 以外の場合、safe を返さず blocked または fail_closed を返す
  • AC28: real API key を argv で渡すことを禁止し、argv に credential が含まれる fixture が exposure_state: possible で blocked になる
  • AC29: fixture path tests/fixtures/session-recording-runtime-safety/** が利用可能で、security:session-recording:fixture / :host スクリプトが分離されている

Verification Commands

$ pnpm typecheck
# AC1

$ pnpm lint
# AC10

# preflight-scope: pr_review_only
$ pnpm test
# AC3
# AC4
# AC5
# AC6
# AC7
# AC8
# AC9
# AC11
# AC12
# AC13
# AC14
# AC18
# AC19
# AC20
# AC21
# AC22
# AC23
# AC24
# AC25
# AC26
# AC27
# AC28
# AC29

$ pnpm build
# AC14

# baseline-expect: pass
$ test -f .claude/scripts/check_session_recording_runtime_safety.py
# AC3

# baseline-expect: pass
$ test -f tests/session_recording_runtime_safety.test.ts
# AC29

# preflight-scope: runtime_only
$ uv run python3 .claude/scripts/check_session_recording_runtime_safety.py --json --execution-profile fixture --fixture-root tests/fixtures/session-recording-runtime-safety
# AC15
# AC16
# AC17

# preflight-scope: pr_review_only
$ pnpm policy:check
# AC0
# AC1
# AC2

# preflight-scope: pr_review_only
$ pnpm secret-exposure:scan:clean
# AC10

# preflight-scope: pr_review_only
$ pnpm session-recording:smoke
# AC14

# preflight-scope: pr_review_only
$ pnpm security:session-recording:fixture
# AC29

# preflight-scope: pr_review_only
$ pnpm security:session-recording:host
# AC15

live runtime では secret 値や full environment を表示するコマンドを使用しない。

Allowed Paths

  • docs/dev/secret-policy.md
  • docs/dev/session-recording-policy.md
  • docs/dev/onboarding/session-recording-tool.md
  • .claude/scripts/check_secret_policy.py
  • .claude/scripts/check_session_recording_policy.py
  • .claude/scripts/check_session_recording_runtime_safety.py
  • .claude/scripts/secret_exposure_scanner.py
  • tests/session_recording_runtime_safety.test.ts
  • tests/fixtures/session-recording/**
  • tests/fixtures/session-recording-runtime-safety/**
  • package.json

新規 module が必要な場合は以下だけを Scope Delta 候補とする。

  • .claude/scripts/lib/latitude_telemetry_safety.py
  • .claude/scripts/lib/__init__.py

Runtime Verification Applicability

decision: immediate
applicable_acs:
  - AC3
  - AC4
  - AC5
  - AC6
  - AC7
  - AC8
  - AC9
  - AC13
  - AC15
  - AC18
  - AC19
  - AC20
  - AC21
  - AC22
  - AC23
  - AC24
  - AC25
  - AC26
  - AC27
execution_environment: WSL2/Linux
skip_conditions:
  - runtime_locus is not linux or wsl
  - execution_profile is fixture
fallback_policy: fail_closed
artifact_requirements:
  - runtime_safety_checker_output_json
primary_environment: WSL2/Linux
allowed_live_operations:
  - read_only_settings_structure_check
  - exact_environment_key_presence_check
  - process_preload_presence_check
  - local_state_presence_check
  - package_version_and_integrity_check
forbidden_live_operations:
  - real_prompt_execution
  - trace_upload
  - credential_value_output
  - request_body_read
  - full_environment_dump
  - automatic_settings_mutation
macos:
  decision: fixture_required
  reason: "primary runtime が WSL2/Linux のため、launchctl/plist は fixture 検証する"
windows_host:
  decision: not_applicable
  reason: "WSL2 から Windows host を直接検査できないため fail_closed とし、Out of Scope に含める"

Stop Conditions

  • credential value を読む、表示する、hash 化する必要が生じた場合
  • request spool 本文を読む必要が生じた場合
  • full environment dump が必要になった場合
  • unrelated な Claude 設定を置換する必要が生じた場合
  • active process の preload 有無を安全に検証できない場合
  • unpinned package しか実行できない場合
  • runtime checker 間で verdict または reason semantics が競合した場合
  • policy exception なしに real telemetry を有効化しようとした場合
  • remote trace 存在が疑われる場合は削除完了を自己判定せず、人間へ escalate する
  • raw payload または credential が public surface へ出た場合は即時停止し、revoke / rotate を優先する
  • Allowed Paths 外の変更が必要になった場合

Required Skills

  • Python
  • fail-closed runtime verification
  • Secret Inventory / Kill Switch policy
  • Claude Code hook configuration
  • systemd user environment
  • npm registry / provenance verification
  • secure fixture design

Open Questions

  • remote_trace_state の確認は人間 attestation のみとするか、または機械的な確認手順を定義するか(absent_human_attested の扱いは containment_state で代替可能か)

Next Action

  1. issue-contract-review を実施し go を取得する
  2. impl-review-loop を起動する

Artifact Refs

Handoff Prompt Draft

#1157 を実装してください。
Latitude telemetry の credential / export / capture / preload / uninstall state を
既存 check_session_recording_runtime_safety.py に latitude component として追加し、
secret 非出力・fail-closed の runtime safety checker を構築します。
execution_profile: host/fixture、global aggregation truth table、
sensitive_value_handling、quiescent 二段階 postcondition、
npm provenance 検証を含む v2 contract に従ってください。
Issue contract を正本として扱い、Allowed Paths 内のみ変更してください。

Delivery Rule

  • 1 Issue = 1 PR
  • Draft PR を既定とする
  • 実開発 session は実行しない
  • worker 自己申告を authoritative runtime evidence にしない
  • live verification 結果は checker 出力と validation exit code で記録する

Closure Evidence

本 Issue コメントへ、次の public-safe marker を 1 件記録する。

{
  "schema": "latitude_telemetry_safety/v1",
  "verdict": "blocked",
  "reason_codes": [],
  "raw_values_emitted": false,
  "checked_surfaces": [],
  "runtime_environment": "wsl2_linux",
  "policy_consistent": true,
  "real_development_session_allowed": false,
  "follow_up_decision_required": true
}

marker は credential value、project slug、local path、request count、request body を含めない。

Activity

  1. added
    workflow
    process
    area/security
    on Jun 25, 2026
  2. squne121 commented on Jun 25, 2026

    @squne121
    OwnerAuthor

    判定

    REQUEST_CHANGES。Issue契約を修正してから実装着手すべきです。

    #1157は、親Issue #1153のレビューで指摘された「export停止とcapture停止の分離」「backup・active process・partial uninstallの検査」「未固定配布物の拒否」を適切に引き継いでいます。一方、現状の契約では、checkerが正常に実装されても偽陽性、偽陰性、または永続的なfail_closedになり得ます。特に、既存checkerとの統合規則、検査不能なsurface、local payloadの定義、送信先検証が不足しています。

    Blocker 1: top-level verdictの集約規則が定義されていない

    既存checkerは全EntireCLI系checkを無条件実行し、公開originをcheckpoint remoteのfallbackとして扱います。このため、EntireCLIを使用していなくても公開repoではFAILになります。PR #474の実runtime evidenceでも、公開originを理由にpublic_push_remote_detectedとpublic_checkpoint_branch_presentが発生しています。現行実装は、既知のFAILが1件でもあればFAIL-CLOSEDよりFAILを優先します。

    したがって、Latitude componentがsafeまたはnot_applicableでも、top-levelは常にEntire component由来でblockedになり得ます。#1157は「EntireCLI checker仕様変更」をOut of Scopeにしていますが、同じcanonical checkerへcomponentを追加する以上、少なくとも次が必要です。

    • componentごとのapplicability: applicable | not_applicable | unknown
    • global aggregation truth table
    • blockedとfail_closedが同時発生した場合の優先順位
    • inspection_complete: boolean
    • exit code 0/1/2との対応
    • 既存の行指向出力を維持するか、--jsonへ全面移行するか

    推奨集約は次です。

    known blockerあり          -> verdict=blocked, exit=1
    known blockerなし・unknown -> verdict=fail_closed, exit=2
    applicableかつ全safe       -> verdict=safe, exit=0
    全component not_applicable -> verdict=not_applicable, exit=0
    

    既知blockerとunknownが併存する場合は、verdict=blockedにしつつinspection_complete=falseを残すのが、既存exit contractとの後方互換性を保ちやすい設計です。

    Blocker 2: live checkerをfixture用環境変数で偽装できる

    現行checkerではSRRS_SECRETS_MODEが未設定ならPASSです。また既存testは、SRRS_GH_VISIBILITY、SRRS_GIT_CONFIG_OUTPUT、SRRS_CHECKPOINT_TOKENなどの環境変数で外部状態を全面的にmockしています。これらのoverrideはlive実行経路にも存在するため、誤設定または意図的な環境変数注入で安全判定を偽装できます。

    #1157では次を固定すべきです。

    • execution_profile: host | fixture
    • hostでは全SRRS_* overrideを拒否する
    • fixtureは明示的な--fixture-rootまたは--test-modeがある場合だけ許可する
    • host modeではdocs/dev/secret-policy.mdのcanonical YAMLを直接読み、source digestを出力する
    • policyが読めない、複数blockがある、schema不一致の場合はfail_closed
    • environment値をpolicy SSOTの代用にしない

    特に「ローカルにLatitude keyが存在する」という親Issueの前提と、Secret Inventoryのcurrent_secrets_mode: noneが矛盾する状態は、環境変数次第でPASSしてはなりません。

    Blocker 3: 「値を読まない」と「検査する」が技術的に矛盾している

    #1157はcredential valueやfull environmentを読まないことを要求しつつ、JSON settingsのfield存在、systemd user environment、active process environmentを検査対象にしています。

    systemdの公式interfaceであるsystemctl show-environmentは、特定keyだけを取得するcommandではなく、managerのenvironment block全体をdumpします。したがって「systemd managerにBUN_OPTIONSが存在するかを検査するが、full environmentは読み込まない」という契約は、そのままでは実装不能です。 ([man7.org]1)

    禁止事項は次のように再定義すべきです。

    sensitive_value_handling:
      human_visible: forbidden
      stdout_or_stderr: forbidden
      artifact_or_snapshot: forbidden
      logging_or_hashing: forbidden
      equality_comparison_against_known_secret: forbidden
      bounded_in_memory_presence_scan: allowed
      persistence_after_scan: forbidden

    また、subprocessのraw stderrをそのまま転送しないこと、stdoutは--json時に単一JSON objectだけとすることをAcceptance Criteriaへ追加すべきです。

    Blocker 4: Claude CodeとBUN_OPTIONSの実surfaceを網羅していない

    Claude Codeのhookは、user/project/local settingsだけでなく、managed policy、plugin、skill、agent frontmatterにも定義できます。さらに、全matching hookは並列実行され、Latitudeのasync: true hookはClaudeの動作をblockできません。 ([Claude Code]2) ([Claude Code]2) ([Claude Code]2)

    Latitude側も、Linuxではsystemd user environmentを利用し、手動構成ではshell startup fileへBUN_OPTIONSを設定する運用を案内しています。現在の#1157のchecked surfacesだけでは、shell rc、environment generator、managed/plugin hookなどの残留を見逃します。

    追加が必要なlogical surfaceは少なくとも次です。

    - shell_startup_environment
    - systemd_environment_generators
    - managed_claude_settings
    - enabled_plugin_hooks
    - active_skill_agent_hooks
    - current_shell_environment
    - process_parent_environment
    - windows_host_runtime

    WSL2からWindows側Claude Desktop、VS Code extension host、Windows側process environmentを検査できない場合は、runtime_locus: unknownとしてfail_closedにすべきです。単に「primary environmentがWSL2/Linux」でWindows hostを検査対象外にすると、最も重要なDesktop/IDE surfaceがblind spotになります。

    Blocker 5: latitude_stateをmetadataとみなせない

    preloadのrequest spoolには、system prompt、messages、tool definitionsなどを含むrequest bodyが保存されます。さらにstate.jsonはoffsetやturn countだけでなく、buffer: stringを永続化します。したがって、latitude_stateにもpartial transcript contentが含まれ得ます。

    A0のcontainment checkerでは、内容を解析して「無害なstateか」を判定すべきではありません。次の保守的規則が適切です。

    • request spool fileが1件でも存在すればblocked
    • state.jsonが存在すればblocked
    • temporary file、lock、backup、異名の残留も検査する
    • file bodyは読まない
    • lstatを用い、owner、mode、symlink、非regular fileを検査する
    • owner不一致、過剰permission、symlinkはblockedまたはfail_closed

    上流実装はstate/request directoryとfileの作成時に明示的なrestrictive modeを指定していないため、実際のpermissionをumask任せとせず検査対象に含めるべきです。

    Blocker 6: export先とtransportの検証が欠落している

    LatitudeのLATITUDE_BASE_URLは任意文字列を受け入れ、hookはそのURLへBearer API keyとOTLP payloadを送信します。現在の#1157は「export enabled/disabled」は扱いますが、「どこへ送るか」を扱っていません。

    以下を追加すべきです。

    destination_state: approved_cloud | approved_self_host | unapproved | unknown
    transport_state: https | plaintext | unknown
    diagnostic_logging_state: disabled | enabled | unknown

    LATITUDE_BASE_URLが未承認origin、非HTTPS、parse不能の場合はblockedです。LATITUDE_DEBUG=1も、上流実装がsession ID、transcript path、project、送信URL等をstderrへ出力し得るため、実sessionではblocked対象にすべきです。

    またLatitudeのcustom redactionは「content gateの後、OTLP exportの前」に行われます。preloadが保存するraw request spoolの安全性を証明するものではないため、redaction有効をcapture_state: inactiveの根拠にしてはなりません。 ([Latitude Docs]3)

    Blocker 7: uninstall検証にquiescence条件がない

    上流uninstallは、個別stepの失敗をcatchして後続処理を継続し、最終的に完了表示し得ます。設定backupは保持され、既存processに継承済みのBUN_OPTIONSはClaudeやterminalを再起動するまで残り得ます。

    この状態でsettingsとspoolを1回確認するだけではTOCTOUがあります。preload済みprocessが検査後にrequest fileを再作成できるためです。

    postconditionは次の順序を固定すべきです。

    1. 新規起動経路のBUN_OPTIONS/hookを停止
    2. Claude CLI、Desktop、IDE extension host、関連Bun processを停止・再起動
    3. active process inheritanceを再検査
    4. settings、backup、state、spool、preloadを検査・除去
    5. 一定の静止期間後に2回目のread-only scan
    6. 2回の結果が同一かつ対象processが存在しない場合だけcontained

    uninstall_stateは「uninstall commandを実行したか」ではなく、このpostconditionだけから導出すべきです。

    Blocker 8: 配布物検証がversion/integrityだけでは不足する

    公式手順と上流default hookはいずれもversionなしのnpx -y @latitude-data/claude-code-telemetryです。現在の上流manifestは0.0.9ですが、unversioned commandはlocal dependency、npm cache、remote fetchのいずれも実行し得ます。 ([npmドキュメント]4) ([Latitude Docs]3)

    上流publish workflowはnpm provenance付きでpublishしています。これは利用すべきですが、npm自身もprovenanceはsource/buildとのlinkを証明するだけで、悪意あるcodeがないことまでは保証しないと明記しています。検証commandとしてnpm audit signaturesも案内されています。 ([npmドキュメント]5)

    distribution contractは次まで拡張すべきです。

    distribution:
      package_spec: "@latitude-data/claude-code-telemetry@<exact-version>"
      registry_origin: approved | unapproved | unknown
      dist_integrity: string | null
      registry_signature_verified: true | false | null
      provenance_verified: true | false | null
      provenance_source_ref: string | null
      tarball_sha256: string | null
      installed_entrypoint_sha256: string | null
      preload_sha256: string | null
      node_version: string | null
      npm_version: string | null
      resolution_source: local_lockfile | npm_cache | remote_fetch | unknown

    このIssueが「完全除去のみ」を目的とするなら、distributionは検出用であり、absent後はnot_applicableになると明記すべきです。Latitudeを残したままpinningする可能性を含めるなら、lockfile、wrapper、package installation pathをAllowed Pathsへ加える必要があります。

    High 1: safeとnot_applicableが重複し、remote traceを無視している

    現在の定義では、Latitude関連surfaceがすべて不存在でunknownなしの場合、not_applicableの条件を満たします。同時にcurrent_secrets_mode == noneならsafe条件も満たします。さらにsafe条件にremote_trace_stateが含まれていません。

    absent_human_attestedもmachine-verifiable evidenceではありません。次の分離が必要です。

    containment_state: never_observed | active | contained | unknown
    exposure_state: none_observed | possible | confirmed | unknown
    credential_rotation_state: not_required | required | completed_attested | unknown
    remote_cleanup_state: not_required | required | completed_attested | unknown
    evidence_refs: []

    過去にcredential、preload、spool、exportのいずれかが存在した可能性があるなら、local postconditionがcleanでもsafeではなくcontained相当として扱い、rotation/deleteがOut of Scopeならparentのreal pilotはBLOCKEDのままにすべきです。

    High 2: credentialをCLI argumentへ渡す公式手順への対処がない

    公式docsは--api-key=...をinstaller argumentとして渡す例を掲載しています。これはshell historyやprocess argvに残る可能性があります。 ([Latitude Docs]3)

    shell history全体を自動scanすると無関係なsecretまで読む危険があるため、checkerでhistoryを読むべきではありません。代わりに次をpolicy化すべきです。

    • real keyをargvへ渡すことを禁止
    • 過去にargv利用の可能性がある場合はexposure_state: possible
    • shell historyを自動収集しない
    • rotation完了までreal sessionを再開しない

    High 3: fixture pathとsecurity gate契約が現行repoと一致しない

    既存testのcanonical fixture pathはtests/fixtures/session-recording-runtime-safety/**ですが、#1157のAllowed Pathsはtests/fixtures/session-recording/**だけです。既存testは行指向outputとexit 0/1/2も前提にしています。

    また現在のsecurity:session-recordingはpolicy、manifest、fixture smoke、scannerを実行しますが、live runtime checkerを直接実行していません。

    最低限、次を追加してください。

    tests/fixtures/session-recording-runtime-safety/**
    

    そしてscriptを分離するのが妥当です。

    {
      "security:session-recording:fixture": "... deterministic fixture checks ...",
      "security:session-recording:host": "... --execution-profile host --json ...",
      "security:session-recording": "... fixture checks only ..."
    }

    generic CIでhost inspectionを実行すると、systemd user bus、active process、launchctl等が検査不能となり、CIが恒常的にfail_closedになるためです。

    推奨するv2 contractの骨格

    schema: session_recording_runtime_safety/v2
    decision: allow | deny
    verdict: safe | blocked | fail_closed | not_applicable
    inspection_complete: true | false
    exit_code: 0 | 1 | 2
    
    execution_profile: host | fixture
    runtime_locus: linux | wsl | macos | windows_host | unknown
    
    policy:
      source: docs/dev/secret-policy.md
      source_digest: sha256:<digest>
      current_secrets_mode: none | publish_secret | app_secret | unknown
    
    components:
      entire:
        applicability: applicable | not_applicable | unknown
        verdict: safe | blocked | fail_closed | not_applicable
        reason_codes: []
    
      latitude:
        applicability: applicable | not_applicable | unknown
        verdict: safe | blocked | fail_closed | not_applicable
    
        containment_state: never_observed | active | contained | unknown
        credential_state: present | absent | unknown
        export_state: enabled | disabled | unknown
        capture_state: active | inactive | unknown
        local_storage_state: absent | present | unsafe_metadata | unknown
        active_process_state: preload_present | preload_absent | unknown
        destination_state: approved_cloud | approved_self_host | unapproved | unknown
        transport_state: https | plaintext | unknown
        diagnostic_logging_state: disabled | enabled | unknown
        exposure_state: none_observed | possible | confirmed | unknown
    
        distribution:
          package_spec: string | null
          dist_integrity: string | null
          registry_signature_verified: boolean | null
          provenance_verified: boolean | null
          provenance_source_ref: string | null
          preload_sha256: string | null
    
        checked_surfaces: []
        reason_codes: []
        raw_values_emitted: false
    
    checked_at: ISO8601

    承認条件

    次の修正が入れば、A0として実装可能な契約になります。

    1. component applicability、global aggregation、exit code、後方互換を固定する。
    2. host modeでSRRS_* overrideを拒否し、Secret Inventory SSOTを直接参照する。
    3. 「read禁止」を「emit/persist/hash禁止」へ精密化する。
    4. managed/plugin/skill/agent hook、shell environment、WSL host境界を追加する。
    5. state/spoolの存在をpayload残留として扱い、owner/mode/symlinkも検査する。
    6. export destination、transport、debug loggingを判定に含める。
    7. quiescentな二段階postconditionを必須にする。
    8. npm signature/provenance/source refをdistribution evidenceへ加える。
    9. remote state不明またはrotation未完了ではsafeを返さない。
    10. fixture pathとhost/CI scriptを現行repoへ合わせる。

    現状の#1157は安全側の意図は正しいものの、判定器そのものの適用性と検査境界が未確定です。このまま実装すると「常にBLOCKED」か「未検査surfaceをsafeと誤認」のどちらかになりやすいため、Issue本文の契約修正を先行させるべきです。

  3. squne121 commented on Jun 25, 2026

    @squne121
    OwnerAuthor

    Refinement Loop: Approved

    The issue has been approved and is ready for implementation.

  4. squne121 commented on Jun 25, 2026

    @squne121
    OwnerAuthor

    Issue Contract Review: go

    status: go
    issue: #1157
    source: all_checks_pass

    VC Preflight 集約

    コマンド スコープ 結果
    pnpm typecheck regression_gate go (exit 0)
    pnpm lint regression_gate go (exit 0)
    pnpm test regression_gate go (1073 tests passed)
    pnpm build regression_gate go (exit 0)
    test -f .claude/scripts/check_session_recording_runtime_safety.py baseline_fail_expected go (pass)
    test -f tests/session_recording_runtime_safety.test.ts baseline_fail_expected go (pass)
    uv run python3 check_session_recording_runtime_safety.py ... runtime_only skipped
    pnpm policy:check 他 5 件 pr_review_only skipped

    Worktree / Branch

    ```
    branch: worktree-issue-1157-latitude-telemetry-safety
    ```

    Handoff

    implement-issue または impl-review-loop を起動してください。

    ```
    issue: 1157
    contract_snapshot_url: (this comment)
    ```

  5. changed the title [-]security(latitude): telemetry credential / preload capture を封じ込め、Secret Inventory / Kill Switch を fail-closed 化する[/-] [+]実装: security(latitude): telemetry credential / preload capture を封じ込め、Secret Inventory / Kill Switch を fail-closed 化する[/+] on Jun 25, 2026
  6. squne121 commented on Jun 25, 2026

    @squne121
    OwnerAuthor

    Contract Review Result

    CONTRACT_REVIEW_RESULT_V1:
      status: go
      generated_at: "2026-06-25T13:13:18Z"
      generated_by: issue-contract-review
      issue_url: https://github.com/squne121/loop-protocol/issues/1157
      body_sha256: "sha256:e1d2d9e76beb5eafb2e5b539e63440dbe2b6e454fc40058543c14a6c3393068c"
      checks:
        readiness: go
        blockers: pass
        product_spec: pass
        vc_preflight: pass
      source: ensure_contract_snapshot_auto
  7. squne121 commented on Jun 25, 2026

    @squne121
    OwnerAuthor

    Issue Contract Review: go

    status: go
    issue: #1157
    source: all_checks_pass

    VC Preflight 集約

    コマンド スコープ 結果
    pnpm typecheck regression_gate go (exit 0)
    pnpm lint regression_gate go (exit 0)
    pnpm test pr_review_only skipped
    pnpm build regression_gate go (exit 0)
    test -f .claude/scripts/check_session_recording_runtime_safety.py regression_gate go (pass)
    test -f tests/session_recording_runtime_safety.test.ts regression_gate go (pass)
    uv run python3 check_session_recording_runtime_safety.py ... runtime_only skipped
    pnpm policy:check 他 4 件 pr_review_only skipped

    Worktree / Branch

    branch: worktree-issue-1157-latitude-telemetry-safety
    

    Handoff

    implement-issue または impl-review-loop を起動してください。

    issue: 1157
    contract_snapshot_url: (this comment)
    

    Contract Review Result

    CONTRACT_REVIEW_RESULT_V1:
      status: go
      generated_at: "2026-06-25T13:21:00Z"
      generated_by: issue-contract-review
      issue_url: https://github.com/squne121/loop-protocol/issues/1157
      body_sha256: "sha256:0e6b0240016778b7514b08bb582b7de2684aea291c174c15135a7d717c40fa3c"
      checks:
        readiness: go
        blockers: pass
        product_spec: pass
        vc_preflight: pass
        product_spec_check:
          applicability: not_applicable
          decision: pass
          blocked_rule_ids: []
      source: run_contract_review_once_execute
  8. added a commit that references this issue on Jun 25, 2026
  9. squne121 commented on Jun 25, 2026

    @squne121
    OwnerAuthor

    実装完了: PR #1162 #1162 — latitude telemetry safety fail-closed / 全 1098 テスト pass

  10. squne121 commented on Jun 25, 2026

    @squne121
    OwnerAuthor

    Issue Contract Review: go

    status: go
    issue: #1157
    source: all_checks_pass

    VC Preflight 集約

    コマンド スコープ 結果
    pnpm typecheck regression_gate go (exit 0)
    pnpm lint regression_gate go (exit 0)
    pnpm test pr_review_only skipped
    pnpm build regression_gate go (exit 0)
    test -f .claude/scripts/check_session_recording_runtime_safety.py regression_gate go (pass)
    test -f tests/session_recording_runtime_safety.test.ts regression_gate go (pass)
    uv run python3 check_session_recording_runtime_safety.py ... runtime_only skipped
    pnpm policy:check 他 4 件 pr_review_only skipped

    Allowed Paths 更新

    .claude/scripts/lib/__init__.py を Allowed Paths に追加(PR #1162 allowed_paths_gate: fail_closed 解消のため)。

    Worktree / Branch

    branch: worktree-issue-1157-latitude-telemetry-safety
    

    Handoff

    implement-issue または impl-review-loop を起動してください。

    issue: 1157
    contract_snapshot_url: (this comment)
    

    Contract Review Result

    CONTRACT_REVIEW_RESULT_V1:
      status: go
      generated_at: "2026-06-25T14:05:01Z"
      generated_by: issue-contract-review
      issue_url: https://github.com/squne121/loop-protocol/issues/1157
      body_sha256: "sha256:da37ac023a1e1cb6b7961070e5c6613937a403d4ee16f64e65617661f4cf70b2"
      checks:
        readiness: go
        blockers: pass
        product_spec: pass
        vc_preflight: pass
        product_spec_check:
          applicability: not_applicable
          decision: pass
          blocked_rule_ids: []
      source: run_contract_review_once_execute
  11. added a commit that references this issue on Jun 25, 2026
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

    area/securityphase/implementationprocessworkflow

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions