as a follwo up to https://github.com/entireio/cli/pull/1235 We got this feedback: I took…
- User
as a follwo up to https://github.com/entireio/cli/pull/1235
We got this feedback:
I took a look at the PR, and it mostly looks great.
One thing still worth considering (from my perspective): ResolveSessionFile() in pi.go and codex.go still pass absolute paths which rely on call-site discipline as opposed to DiD which you have done in the other fixes. If other/future development calls ResolveSessionFile() on remote data without a prior ValidateSessionID() check, the vulnerability comes back.
Consider something like:
(in pi.go + codex.go) if filepath.IsAbs(agentSessionID) {
- return agentSessionID, nil
- return "", fmt.Errorf("session ID must be relative, got absolute path: %q", agentSessionID) }
I haven't done the diligence to know if Pi's live session hooks actually require (which is bad practice in general, but I digress) absolute paths. If they do, that use case should be abstracted to a separate method outside of the restore path.
Assistant· claude-opus-4-8
I'll look at the current state of
ResolveSessionFile()in both files and understand the context from PR #1235.Assistant· claude-opus-4-8
Now let me understand the interface signature and how
ResolveSessionFileis called across the codebase.Assistant· claude-opus-4-8
Let me look at how the restore path validates session IDs (the DiD approach mentioned), and how other agents handle this.
- User
[Request interrupted by user]
- User
sorry, this is the right PR https://github.com/entireio/cli/pull/1365 for the context for this feedback:
I took a look at the PR, and it mostly looks great.
One thing still worth considering (from my perspective): ResolveSessionFile() in pi.go and codex.go still pass absolute paths which rely on call-site discipline as opposed to DiD which you have done in the other fixes. If other/future development calls ResolveSessionFile() on remote data without a prior ValidateSessionID() check, the vulnerability comes back.
Consider something like:
(in pi.go + codex.go) if filepath.IsAbs(agentSessionID) {
- return agentSessionID, nil
- return "", fmt.Errorf("session ID must be relative, got absolute path: %q", agentSessionID) }
I haven't done the diligence to know if Pi's live session hooks actually require (which is bad practice in general, but I digress) absolute paths. If they do, that use case should be abstracted to a separate method outside of the restore path.
Assistant· claude-opus-4-8
The context is clear now. Let me read the documented security contract on the
Agentinterface and understand whether the absolute-path passthrough is actually exercised by any legitimate caller.Assistant· claude-opus-4-8
Let me check whether any legitimate live caller actually passes an absolute path to
ResolveSessionFile(the comment claims hook payloads rely on it). Let me trace the attach flow and pi/codex lifecycle.Assistant· claude-opus-4-8
I now have the full picture. Let me confirm my key finding before proposing a fix:
The absolute-path passthrough is a footgun with no legitimate caller. All six call sites of
ResolveSessionFileeither validate the ID withValidateSessionIDfirst (transcript.go:28,manual_commit_rewind.go:708/867, and the attach flow which goes throughresolveTranscriptPath) or derive the ID from a path basename that can never be absolute (resolve_transcript.go:54). The live Pi/Codex hook flow recordsSessionRefdirectly and reads it viaReadSession— it never round-trips throughResolveSessionFile. So theif filepath.IsAbs(...) { return verbatim }branch is dead code for legitimate input and live only as an attack surface.That means we can harden it freely. There are two reasonable shapes for the fix, with a real trade-off:
Assistant· claude-opus-4-8
The user wants the signature change to
(string, error). This touches the interface, all 11 implementations, the external wrapper, and the callers. Let me read all the implementations and callers so I update them correctly.Assistant· claude-opus-4-8
Now the two internal lifecycle callers and the external wrapper:
Assistant· claude-opus-4-8
I have the full inventory. Let me find all test call sites that need updating too.
Assistant· claude-opus-4-8
This is a broad change. Let me check for any other
Agentinterface implementers (mocks, e2e, external protocol handler) I haven't accounted for.Assistant· claude-opus-4-8
This is a large mechanical change across the interface, 11 implementations, 5 production callers, and ~19 test files. Let me track it with a task list.
Assistant· claude-opus-4-8
Starting with the interface:
Assistant· claude-opus-4-8
Now pi.go:
Assistant· claude-opus-4-8
Now the 7 straightforward implementations. cursor.go:
Assistant· claude-opus-4-8
Now external.go (propagate errors) and the wrapper:
Assistant· claude-opus-4-8
Now the two internal lifecycle callers (cursor + copilot):
Assistant· claude-opus-4-8
Now the production callers. transcript.go:41:
Assistant· claude-opus-4-8
Now manual_commit_rewind.go — line 730 (RestoreLogsOnly, has warnings) and line 881:
Assistant· claude-opus-4-8
Now resolve_transcript.go:56:
Assistant· claude-opus-4-8
Let me build the production code to catch any remaining issues before tackling tests:
Assistant· claude-opus-4-8
A caller I missed in e2e/testutil:
Assistant· claude-opus-4-8
Production builds. Now let me vet with all build tags to catch e2e/integration callers:
Assistant· claude-opus-4-8
Now the test mocks. Let me update each mock signature. First the simple one-liner stubs:
Assistant· claude-opus-4-8
Now rewind_test.go (two mocks at 648 and 684):
Assistant· claude-opus-4-8
Now the test assertions. cursor_test.go (5 call sites):
Assistant· claude-opus-4-8
Now copilotcli/security_contract_test.go — this one needs the contract reframed (copilot uses ID as dir component, doesn't reject absolute):
Assistant· claude-opus-4-8
Now claudecode/claude_test.go:
Assistant· claude-opus-4-8
Now codex_test.go (lines 96, 123):
Assistant· claude-opus-4-8
These use
require. Let me update both:Assistant· claude-opus-4-8
Now codex/security_contract_test.go — rewrite to assert the new error-returning behavior:
Assistant· claude-opus-4-8
Now gemini_test.go (3 calls):
Assistant· claude-opus-4-8
Now pi/session_resolve_test.go — multiple calls plus rewriting the passthrough test to assert rejection:
Assistant· claude-opus-4-8
Now the remaining three pi calls (lines ~118, ~129, ~142):
Assistant· claude-opus-4-8
Let me re-run vet with all tags to find any remaining call sites I missed:
Assistant· claude-opus-4-8
All build/vet clean across tags. Let me check whether the resume/rewind restore path has a regression test I should extend to assert the new behavior, then run the full check.
Assistant· claude-opus-4-8
This test's doc comment now describes the pre-fix behavior. Let me update it to reflect the new defense-in-depth layer:
Assistant· claude-opus-4-8
gofmt aligned the struct method blocks. Now lint and tests:
Assistant· claude-opus-4-8
Lint clean. Now the full test suite:
Assistant· claude-opus-4-8
A failure is hidden above the tail. Let me find it:
Assistant· claude-opus-4-8
Passed (EXIT=0). The earlier
FAILwas a flake unrelated to my change. Let me confirm the packages I touched pass deterministically with a couple of repeats:Assistant· claude-opus-4-8
These two failures involve the global agent registry — likely
-count=2re-registration state leakage, not my change. Let me verify withcount=1:Assistant· claude-opus-4-8
count=1passes. The two failures only occur under-count=2because those tests register external agents in the global agent registry and aren't re-entrant — a pre-existing isolation quirk unrelated to this change (my edits don't touch registration). CI runscount=1, andtest:cipassed green (EXIT=0).Assistant· claude-opus-4-8
- User
can we first commit this changes, and then yes I think we should apply it everywhere
Assistant· claude-opus-4-8
I'll commit the current scoped change first, then extend the rejection to all agents.
Assistant· claude-opus-4-8
We're on a feature branch
soph/more-path-hardeningalready. Let me commit the scoped change.Assistant· claude-opus-4-8
Committed as
32e45a5efe. Now let me extend the absolute-path rejection to all agents. To avoid duplicating thefilepath.IsAbscheck across 9 files (and tripping thedupllinter), I'll add a shared helper in thevalidationpackage and route every agent through it — including refactoring Pi/Codex to use it.Assistant· claude-opus-4-8
Now refactor Pi and Codex to use the helper, then apply to the other 7. First Pi:
Assistant· claude-opus-4-8
Let me check Pi's imports (need
validation, may no longer needfmtif it was only used there):Assistant· claude-opus-4-8
Now Codex — it already imports
validation:Assistant· claude-opus-4-8
Now the 7 other agents. Let me check which already import
validation:Assistant· claude-opus-4-8
I'll add the import and guard to each. Starting with cursor:
Assistant· claude-opus-4-8
copilotcli:
Assistant· claude-opus-4-8
factoryaidroid:
Assistant· claude-opus-4-8
claudecode:
Assistant· claude-opus-4-8
geminicli:
Assistant· claude-opus-4-8
vogon:
Assistant· claude-opus-4-8
opencode:
Assistant· claude-opus-4-8
Now external.go — guard the input before invoking the subprocess:
Assistant· claude-opus-4-8
Now update the interface doc — all implementations now reject absolute IDs:
Assistant· claude-opus-4-8
Now let me build to catch import/compile issues:
Assistant· claude-opus-4-8
Builds clean. Now let me add a registry-wide contract test asserting every built-in agent rejects an absolute ID — this is the durable "everywhere" guard. Let me see how agents are registered/enumerated:
Assistant· claude-opus-4-8
I'll write a registry-wide contract test that blank-imports every built-in agent and asserts each rejects an absolute ID — a durable guard for current and future agents:
Assistant· claude-opus-4-8
Now a direct test for the external agent (not in the built-in registry). Let me check how
external.Agentis constructed in its tests:Assistant· claude-opus-4-8
The external test is in-package (
package external), so I can construct&Agent{}directly. The guard runs beforee.run, so no subprocess is needed. Let me add a focused test:Assistant· claude-opus-4-8
Now format and verify everything compiles across tags:
Assistant· claude-opus-4-8
Clean. Now lint and the new tests:
Assistant· claude-opus-4-8
wrapcheckflags returning the helper's error unwrapped (10 sites). Let me check the lint config for the right convention:Assistant· claude-opus-4-8
Tests pass. The
wrapchecklinter wants the helper's error wrapped at all 10 call sites. Rather than add redundant wrapping everywhere, the cleanest fix is to tell wrapcheck to treat this guard like the other in-house error sources. Let me check the precise wrapcheck setting supported here:Assistant· claude-opus-4-8
I'll add
extra-ignore-sigsfor the guard so wrapcheck treats it like the in-house error sources it already ignores:Assistant· claude-opus-4-8
extra-ignore-sigsis accepted and lint is clean. Now the full test suite:Assistant· claude-opus-4-8
All green (EXIT=0, including the Vogon canary). Let me do a final review of the diff before committing:
Assistant· claude-opus-4-8
Clean. Let me commit this second change.
Assistant· claude-opus-4-8
Both changes are committed on
soph/more-path-hardening.Summary
Commit 1 (
32e45a5efe) — the scoped change you reviewed earlier:ResolveSessionFilesignature →(string, error), with Pi and Codex rejecting absolute IDs.Commit 2 (
e5a7465b61) — extended the rejection to every agent:- Single source of truth: new
validation.RejectAbsoluteSessionID(rejectsfilepath.IsAbsand Windows drive-relative volume names, mirroring the existing absolute check).
- Single source of truth: new