Repository navigation
feat(harness-ops): route repository hook telemetry through the reference sink without a copy - #14270
melodic-automation-lanes[bot] wants to merge 1 commit into
Conversation
Lane-Activity: work-resolve-issue/resolve-issue
| tmp="$launcher.$$" | ||
| if printf '%s\n' "$body" >"$tmp" 2>/dev/null && chmod +x "$tmp" 2>/dev/null; then |
There was a problem hiding this comment.
The temporary file is opened through a symlink, then marked executable. tmp="$launcher.$$" is a name an attacker can predict, and it sits inside the repository's log root. printf ... >"$tmp" follows a symlink and truncates its target, and chmod +x "$tmp" then marks that target executable. slog_root_to checks only where the root directory physically is, not the files inside it.
Exploit path: a repository commits .observability/claude/.gitignore (*) plus symlinks named hook-telemetry-sink.sh.<pid> across the PID range, pointing at a file in the user's home such as ~/.bashrc, and wires HOOK_TELEMETRY_SINK to the launcher path. When the session-start PID matches one of them, that user file is overwritten with the launcher text and made executable. The text is fixed, so this is a clobber or breakage, not code execution. That is why this is a suggestion and not a blocker.
The guard in session-log-lib.sh already uses an exclusive create for the same reason. Doing the same here refuses an existing path, a planted symlink included:
| tmp="$launcher.$$" | |
| if printf '%s\n' "$body" >"$tmp" 2>/dev/null && chmod +x "$tmp" 2>/dev/null; then | |
| tmp="$launcher.$$" | |
| if (set -o noclobber; printf '%s\n' "$body" >"$tmp") 2>/dev/null && chmod +x "$tmp" 2>/dev/null; then |
severity: SUGGESTION
claude-lane: claude-security-review
|
claude-security-review reviewed Security review: PR #14270 (harness-ops reference-sink launcher)None of the 7 changed files matches a What I checked
Finding
Spend: one extra short process chain (sh, node, bash) on every session start for each harness-ops user. It exits at once when nothing is wired. This uses no paid resources; it is not a hold and not counted as a finding. No embedded instructions in the PR context. Prior findings: none (first review, not blocking only). critical-findings: 0 |
| # The repository root, resolved as the sink and hook::emit_telemetry resolve | ||
| # it, so a session started in a subdirectory still writes where producers look. | ||
| project="" | ||
| hook::repo_root_to project "$CLAUDE_PROJECT_DIR" || : |
There was a problem hiding this comment.
Advisory: in a subdirectory session, harness-ops' own producers never reach this launcher.
The comment says the root is "resolved as the sink and hook::emit_telemetry resolve it". That is not how emit_telemetry resolves it. hook::emit_telemetry joins a relative HOOK_TELEMETRY_SINK onto the repo_root its caller passes (hook-utils.sh:3484-3491). Every harness-ops producer passes the raw ${CLAUDE_PROJECT_DIR:-}, not a git-resolved root:
- audit-event-emitter.sh:87, plus lines 111, 153 and 196
- hook-failure-audit.sh:589
- skill-usage-audit.sh:65
Only the formatter/guardrail path (REPO_ROOT, hook-utils.sh:3117) passes the resolved root.
How it fails: start a session in repo/sub with HOOK_TELEMETRY_SINK=.observability/claude/hook-telemetry-sink.sh. This hook writes repo/.observability/claude/hook-telemetry-sink.sh. The harness-ops audit rows (API errors, config changes, permission denials, skill usage, hook failures, and the rest) then exec repo/sub/.observability/claude/hook-telemetry-sink.sh. That file does not exist, so they drop every envelope silently. Formatter rows still land. The README says the launcher "goes under the repository root even when a session starts in a subdirectory", which reads as if subdirectory sessions work. The new subdirectory test only checks where the file is placed, not that a harness-ops producer reaches it.
The raw-root callers predate this PR, but this route is what makes the scenario a documented one. Possible fix: have those producers resolve the root with hook::repo_root_to before calling emit_telemetry, the way the formatter path does. Alternatively, narrow the README and comment claims. In either case, add a test that pipes an audit-event-emitter.sh row through a subdirectory session.
claude-lane: claude-review
|
|
||
| - **Copy the reference sink into your repository** (for example | ||
| `.claude/hooks/hook-telemetry-sink.sh`) and wire that repository-relative | ||
| path. The sink sources two files from its own directory, so copy all three | ||
| side by side: `hook-telemetry-sink.sh`, `hook-utils.sh` (for | ||
| `hook::repo_root_to`) and `session-log-lib.sh` (the log root, the guard and |
There was a problem hiding this comment.
Advisory: the closing-issue criterion is met, but nothing tests it.
#14227's criterion reads: "The README's copy route, if kept, lists every file the sink needs." This list now names hook-telemetry-sink.sh, hook-utils.sh and session-log-lib.sh, which matches the sink's two source lines today. No test in the PR or the repository compares the two, so the next source added to hook-telemetry-sink.sh would make this list incomplete again, unnoticed. That is how the original gap arose.
Possible fix: a test that does one of these:
- Extracts the sink's
source "$HOOK_DIR/..."targets and checks that each appears in this list. - Copies exactly the listed files into a temporary directory and pipes one envelope through the copy.
claude-lane: claude-review
|
claude-review reviewed Code review: PR #14270, harness-ops copy-free route to the reference sinkI read every hunk of all 7 changed files. I also read the code the changed lines call: Closing issue #14227, done-when criteria
Checked and found fine
Runtime cost (not a hold, not counted) Not verified by me |
|
Closing in favor of #14279, which implements the design the owner chose for #14227 on 2026-11-08 (option (a)): a stable launcher under the harness-ops plugin data directory, refreshed on SessionStart, and one reserved This PR takes a different route. It writes the launcher under each repository's log root and wires it by relative path, with no reserved value and no producer change. #14279 also carries this PR's |
|
Superseded by #14279; reason in the comment above. |
Closes #14227
Summary
Opened by the work-resolve-issue lane. The run's own summary:
Not verified
bash <path>(exec-bash.mjs and the test runner), so the mode should not matter, but a reviewer may want +x for consistency.Fix
.data.subject // .data.file // ""; the header comments describe the new mapping and the launcher wiring.Verification
The runner ran each check from the base copy against a1d425b:
The run reports:
{tool, file}data with no subject key, confirming the empty-subject cause.envvalues are copied into Claude Code's environment as written, and no shell processes them, so~and$HOMEstay as typed; Claude Code writes each env entry into the process environment.Left out: the items under Not verified.
Related
#14227