Skip to content

fix(hooks)!: resolve the hook interpreter and hook PATH from directories the agent cannot write - #8605

Merged
waynesun09 merged 4 commits into
mainfrom
hook-trusted-interpreter
Oct 20, 2026
Merged

waynesun09 merged 4 commits into
mainfrom
hook-trusted-interpreter

Conversation

@waynesun09

@waynesun09 waynesun09 commented Oct 20, 2026 •

Copy link
Copy Markdown
Member

Summary

Claude Code and codex hooks now get the same pinned interpreter and PATH the launch loader already uses (#8591), instead of a plain command -v python3 and the raw sandbox PATH.

Related Issue

Follow-up to #8575 / #8591. The pi hook adapter gets the same treatment in #8589.

Changes

  • Bootstrap (codex_bootstrap.go, hookPreflightInterpreter): runs the launch's own pin (envDataPin) in the sandbox and reads back the pinned python3 and FULLSEND_TRUSTED_PATH in one exec. It replaces codexPreflightPython and Claude's claudePreflightInterpreter. The absolute-path check and the Python 3.11 floor stay. Bootstrap fails with a clear error when no such python3 exists.
  • Claude Code (claude.go): hooks.json runs each hook as PATH='<trusted PATH>' <python> -E -s -B <script> (GenerateHooksConfigPinned).
  • codex (codex_run.go, fullsend-codex-hook.py): the run command exports FULLSEND_TRUSTED_PATH after .env. It is read-only and on the loader drop list, so .env cannot change it. The hook adapter sets its children's PATH from it. A missing, empty or relative-entry value blocks the call before anything is spawned, the same as a missing digest map. codex itself keeps FULLSEND_CODEX_PATH (restored as its PATH, no longer exported).
  • Trusted PATH as root (env_data.go, envDataTrustedPath): as root the trusted PATH still drops empty, relative and missing entries, which the hook adapters refuse. This is the shared fragment, so it also stops pi hooks blocking under root when PATH has an empty entry.
  • Docs: runtime-implementation.md describes the hook interpreter and PATH contract. docs/runtimes/{claude,codex}.md state that with hooks on the protected python3 must be 3.11 or newer.
  • Codex golden launch files regenerated (the FULLSEND_TRUSTED_PATH line and the export).

Breaking change

With sandbox hooks on, the python3 found in a PATH directory the sandbox user cannot write must be 3.11 or newer. The hook adapter's version floor used to run on command -v python3, so an image whose only 3.11+ interpreter is an agent-owned virtualenv over an older system python3 (RHEL/UBI 9 ships 3.9) passed Bootstrap. It now fails with hook interpreter ... needs at least 3.11. The fullsend sandbox image resolves /usr/bin/python3.12 and is not affected.

Testing

  • go test ./internal/runtime/... ./internal/security/... ./internal/cli/... pass as a non-root user on Linux (Debian, /bin/sh = dash) at the head, rebased on main after fix(#8577): run pi hook scripts with the python3 pinned before .env #8589. Before the rebase, the same suites and the pi extension's node tests passed on Fedora 44 (/bin/sh = bash 5).
  • New tests: Bootstrap reads back the pinned interpreter and the trusted PATH and rejects a non-absolute or too-old interpreter. The Claude hooks.json carries the trusted PATH. The codex adapter blocks without a trusted PATH, and its children get exactly that PATH. The codex launch exports it after .env. Bootstrap fails through hookPreflightInterpreter when the pinned interpreter is below 3.11, and codex hooks.json starts every command with the pinned interpreter. Each fails when its fix is removed.
  • Checked in the fleet sandbox image as the sandbox user: the hook interpreter resolves to the image's root-owned python3, and the hook PATH leaves out the sandbox-owned venv bin.

Checklist

  • PR title follows Conventional Commits (correct type, ! for breaking changes; see Breaking change).
  • Commits are signed off (DCO)
  • I wrote this contribution myself and can explain all changes in it

🤖 Generated with Claude Code

@qodo-code-review

Copy link
Copy Markdown

PR Summary by Qodo

Pin Claude Code and codex hooks to a trusted interpreter and PATH

🐞 Bug fix 🧪 Tests 📝 Documentation 🕐 40+ Minutes

Grey Divider

AI Description

• Resolve hook Python and PATH using the launch loader’s trusted-directory rules, excluding
 agent-writable locations.
• Give Claude hooks the trusted PATH and make codex hooks fail closed without it.
• Add regression coverage and document the hook execution contract.
Diagram

graph TD
  Pin["Trusted PATH pin"] --> Bootstrap["Hook preflight"] --> Claude["Claude hooks.json"] --> Scripts["Hook scripts"]
  Pin --> Run["codex launch"] --> Adapter["codex adapter"] --> Scripts
Loading
High-Level Assessment

Reusing the launch loader’s existing pin is the best approach: a separate hook-specific resolver could diverge from launch security rules, while pinning only Python would leave tools invoked by hooks exposed to an agent-writable PATH.

Files changed (14) +291 / -106

Bug fix (4) +87 / -59
claude.goUse shared trusted hook preflight for Claude +6/-25

Use shared trusted hook preflight for Claude

• Replaces Claude’s separate interpreter and raw-PATH lookups with the shared preflight result used to render hooks.json.

internal/runtime/claude.go

codex_bootstrap.goResolve hook Python and PATH through the launch pin +40/-19

Resolve hook Python and PATH through the launch pin

• Adds a shared preflight that runs envDataPin, reads back its interpreter and trusted PATH, and retains absolute-path and Python-version checks. Codex Bootstrap uses its interpreter result.

internal/runtime/codex_bootstrap.go

fullsend-codex-hook.pyRequire a trusted PATH before running codex hook scripts +32/-9

Require a trusted PATH before running codex hook scripts

• Sets hook children’s PATH from FULLSEND_TRUSTED_PATH instead of codex’s PATH. Blocks script execution when that value is missing, empty, or contains a non-absolute entry.

internal/runtime/codex_hook/fullsend-codex-hook.py

codex_run.goExport the trusted PATH to the codex adapter +9/-6

Export the trusted PATH to the codex adapter

• Exports the loader’s read-only FULLSEND_TRUSTED_PATH after .env is processed, while continuing to restore FULLSEND_CODEX_PATH for codex itself.

internal/runtime/codex_run.go

Tests (8) +191 / -42
claude_test.goVerify Claude hooks exclude the writable virtualenv +15/-6

Verify Claude hooks exclude the writable virtualenv

• Updates sandbox stubs for the shared probe and asserts that hooks.json contains the trusted PATH rather than the raw PATH.

internal/runtime/claude_test.go

codex_bootstrap_test.goCover trusted hook preflight and failure cases +99/-19

Cover trusted hook preflight and failure cases

• Tests pinned lookup, output parsing, missing or relative interpreters, empty PATH, and rejection of a writable PATH entry in a real shell.

internal/runtime/codex_bootstrap_test.go

codex_hook_test.goTest codex adapter trusted-PATH enforcement +60/-13

Test codex adapter trusted-PATH enforcement

• Supplies the trusted PATH in adapter fixtures and verifies malformed or absent values block spawning. Confirms children receive that value rather than inherited or codex PATH.

internal/runtime/codex_hook_test.go

codex_run_test.goCheck trusted-PATH export ordering +13/-0

Check trusted-PATH export ordering

• Asserts the trusted PATH is recorded before .env, exported after it and before codex starts, and not subsequently unset.

internal/runtime/codex_run_test.go

launch-delegating.txtRefresh delegating launch command golden +1/-1

Refresh delegating launch command golden

• Records the additional FULLSEND_TRUSTED_PATH export.

internal/runtime/testdata/codex/golden/launch-delegating.txt

launch-gateway.txtRefresh gateway launch command golden +1/-1

Refresh gateway launch command golden

• Records the additional FULLSEND_TRUSTED_PATH export.

internal/runtime/testdata/codex/golden/launch-gateway.txt

launch-hooks.txtRefresh hooks launch command golden +1/-1

Refresh hooks launch command golden

• Records the additional FULLSEND_TRUSTED_PATH export.

internal/runtime/testdata/codex/golden/launch-hooks.txt

launch-nohooks.txtRefresh no-hooks launch command golden +1/-1

Refresh no-hooks launch command golden

• Records the additional FULLSEND_TRUSTED_PATH export.

internal/runtime/testdata/codex/golden/launch-nohooks.txt

Documentation (2) +13 / -5
runtime-implementation.mdDocument trusted hook interpreter and PATH rules +12/-4

Document trusted hook interpreter and PATH rules

• Explains how Claude and codex hooks exclude agent-writable PATH directories, how codex exports the trusted value, and the remaining tool-file trust boundary.

docs/contributing/runtime-implementation.md

claude_integrity.goIdentify the shared preflight in integrity documentation +1/-1

Identify the shared preflight in integrity documentation

• Updates the comment describing how Bootstrap pins interpreter and PATH values covered by the hooks.json digest.

internal/runtime/claude_integrity.go

@fullsend-ai-review

fullsend-ai-review Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

🤖 Finished Review · ✅ Success · Started 6:02 AM UTC · Completed 6:11 AM UTC

Commit: 2402de8 · View workflow run →

Runtime: pi · Model: sonnet → claude-sonnet-5-5 · Effort: high · Cost: $2.09

@qodo-code-review

qodo-code-review Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (1) 📘 Rule violations (0) 🔗 Cross-repo conflicts (0) 📜 Skill insights (0)

Grey Divider


Informational

1. Codex hooks block every call under a root launch with a relative PATH entry ✗ Dismissed
Description
When the launch runs as the owner of /, envDataTrustedPath sets FULLSEND_TRUSTED_PATH to the
raw $PATH without filtering, so empty or relative entries stay in. The new adapter check
trusted_path() rejects any entry that does not start with /, so run_script fails closed and
blocks every tool call. The old FULLSEND_CODEX_PATH handling accepted the same PATH, so this is a
regression for any image that runs as root with a PATH like /usr/bin: or one containing ..
Code

internal/runtime/codex_hook/fullsend-codex-hook.py[R226-229]

+    value = os.environ.get(PINNED_PATH_ENV, "")
+    if not value or not all(d.startswith("/") for d in value.split(":")):
+        return None
+    return value
Relevance

●● Moderate

Intentional fail-closed validation conflicts with root PATH compatibility; no close precedent
resolves this regression.

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The root branch if test -O /; then printf '%s' "$PATH" records PATH as-is, and only the non-root
branch has case $d in (/*) ;; (*) continue ;; esac. The adapter then requires every :-separated
entry to start with /. Bootstrap does not catch this either: hookPreflightInterpreter only
rejects an empty PATH or one containing a newline, and codex throws the path away.

internal/runtime/env_data.go[123-127]
internal/runtime/codex_bootstrap.go[584-589]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
As root, `envDataTrustedPath` keeps `$PATH` unfiltered, including empty and relative entries. The codex hook adapter's `trusted_path()` rejects those entries, so every hook blocks.

## Fix Focus Areas
- internal/runtime/env_data.go[123-127]
- internal/runtime/codex_hook/fullsend-codex-hook.py[220-229]

## Recommended Fix
In the `test -O /` branch of `envDataTrustedPath`, still drop non-absolute and empty entries (reuse the `case $d in (/*) ;; (*) continue ;; esac` filter and only skip the writability walk). Add a test that runs as root, or one that simulates the root branch, with a PATH that has an empty entry.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


2. Hooks fail for marked interpreter paths 🐞 Bug ≡ Correctness
Description
hookPreflightInterpreter splits the probe output on the first unescaped |fullsend-hook-sep|, so
that sequence inside the pinned interpreter’s filename is mistaken for the field boundary. If a
custom image places its protected Python interpreter at such a path, the version check receives a
truncated filename and bootstrap fails despite the interpreter being usable.
Code

internal/runtime/codex_bootstrap.go[579]

+	python, path, found := strings.Cut(line, hookInterpreterSep)
Relevance

● Weak

Close precedent rejected separator-collision concerns in bootstrap output parsing.

PR-#7819

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The probe prints the resolved interpreter directly before the fixed marker, and the parser uses the
first marker as its boundary. The pin takes the resolved filename from readlink -f without
excluding that sequence.

internal/runtime/codex_bootstrap.go[552-560]
internal/runtime/codex_bootstrap.go[575-596]
internal/runtime/env_data.go[150-157]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The bootstrap probe joins an interpreter filename and PATH with an unescaped marker, then splits at the first occurrence. A valid interpreter filename containing that marker is parsed incorrectly.

## Fix Focus Areas
- internal/runtime/codex_bootstrap.go[552-588]

## Recommended Fix
Encode or length-prefix the two probe fields so their contents cannot be mistaken for a separator. Decode them before validating the interpreter and PATH, and add a test with the marker in the interpreter filename.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Dismiss ↗ | View ↗


Grey Divider

Context sources
❌ Tickets: failed to load — Ticket collection could not establish complete evidence
✅ Compliance rules (platform): 88 rules
✅ Skills: 5 invoked
  writing-user-docs
  writing-adrs
  check-patch-coverage
  cutting-releases
  adr-corner
✅ Cross-repo context — repo relationships
  Explored: repo: fullsend-ai/agents (sha: ac4082a3) — View relationship
Review mode: Auto: 🧠 Deep: Security-sensitive hook execution changes span multiple independent runtime paths.

Grey Divider

Tip of the day
💡 Did you know, you can open the rule or relationship behind a finding in one click

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

@github-actions

github-actions Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Site preview

Preview: https://62e5c41f-site.fullsend-ai.workers.dev

Commit: 04acf4823828d795c912313183937533a8ef5023

@codecov

codecov Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.36842% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
internal/runtime/codex_bootstrap.go 95.23% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@fullsend-ai-review fullsend-ai-review Bot added the risk/moderate PR risk: moderate label Oct 20, 2026
@fullsend-ai-review

fullsend-ai-review Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

<!-- fullsend:risk-assessment -->
Risk Assessment: moderate (2/5)

Details

Moderate risk is maintained reflecting a medium change size across 18 files in an active runtime subsystem with high recent commit churn, balanced by zero protected path changes, no dependency updates, solid test coverage, and a well-aligned referenced issue.

Previous run

<!-- fullsend:risk-assessment -->
Risk Assessment: moderate (2/5)

Details

Moderate risk reflects a medium change size across 16 files in an active runtime subsystem with high recent commit churn, balanced by zero protected path changes, no dependency updates, solid test coverage, and a well-aligned referenced issue.

Previous run (2)

<!-- fullsend:risk-assessment -->
Risk Assessment: moderate (2/5)

Details

Moderate change size across runtime files with high recent commit churn, offset by zero protected path or dependency changes, solid test coverage, and close alignment with an active follow-up issue.

Previous run (3)

<!-- fullsend:risk-assessment -->
Risk Assessment: moderate (2/5)

Details

Moderate change size across runtime files with high recent commit churn, offset by zero protected path or dependency changes, good test additions, and close alignment with an active follow-up issue.

@fullsend-ai-review

fullsend-ai-review Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Review

Findings

Low

  • [injection-vuln] internal/runtime/codex_bootstrap.go:281 — Hardening item, not an exploitable injection. The interpreter from hookPreflightInterpreter is now the readlink -f result of the launch pin, and codexHooksJSON (internal/runtime/codex_config.go:465, :494, unchanged by this PR) joins it into each hook command without shell quoting. Bootstrap only checks that the path is absolute. If an image installs the protected interpreter at a path with spaces or shell metacharacters, the quoted version check passes but the generated codex hook commands would misparse the path. The agent cannot control this path, because the pin only accepts a target whose file and parent directories the agent cannot write. Only the image author chooses it.
    Remediation: Optionally shellQuote each argument in both codexHooksJSON command constructors, or reject unusual characters in hookPreflightInterpreter, and add a test with a space in the resolved interpreter path.
Previous run

<!-- fullsend:review-findings-v2:eyJ2ZXJzaW9uIjoyLCJhY3Rpb24iOiJhcHByb3ZlIiwiZmluZGluZ3MiOlt7InNldmVyaXR5IjoibG93IiwiY2F0ZWdvcnkiOiJ0ZXN0LWluYWRlcXVhdGUiLCJmaWxlIjoiaW50ZXJuYWwvcnVudGltZS9jb2RleF9ob29rX3Rlc3QuZ28iLCJpZCI6ImZfNTQ0ODFiN2I1ZDg4YTIxOSIsImxpbmUiOjk4OCwiYWN0aW9uYWJsZSI6dHJ1ZX0seyJzZXZlcml0eSI6ImxvdyIsImNhdGVnb3J5IjoibmFtaW5nLWNvbnZlbnRpb24iLCJmaWxlIjoiaW50ZXJuYWwvcnVudGltZS9jb2RleF9ob29rL2Z1bGxzZW5kLWNvZGV4LWhvb2sucHkiLCJpZCI6ImZfM2E3N2ZlYTgzZmY5ZTI2MCIsImxpbmUiOjk2LCJhY3Rpb25hYmxlIjp0cnVlfV0sImRpc3Bvc2l0aW9ucyI6W3siaWQiOiJmXzU0NDgxYjdiNWQ4OGEyMTkiLCJzdGF0dXMiOiJyZXNvbHZlZF9ieV9jaGFuZ2UifSx7ImlkIjoiZl8zYTc3ZmVhODNmZjllMjYwIiwic3RhdHVzIjoicmVzb2x2ZWRfYnlfY2hhbmdlIn1dfQ== -->

Looks good to me

Previous run (2)

<!-- fullsend:review-findings-v2:eyJ2ZXJzaW9uIjoyLCJhY3Rpb24iOiJhcHByb3ZlIiwiZmluZGluZ3MiOlt7InNldmVyaXR5IjoibG93IiwiY2F0ZWdvcnkiOiJ0ZXN0LWluYWRlcXVhdGUiLCJmaWxlIjoiaW50ZXJuYWwvcnVudGltZS9jb2RleF9ob29rX3Rlc3QuZ28iLCJpZCI6ImZfNTQ0ODFiN2I1ZDg4YTIxOSIsImxpbmUiOjk4OCwiYWN0aW9uYWJsZSI6dHJ1ZX0seyJzZXZlcml0eSI6ImxvdyIsImNhdGVnb3J5IjoibmFtaW5nLWNvbnZlbnRpb24iLCJmaWxlIjoiaW50ZXJuYWwvcnVudGltZS9jb2RleF9ob29rL2Z1bGxzZW5kLWNvZGV4LWhvb2sucHkiLCJpZCI6ImZfM2E3N2ZlYTgzZmY5ZTI2MCIsImxpbmUiOjk2LCJhY3Rpb25hYmxlIjp0cnVlfV0sImRpc3Bvc2l0aW9ucyI6W3siaWQiOiJmXzU0NDgxYjdiNWQ4OGEyMTkiLCJzdGF0dXMiOiJyZXNvbHZlZF9ieV9jaGFuZ2UifSx7ImlkIjoiZl8zYTc3ZmVhODNmZjllMjYwIiwic3RhdHVzIjoicmVzb2x2ZWRfYnlfY2hhbmdlIn1dfQ== -->

Looks good to me

Earlier findings

  • f_54481b7b5d88a219 — resolved_by_change: the missing-digest test now strips only the digest env from codexAdapterBaseEnv() and asserts the refusal message.
  • f_3a77fea83ff9e260 — resolved_by_change: PINNED_PATH_ENV renamed to TRUSTED_PATH_ENV at its definition and use sites.
Previous run (3)

<!-- fullsend:review-findings-v2:eyJ2ZXJzaW9uIjoyLCJhY3Rpb24iOiJyZXF1ZXN0LWNoYW5nZXMiLCJmaW5kaW5ncyI6W3sic2V2ZXJpdHkiOiJsb3ciLCJjYXRlZ29yeSI6InRlc3QtaW5hZGVxdWF0ZSIsImZpbGUiOiJpbnRlcm5hbC9ydW50aW1lL2NvZGV4X2hvb2tfdGVzdC5nbyIsImlkIjoiZl81NDQ4MWI3YjVkODhhMjE5IiwibGluZSI6OTg4LCJhY3Rpb25hYmxlIjp0cnVlfSx7InNldmVyaXR5IjoibG93IiwiY2F0ZWdvcnkiOiJuYW1pbmctY29udmVudGlvbiIsImZpbGUiOiJpbnRlcm5hbC9ydW50aW1lL2NvZGV4X2hvb2svZnVsbHNlbmQtY29kZXgtaG9vay5weSIsImlkIjoiZl8zYTc3ZmVhODNmZjllMjYwIiwibGluZSI6OTYsImFjdGlvbmFibGUiOnRydWV9XX0= -->

Review

Findings

Low

  • [test-inadequate] internal/runtime/codex_hook_test.go:988 — In the absent-digest case of TestCodexAdapter_RefusesWithoutTheDigestEnv, cmd.Env is rebuilt from os.Environ() rather than codexAdapterBaseEnv(), so FULLSEND_TRUSTED_PATH is normally dropped along with the digest variable. Today run_script() checks the digest before the trusted PATH, so the digest refusal fires first. If missing-digest enforcement regressed, the new trusted-PATH guard would still exit 2 and the test only asserts the exit code, so this subcase no longer tests the missing-digest contract on its own.
    Remediation: Strip the digest variable from codexAdapterBaseEnv() instead of os.Environ(), and assert that the output names FULLSEND_CODEX_HOOK_DIGESTS as missing or malformed.
  • [naming-convention] internal/runtime/codex_hook/fullsend-codex-hook.py:96 — The constant PINNED_PATH_ENV = "FULLSEND_TRUSTED_PATH" keeps a name from when it pointed at FULLSEND_CODEX_PATH. That variable is still separate (the pinned PATH restored for Codex itself), so calling the trusted hook PATH "pinned" invites confusion and does not match trusted_path() or the HOOK_DIGESTS_ENV/SPAWN_DIGESTS_ENV naming.
    Remediation: Rename PINNED_PATH_ENV to TRUSTED_PATH_ENV and update its references in trusted_path() and run_script().

Next steps:

  • /fs-fix — agent addresses review findings automatically
  • /fs-fix <your instruction> — agent fixes with your specific guidance
  • Push commits directly — review re-runs automatically on push
  • /fs-fix-stop — disable automatic fix runs for this PR

fullsend-ai-review[bot]

This comment was marked as outdated.

@waynesun09

Copy link
Copy Markdown
Member Author

/fs-fix-stop

@github-actions github-actions Bot added the fullsend-no-fix Skip bot-triggered fix agent runs label Oct 20, 2026
@github-actions

Copy link
Copy Markdown

Fix agent disabled for this PR. Remove the fullsend-no-fix label or use /fs-fix to re-engage.

@fullsend-ai-review

fullsend-ai-review Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

🤖 Finished Review · ✅ Success · Started 6:28 AM UTC · Completed 6:34 AM UTC

Commit: 0879f59 · View workflow run →

Runtime: pi · Model: sonnet → claude-sonnet-5-5 · Effort: high · Cost: $1.48

fullsend-ai-review[bot]

This comment was marked as outdated.

@fullsend-ai-review fullsend-ai-review Bot added the ready-for-merge All reviewers approved — ready to merge label Oct 20, 2026
…es the agent cannot write

Resolve the Claude Code and codex hook interpreter and the hook PATH
from directories the agent cannot write.

Bootstrap now runs the launch's own python3 pin (envDataPin) in the
sandbox and reads back the pinned interpreter and the trusted PATH in a
single exec, instead of a plain `command -v python3` and the raw sandbox
PATH, which can start with a directory the agent user owns (a
virtualenv's bin). The absolute-path check and the Python 3.11 floor
stay; Bootstrap fails with a clear error when no such python3 exists.

Claude Code: hooks.json pins the trusted PATH for the hooks.

codex: the launch already records FULLSEND_TRUSTED_PATH read-only before
.env (inside envDataLoad, on the loader drop list); Run now exports it
after .env and the hook adapter sets its children's PATH from it. codex
itself keeps FULLSEND_CODEX_PATH.

Assisted-by: Claude
Signed-off-by: Wayne Sun <gsun@redhat.com>
The codex hook adapter fell back to its inherited PATH when
FULLSEND_TRUSTED_PATH was missing. The run command always exports it before
codex starts, so a missing, empty or relative-entry value means the launch
was not the one fullsend built: run_script now blocks before spawning, as
it does for a missing digest map. Docs say the trusted PATH leaves out
directories the agent user owns or can write.

Assisted-by: Claude
Signed-off-by: Wayne Sun <gsun@redhat.com>
As root the trusted PATH was the raw launch PATH, so an empty or
relative entry made the codex hook adapter block every call. Root
launches now drop relative and empty entries and missing directories
too, and skip only the ownership checks.

Rename the adapter's PINNED_PATH_ENV to TRUSTED_PATH_ENV, and make the
missing-digest test check its own refusal with the trusted PATH set.

Assisted-by: Claude
Signed-off-by: Wayne Sun <gsun@redhat.com>
@waynesun09

Copy link
Copy Markdown
Member Author

Thanks @dhshah13. The three inline asks are fixed in 04acf48. The body now covers the third commit, the root change to the shared envDataTrustedPath (it also affects pi), and the golden changes. The tirith docs, the codexAdapterBaseEnv PATH and the tree / "Not covered" LOWs are in #8631.

@fullsend-ai-review

fullsend-ai-review Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

🤖 Finished Review · ✅ Success · Started 5:07 PM UTC · Completed 5:20 PM UTC

Commit: 04acf48 · View workflow run →

Runtime: pi · Model: sonnet → claude-sonnet-5-5 · Effort: high · Cost: $2.31

@fullsend-ai-review fullsend-ai-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Note: The following review comments could not be posted on the diff (GitHub returned 422) and are included here instead:

  • internal/runtime/codex_bootstrap.go (file-level): Line 281 ·
    [low] injection-vuln

Hardening item, not an exploitable injection: the interpreter from hookPreflightInterpreter (now the readlink -f result of the launch pin) is joined unquoted into each hook command by codexHooksJSON (codex_config.go:465,494, unchanged by this PR). A protected interpreter path containing spaces or shell metacharacters would pass the quoted version check but misparse in the generated hook commands. The agent cannot control the path; only the image author does.

Suggested fix: Optionally shellQuote each argument in both codexHooksJSON command constructors, or reject unusual characters in hookPreflightInterpreter, and add a test with a space in the resolved interpreter path.

@fullsend-ai-review
fullsend-ai-review Bot dismissed their stale review October 20, 2026 17:19

Superseded by updated review

@dhshah13 dhshah13 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.

Re-checked at 04acf48: both new tests fail with their fix removed (codex Bootstrap back to command -v python3; the floor call deleted), and go test ./internal/runtime/... ./internal/security/... ./internal/cli/... pass on Linux as non-root with dash. Docs, body and the breaking marker read right. Remaining LOWs tracked in #8631.

@waynesun09
waynesun09 added this pull request to the merge queue Oct 20, 2026
Merged via the queue into main with commit bbe0ab2 Oct 20, 2026
61 checks passed
@waynesun09
waynesun09 deleted the hook-trusted-interpreter branch October 20, 2026 18:47
jctanner added a commit to jctanner-fullsend-ai/fullsend that referenced this pull request Oct 23, 2026
Retroactive record of the decision implemented in PR fullsend-ai#8605 (merged
2026-10-20): hook scripts resolve their interpreter and PATH only from
directories the agent cannot write, using the launch loader's
trusted-directory rules. Codex hooks fail closed without the trusted
environment.

Composes with ADR 0094's plugin trust model: the code that registers
tools, the code that executes the agent, and the code that observes the
agent now all resolve from agent-unwritable space.

Renumbered from 0146 to 0150 after checking open PRs for in-flight
ADR numbers (0146 = fullsend-ai#8679, 0147 = fullsend-ai#8694, 0148/0149 = fullsend-ai#8698) per the
writing-adrs skill's step 1.

Signed-off-by: James Tanner <jtanner@redhat.com>
jctanner added a commit to jctanner-fullsend-ai/fullsend that referenced this pull request Oct 23, 2026
Retroactive record of the decision implemented in PR fullsend-ai#8605 (merged
2026-10-20), extended by fullsend-ai#8589 (pi) and fullsend-ai#8633 (CLI binary pinning).
Hook scripts resolve their interpreter and PATH only from directories
the agent cannot write.

Restructured per review feedback: Decision states the rules a safe
hook setup must follow (trusted location, hooks see only trusted
locations, one resolver, protected to the point of use, no hook no
tool call, every runtime, no untrusted fallback, nothing protectable
means fail closed), with a per-runtime conformance table. Factual
corrections: the shared resolver is hookPreflightInterpreter, the
Claude PATH is baked into hooks.json at Bootstrap (not exported at
launch), Codex hook children use FULLSEND_TRUSTED_PATH (not
FULLSEND_CODEX_PATH), and pi is included (same treatment in fullsend-ai#8589,
pinned python3 not Node).

Signed-off-by: James Tanner <jtanner@redhat.com>
jctanner added a commit to jctanner-fullsend-ai/fullsend that referenced this pull request Oct 29, 2026
Renumber the ADR 0150 -> 0152 (0146-0151 are claimed by open PRs
fullsend-ai#8679, fullsend-ai#8694, fullsend-ai#8698, fullsend-ai#8702; fullsend-ai#8702 was filed first for 0150).

Per waynesun09's reviews (first round 14:56, second round 18:29):

- restructure the Decision as rules 1-10 with the conformance table
  separated out (moved to docs/contributing/runtime-implementation.md
  so it can track the implementation as the code changes, linked from
  Consequences)
- add the Options section back per the ADR template (fail-open with
  warning, per-runtime resolvers, version-floor acceptance,
  hash-verification as primary mechanism — each rejected)
- add rules 9 (executables, not just directories) and 10 (scope:
  settings sources fullsend-ai#8637, hooks.json integrity fullsend-ai#8261, plugin trust
  ADR 0094)
- gaps against the rules are tracked in issues, not the ADR: fullsend-ai#8763
  (per-file trust for every executable a hook runs) and fullsend-ai#8764 (paths
  that let a tool call through without a hook verdict), both filed by
  the reviewer; rule 8's root-launch exception stays as a one-sentence
  stated limit
- fix the pre-fullsend-ai#8605 Codex wording: the PATH was restored for itself
  and its hook adapter's children
- fix the architecture.md sentence to state the decision for all
  runtimes, not Codex only
- factual corrections from the first round: the shared resolver is
  hookPreflightInterpreter; the boundary value is FULLSEND_TRUSTED_PATH;
  the pre-fullsend-ai#8605 gap was image-PATH agent-writable dirs; pi included
  (same treatment in fullsend-ai#8589, pinned python3 not Node)

Per the dual-model review round (GLM 5.3 + DeepSeek V4.1 Flash):
- breaking change names the runtimes (pi has no version preflight)
- forge scope before Consequences, full forge list

Signed-off-by: James Tanner <jtanner@redhat.com>
jctanner added a commit to jctanner-fullsend-ai/fullsend that referenced this pull request Oct 29, 2026
Renumber the ADR 0150 -> 0152 (0146-0151 are claimed by open PRs
fullsend-ai#8679, fullsend-ai#8694, fullsend-ai#8698, fullsend-ai#8702; fullsend-ai#8702 was filed first for 0150).

Per waynesun09's reviews (first round 14:56, second round 18:29):

- restructure the Decision as rules 1-10 with the conformance table
  separated out (moved to docs/contributing/runtime-implementation.md
  so it can track the implementation as the code changes, linked from
  Consequences)
- add the Options section back per the ADR template
- add rules 9 (executables, not just directories) and 10 (scope)
- gaps tracked in issues only: fullsend-ai#8763 and fullsend-ai#8764 linked bare, no
  implementation-state prose in the ADR
- fold the root-launch case into rule 8 as an explicit scope
  precondition (accurate wording: the PATH still drops relative,
  empty, and missing entries as root; it cannot exclude
  agent-writable directories) instead of a contradictory
  Consequences 'limit'
- cite the pre-fullsend-ai#8605 Codex behavior at the correct SHA
  (bbe0ab2^1 = 191d723), not unqualified line numbers
- state the OpenCode exclusion in rule 6 and the conformance table
  (no ADR 0090 hook wiring until unbound-force#515)
- fix the fullsend-ai#8589 chronology (merged earlier the same day as fullsend-ai#8605,
  not an extension after it)
- fix the Options wording on hash verification (detects a
  substitution only at the next check; the ADR 0094 preflight
  detects at check time, not 'after the fact')
- reference PR fullsend-ai#8261 explicitly as a PR
- fix the architecture.md sentence to state the decision for all
  runtimes, not Codex only
- factual corrections from the first round: the shared resolver is
  hookPreflightInterpreter; the boundary value is FULLSEND_TRUSTED_PATH;
  the pre-fullsend-ai#8605 gap was image-PATH agent-writable dirs; pi included
  (same treatment in fullsend-ai#8589, pinned python3 not Node)
- update the conformance table Codex row to the post-fullsend-ai#8633 mechanism
  (envDataTrustedPin within codexBinaryPin) with the bbe0ab2 state
  noted

Per the dual-model review round (GLM 5.3 + DeepSeek V4.1 Flash):
- breaking change names the runtimes (pi has no version preflight)
- forge scope before Consequences, full forge list

Signed-off-by: James Tanner <jtanner@redhat.com>
jctanner pushed a commit to jctanner-fullsend-ai/fullsend that referenced this pull request Oct 29, 2026
Retroactive record of the decision implemented in PR fullsend-ai#8605 (merged
2026-10-20, merge commit bbe0ab2), with PR fullsend-ai#8589 (pi, merged earlier
the same day) and extended by PR fullsend-ai#8633 (CLI binary pinning, issue
fullsend-ai#8626): hook interpreters and hook PATH resolve only from directories
the agent cannot write; hook settings are runner-held; startup is
fail-closed on all runtimes carrying sandbox tool hooks.

Decision stated as rules 1-10 with a per-runtime conformance table in
docs/contributing/runtime-implementation.md (linked from Consequences
so it tracks the implementation as code changes). Gaps against the
rules are tracked in issues fullsend-ai#8763 and fullsend-ai#8764, both filed by the
reviewer. The root-launch case is folded into rule 8 as an explicit
scope precondition. OpenCode is excluded (no ADR 0090 hook wiring
until unbound-force#515).

Cross-references updated in the same PR per docs/contributing/adrs.md:
ADR 0090 and ADR 0100 implementation notes, architecture.md runtime
contract bullet, and the tool-call risk assessment problem doc (which
previously stated pi hooks stay writable between iterations).

Signed-off-by: James Tanner <jtanner@redhat.com>
jctanner pushed a commit to jctanner-fullsend-ai/fullsend that referenced this pull request Oct 29, 2026
Retroactive record of the decision implemented in PR fullsend-ai#8605 (merged
2026-10-20, merge commit bbe0ab2), with PR fullsend-ai#8589 (pi, merged earlier
the same day) and extended by PR fullsend-ai#8633 (CLI binary pinning, issue
fullsend-ai#8626): hook interpreters and hook PATH resolve only from directories
the agent cannot write; hook settings are runner-held; startup is
fail-closed on all runtimes carrying sandbox tool hooks.

Decision stated as rules 1-10 with a per-runtime conformance table in
docs/contributing/runtime-implementation.md (linked from Consequences
so it tracks the implementation as code changes). Gaps against the
rules are tracked in issues fullsend-ai#8763 and fullsend-ai#8764, both filed by the
reviewer. The root-launch case is folded into rule 8 as an explicit
scope precondition. OpenCode is excluded (no ADR 0090 hook wiring
until unbound-force#515).

Cross-references updated in the same PR per docs/contributing/adrs.md:
ADR 0090 and ADR 0100 implementation notes, architecture.md runtime
contract bullet, and the tool-call risk assessment problem doc (which
previously stated pi hooks stay writable between iterations).

Signed-off-by: James Tanner <jtanner@redhat.com>
jctanner pushed a commit to jctanner-fullsend-ai/fullsend that referenced this pull request Oct 29, 2026
Retroactive record of the decision implemented in PR fullsend-ai#8605 (merged
2026-10-20, merge commit bbe0ab2), with PR fullsend-ai#8589 (pi, merged earlier
the same day) and extended by PR fullsend-ai#8633 (CLI binary pinning, issue
fullsend-ai#8626): hook interpreters and hook PATH resolve only from directories
the agent cannot write; hook settings are runner-held; startup is
fail-closed on all runtimes carrying sandbox tool hooks.

Decision stated as rules 1-10 with a per-runtime conformance table in
docs/contributing/runtime-implementation.md (linked from Consequences
so it tracks the implementation as code changes). Gaps against the
rules are tracked in issues fullsend-ai#8763 and fullsend-ai#8764, both filed by the
reviewer. The root-launch case is folded into rule 8 as an explicit
scope precondition. OpenCode is excluded (no ADR 0090 hook wiring
until unbound-force#515).

Cross-references updated in the same PR per docs/contributing/adrs.md:
ADR 0090 and ADR 0100 implementation notes, architecture.md runtime
contract bullet, and the tool-call risk assessment problem doc (which
previously stated pi hooks stay writable between iterations).

Signed-off-by: James Tanner <jtanner@redhat.com>
jctanner added a commit to jctanner-fullsend-ai/fullsend that referenced this pull request Oct 29, 2026
Retroactive record of the decision implemented in PR fullsend-ai#8605 (merged
2026-10-20, merge commit bbe0ab2), with PR fullsend-ai#8589 (pi, merged earlier
the same day) and extended by PR fullsend-ai#8633 (CLI binary pinning, issue
fullsend-ai#8626): hook interpreters and hook PATH resolve only from directories
the agent cannot write; hook settings are runner-held; startup is
fail-closed on all runtimes carrying sandbox tool hooks.

Decision stated as rules 1-10 with a per-runtime conformance table in
docs/contributing/runtime-implementation.md (linked from Consequences
so it tracks the implementation as code changes). Gaps against the
rules are tracked in issues fullsend-ai#8763 and fullsend-ai#8764, both filed by the
reviewer. The root-launch case is folded into rule 8 as an explicit
scope precondition. OpenCode is excluded (no ADR 0090 hook wiring
until unbound-force#515).

Cross-references updated in the same PR per docs/contributing/adrs.md:
ADR 0090 and ADR 0100 implementation notes, architecture.md runtime
contract bullet, and the tool-call risk assessment problem doc (which
previously stated pi hooks stay writable between iterations).

Signed-off-by: James Tanner <tanner.jc@gmail.com>
jctanner added a commit to jctanner-fullsend-ai/fullsend that referenced this pull request Oct 29, 2026
Retroactive record of the decision implemented in PR fullsend-ai#8605 (merged
2026-10-20, merge commit bbe0ab2), with PR fullsend-ai#8589 (pi, merged earlier
the same day) and extended by PR fullsend-ai#8633 (CLI binary pinning, issue
fullsend-ai#8626): hook interpreters and hook PATH resolve only from directories
the agent cannot write; hook settings are runner-held; startup is
fail-closed on all runtimes carrying sandbox tool hooks.

Decision stated as rules 1-10 with a per-runtime conformance table in
docs/contributing/runtime-implementation.md (linked from Consequences
so it tracks the implementation as code changes). Gaps against the
rules are tracked in issues fullsend-ai#8763 and fullsend-ai#8764, both filed by the
reviewer. The root-launch case is folded into rule 8 as an explicit
scope precondition. OpenCode is excluded (no ADR 0090 hook wiring
until unbound-force#515).

Cross-references updated in the same PR per docs/contributing/adrs.md:
ADR 0090 and ADR 0100 implementation notes, architecture.md runtime
contract bullet, and the tool-call risk assessment problem doc (which
previously stated pi hooks stay writable between iterations).

Signed-off-by: James Tanner <tanner.jc@gmail.com>
jctanner added a commit to jctanner-fullsend-ai/fullsend that referenced this pull request Oct 29, 2026
Retroactive record of the decision implemented in PR fullsend-ai#8605 (merged
2026-10-20, merge commit bbe0ab2), with PR fullsend-ai#8589 (pi, merged earlier
the same day) and extended by PR fullsend-ai#8633 (CLI binary pinning, issue
fullsend-ai#8626): hook interpreters and hook PATH resolve only from directories
the agent cannot write; hook settings are runner-held; startup is
fail-closed on all runtimes carrying sandbox tool hooks.

Decision stated as rules 1-10 with a per-runtime conformance table in
docs/contributing/runtime-implementation.md (linked from Consequences
so it tracks the implementation as code changes). Gaps against the
rules are tracked in issues fullsend-ai#8763 and fullsend-ai#8764, both filed by the
reviewer. The root-launch case is folded into rule 8 as an explicit
scope precondition. OpenCode is excluded (no ADR 0090 hook wiring
until unbound-force#515).

Cross-references updated in the same PR per docs/contributing/adrs.md:
ADR 0090 and ADR 0100 implementation notes, architecture.md runtime
contract bullet, and the tool-call risk assessment problem doc (which
previously stated pi hooks stay writable between iterations).

Signed-off-by: James Tanner <tanner.jc@gmail.com>
jctanner added a commit to jctanner-fullsend-ai/fullsend that referenced this pull request Oct 29, 2026
Retroactive record of the decision implemented in PR fullsend-ai#8605 (merged
2026-10-20, merge commit bbe0ab2), with PR fullsend-ai#8589 (pi, merged earlier
the same day) and extended by PR fullsend-ai#8633 (CLI binary pinning, issue
fullsend-ai#8626): hook interpreters and hook PATH resolve only from directories
the agent cannot write; hook settings are runner-held; startup is
fail-closed on all runtimes carrying sandbox tool hooks.

Decision stated as rules 1-10 with a per-runtime conformance table in
docs/contributing/runtime-implementation.md (linked from Consequences
so it tracks the implementation as code changes). Gaps against the
rules are tracked in issues fullsend-ai#8763 and fullsend-ai#8764, both filed by the
reviewer. The root-launch case is folded into rule 8 as an explicit
scope precondition. OpenCode is excluded (no ADR 0090 hook wiring
until unbound-force#515).

Cross-references updated in the same PR per docs/contributing/adrs.md:
ADR 0090 and ADR 0100 implementation notes, architecture.md runtime
contract bullet, and the tool-call risk assessment problem doc (which
previously stated pi hooks stay writable between iterations).

Signed-off-by: James Tanner <tanner.jc@gmail.com>

This branch was successfully deployed

1 active and 1 inactive deployments
site-preview — 04acf482 Deployed Oct 20, 2026 by github-actions[bot]
dev — 04acf482 Deployed Oct 20, 2026 by waynesun09 via playback #17368
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fullsend-no-fix Skip bot-triggered fix agent runs ready-for-merge All reviewers approved — ready to merge risk/moderate PR risk: moderate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants