Skip to content

feat(app-control): bind pid captures through a bundled, tested capture script - #10500

Merged
kyle-sexton merged 3 commits into
mainfrom
work-resolve-issue/issue-10400-40544791939-1
Oct 27, 2026
Merged

kyle-sexton merged 3 commits into
mainfrom
work-resolve-issue/issue-10400-40544791939-1

Conversation

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor

Closes #10400

Summary

Opened by the work-resolve-issue lane. The run's own summary:

Adds scripts/build_capture_script.py and a test beside it. The script checks a launch record (pid, uid, start time, cmdline sha256) against /proc, or binds an attached pid, and writes the shown script. That script reads starttime after the last ')' of /proc/<pid>/stat, rechecks before and after the recorder, and deletes the capture on a difference. /app-control:drive now runs threads captures, pid-taking cpu and heap captures, and elevated attaches only through the built script, and shows the builder's full output before the yes. Off Linux it records blocked: pid binding covers Linux only, not &lt;platform&gt;, and an unattended invalid pid is blocked: launched process no longer matches before capture needs elevation.

Not verified

  • The new suite plugins/app-control/scripts/build_capture_script.test.sh was never executed. This lane runs no interpreter, and check-affected skips code from the checked tree. It is left to the PR's CI test lane, which discovers plugins/**/*.test.sh.
  • The skill-quality changed-skills check (including drive's body length) was skipped by check-affected because it runs the checked tree's own code. It is left to CI. The hub SKILL.md grew by about 8 lines.
  • typos was skipped by check-affected because it is not installed; left to CI.
  • New eval cases 22 and 23 were not run with claude plugin eval; that needs a host run.
  • pr-test-windows.yml lists its suites explicitly and is a protected path. The new suite is not added there, and it prints SKIP off Linux anyway.
  • Untracked files in the checkout root (.bash_profile, .bashrc, .gitconfig, .idea, .mcp.json, .profile, .ripgreprc, .vscode, .zprofile, .zshrc) were not created by this run's edits and were left untouched.

Fix

  • plugins/app-control/scripts/build_capture_script.py: new builder. Launch mode checks the record's format, the live /proc values and the caller's uid, and --child resolves a wrapper's one child by parent pid. --attach-pid reads a named pid's uid, start time and hash. It writes the POSIX sh script wit
  • plugins/app-control/scripts/build_capture_script.test.sh: new Linux-only suite against live processes. It covers a comm of 'x) R 1 ) y', a recheck that fails before the recorder, a process killed during the recorder (capture dropped, exit 3), recorder exit 3 mapping to 4, mismatched start time, hash
  • plugins/app-control/skills/drive/reference/pid-binding.md: covers pid-taking cpu/heap captures and elevated attach. Adds the Linux-only stop, the order of stops (platform, record, format check, elevation), the rule that a recorder runs only through the built script (with --elevate on the elevated ro
  • plugins/app-control/skills/drive/SKILL.md: the capture row names pid-taking cpu/heap. The elevated-capture rule names the builder command via ${CLAUDE_PLUGIN_ROOT} and the hand-back. The unattended threads rule states the stop order: Linux-only line, then record and format check (an invalid pid is `
  • plugins/app-control/skills/drive/reference/evidence.md: a capture step's process carries uid and sha256 whenever a pid-bound capture or an elevated attach bound it.
  • plugins/app-control/reference/control-skill.md: a cpu or heap command that targets a running process takes <pid>, and <file> marks an output path (without it, stdout is the capture). Binding is Linux only.
  • plugins/app-control/skills/drive/evals/evals.json: new cases 22 (threads blocked off Linux, naming macOS) and 23 (an invalid recorded pid is launched process no longer matches, not capture needs elevation).
  • .changes/app-control/fix-10400-pid-binding-capture-script-3f9a61c2.md: minor changelog fragment (Added, Changed including the break for non-Linux cpu/heap and elevated attach, Fixed).

Verification

The runner ran each check from the base copy against 9cd37af:

  • scripts/check-changelog-fragments.sh --check: passed

The run reports:

  • /home/runner/work/claude-code-plugins/claude-code-plugins/.lane/checks/bin/check-changelog-fragments: all 4 fragments valid
  • /home/runner/work/claude-code-plugins/claude-code-plugins/.lane/checks/bin/check-affected: 12 passed, 5 skipped over 8 changed files. The first run failed on shellcheck (SC2016, SC2034) and shell-portability (GNU stat -c) in the new test; I fixed both and reran it clean.
  • /home/runner/work/claude-code-plugins/claude-code-plugins/.lane/verify/bin/check-evals-quality plugins/app-control/skills/drive/evals/evals.json: PASS, 0 warnings
  • /home/runner/work/claude-code-plugins/claude-code-plugins/.lane/verify/bin/cant-fail-scan --file plugins/app-control/scripts/build_capture_script.test.sh --check: PASS, no gating findings
  • Grep '#[0-9]{3,}' over plugins/app-control/skills/drive/**, reference/control-skill.md and scripts/build_capture_script*: no matches
  • Local fresh-context review subagent over the whole diff: 6 findings. I fixed all 6: single-pass placeholder fill with a regression test, --elevate stated for the elevated route, the hand-back documented and made chown -h, an INT/TERM trap so an interrupted recorder still gets the recheck, sha256 in
  • read https: //man7.org/linux/man-pages/man5/proc_pid_stat.5.html: field 2 comm is the executable name in parentheses, truncated to TASK_COMM_LEN; field 4 is ppid; field 22 is starttime in clock ticks since boot
  • read https: //man7.org/linux/man-pages/man5/proc_pid_status.5.html: the Uid line holds real, effective, saved set and filesystem UIDs
  • read https: //man7.org/linux/man-pages/man5/proc_pid_cmdline.5.html: NUL-separated strings with a further NUL after the last, and empty for a zombie
  • read https: //man7.org/linux/man-pages/man5/proc_pid_comm.5.html: a thread may modify its own comm by writing /proc/self/task/<tid>/comm
  • read https: //github.com/melodic-software/claude-code-plugins/issues /9546 and its API comments: part 2 of 4 is the owner's slice 1 plus slice 2. The slice-2 secrets_mark item already shipped in app-control 0.13.0.
  • The lane run: https://github.com/melodic-software/claude-code-plugins/actions/runs/40544791939

Left out: the items under Not verified.

Related

#10400

Lane-Activity: work-resolve-issue/resolve-issue

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

claude-security-review: 1 inline finding(s) on 9cd37afe38d47bd18eaf638d6c78941ca36078d7; the summary is in this lane's pull request comment.

claude-lane: claude-security-review

@github-actions

github-actions Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

claude-security-review reviewed fdddc68267726987cfa6ff451619f81525a773a0: 1 finding(s), 1 as inline comments.

Security review of #10500 (head fdddc68): one SUGGESTION, no CRITICAL or IMPORTANT findings.

I read all 8 changed files. The substantive code is the new plugins/app-control/scripts/build_capture_script.py, which generates a POSIX sh script that may call sudo. None of the changed files match a trusted-path glob. No plugin.json or marketplace.json changed, so no manifest <field> lines apply. The changelog fragment, docs, evals and the SKILL.md / pid-binding.md edits tighten the binding rules and remove no guardrail.

What I checked in the builder, and found sound:

  • Script injection. Launch-record values pass anchored fullmatch checks (PID, INT, SHA) before reaching the script. Children come from /proc names that also pass PID. Recorder arguments go through shlex.quote, <pid> is replaced by a validated integer, the capture path is quoted, and control characters are rejected in both. The single-pass PLACEHOLDER.sub stops a value containing @RUN@ from being expanded again.
  • Pid and comm confusion. /proc/<pid>/stat is read after the last ), in both the Python and the sh code.
  • Elevated write. The elevated recorder writes into a root-made mktemp -d stage. The hand-back is done by the user's own redirect, the stage is removed, and the post-recorder recheck deletes the capture on a mismatch.
  • Launch-mode uid. It is checked against the caller's own uid in Python, and against the literal for all four uid fields in the script.
  • Script file creation. O_EXCL refuses an existing path or a symlink, and the mode is 0700.

Spend: this adds no paid-plan or billing surface, so no cost hold.

critical-findings: 0

@github-actions

github-actions Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

claude-review reviewed fdddc68267726987cfa6ff451619f81525a773a0: 0 finding(s), 0 as inline comments.

No findings. I read the whole diff (8 files) and the PR context. I ran nothing, so none of the PR's claimed verification is independently confirmed.

What I checked

  • Builder and generated script (plugins/app-control/scripts/build_capture_script.py):
    • Start-time parsing: the field offsets are consistent between the Python reader (rest[1] is ppid, rest[19] is starttime) and the generated sh ($2, ${20}, both counted after the last )).
    • Recheck and exit codes: the recheck before the recorder and after it, the exit-3 and recorder-3-to-4 mapping, and the drop of the capture on a difference all hold. The hand-back runs before after=1, so an elevated staged capture is also dropped when the recheck fails.
    • Placeholder fill: it is a single pass, so a placeholder name in the capture path or a recorder argument stays literal.
    • Quoting and file creation: arguments are shlex.quoted and control characters are rejected. The script file is created with O_EXCL and mode 0700.
    • Staged elevated write: the staged <file> write is built as intended.
  • Closing issue fix\(app-control\): close the open threads pid-binding and eval follow-ups - part 2 of 4 #10400 criteria:
    • Covered by a test: the builder with a test beside it, the comm with spaces and ), the recheck after the recorder with the capture dropped, and the elevated attach recording and rechecking uid, start time and hash.
    • Covered by docs and evals only: the Linux-only blocked: line (evals 22 and 23), the unattended invalid pid giving launched process no longer matches before capture needs elevation, and cpu/heap following the same binding. No test runs them.
    • Placeholder grep: the #[0-9]{3,} grep is clean on the added lines I read.
  • Manifests: no plugin.json or marketplace.json change, so no manifest lines apply. The fragment's bump: minor is reasonable for the stated break on non-Linux hosts, since app-control is pre-1.0 (0.13.0 per the PR context).

Not confirmed here, as the PR itself states

  • build_capture_script.test.sh has not been executed, nor has the skill-quality check on the grown drive hub SKILL.md. Both are left to CI.
  • Eval cases 22 and 23 have not been run.
  • pr-test-windows.yml does not list the new suite, which prints SKIP off Linux anyway.

Cost: no change here can start a real charge, so there is no hold. The new eval cases add a little prepaid eval usage.

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

The unattended merge path armed native auto-merge at head 9cd37afe38d47bd18eaf638d6c78941ca36078d7.

kyle-sexton and others added 2 commits October 27, 2026 15:52
…e path

An elevated recorder wrote the capture path directly, so the captured
process (same user) could plant a symlink there and have root overwrite
any file. The recorder now writes into a directory the elevated user
makes with mktemp -d; the script copies the file to the capture path
through its own redirect, as the user running it, and removes the
directory. Addresses the claude-security-review IMPORTANT finding.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

claude-security-review: 1 inline finding(s) on fdddc68267726987cfa6ff451619f81525a773a0; the summary is in this lane's pull request comment.

claude-lane: claude-security-review

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

pr-unblock / address-feedback finished round 1 of max 4 on fdddc68.

@melodic-automation-lanes melodic-automation-lanes Bot added the needs-human Human-in-the-loop required; autonomous sessions must not resolve items carrying this. label Oct 27, 2026
@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

The pr-unblock lane stopped on this pull request and needs a person: a review finding is uncertain or deferred, so a person decides it.

  • Reason: feedback-uncertain
  • Resume key: fdddc68267726987cfa6ff451619f81525a773a0 (the head the lane stopped on)

To resume, deal with the reason above, remove the needs-human label (and do-not-merge, if set), then dispatch the pr-unblock workflow with pr-number=10500 and activity=address-feedback:

gh workflow run pr-unblock.yml -R melodic-software/claude-code-plugins -f pr-number=10500 -f activity=address-feedback

@kyle-sexton kyle-sexton removed the needs-human Human-in-the-loop required; autonomous sessions must not resolve items carrying this. label Oct 27, 2026
@kyle-sexton
kyle-sexton enabled auto-merge October 27, 2026 21:06
@kyle-sexton
kyle-sexton added this pull request to the merge queue Oct 27, 2026
Merged via the queue into main with commit 0c5a592 Oct 27, 2026
70 of 71 checks passed
@kyle-sexton
kyle-sexton deleted the work-resolve-issue/issue-10400-40544791939-1 branch October 27, 2026 21:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix\(app-control\): close the open threads pid-binding and eval follow-ups - part 2 of 4

1 participant