daemon, client-core: keymap-command origin variables leak into launched processes #223
Labels
No labels
Area/ci
Area/cli
Area/client
Area/client-core
Area/daemon
Area/deps
Area/docs
Area/grid
Area/manual
Area/nix
Area/protocol
Area/pty
Area/render
Area/shaping
Area/skills
Area/transport
Area/vt
Compat/Breaking
Kind/Bug
Kind/Documentation
Kind/Enhancement
Kind/Feature
Kind/Performance
Kind/Security
Kind/Testing
perf-regression-accepted
Reviewed
Confirmed
Reviewed
Duplicate
Reviewed
Invalid
Reviewed
Won't Fix
Status
Blocked
Status
Need More Info
Status
Upstream
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
felis-terminal/felis#223
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
The keymap-command origin variables (
FELIS_ORIGIN_SESSION_ID,FELIS_HOST,FELIS_CWD, and the viewport anchorsFELIS_INPUT_LINE_NUMBER,FELIS_CURSOR_LINE,FELIS_CURSOR_COLUMN) describe one chord, but nothing removes them from an inherited environment.child_envincrates/felis-client-core/src/pipe.rsonly adds the values the current origin has, and the daemon'sapply_env_policy(crates/felis-daemon/src/lib.rs) does not scrub them.So a felis process launched from a keymap command carries the chord's values onward:
runfrom a--hostwindow → the command launches a localfeliswindow → that client's env (and itsenv_basesnapshot) holds the oldFELIS_HOST→ a later chord from a local session in the new window, which has no host, still seesFELIS_HOST=<remote>. A script that branches on it dials the wrong daemon.FELIS_CWDwhen the new origin has noOSC 7, and to the anchors forrun/ unanchored regions, which keybindings.md documents as unset.Today this needs a
runcommand that backgrounds a window launch itself (felis &), so it is latent; backgroundrun(#224) makes it the ordinary path. Reasoned from the source; not reproduced in a window.Proposed fix
Scrub where every session's environment is already finalized, then set only the current origin's values.
ORIGIN_ENVlist of the six names, removed inapply_env_policynext toENV_DENYLIST. That function runs for every create whatever the base (EnvBaseSource::Request,Relay,Birth), so it covers a snapshot, the relay carrier's env, a daemon whose birth env carries them (including asystemd-runhand-off and the over-cap capture fallback). UnlikeENV_DENYLISTit is not part ofRESERVED_ENV_KEYS, soSpawnArgs.envmay still set them: the transient'schild_envpairs are applied after the scrub and reach the command.run, #224)env_removes the six before setting the current origin's values, independent of the env snapshot (which isNoneover its caps).Rejected: scrubbing at the capture and at
daemon_commandonly. The relay base and asystemd-run-handed-off daemon bypass both.Tests
SpawnArgs.envyields exactly those values (the transient path).OSC 7on a local carrier, sees noFELIS_CWD/FELIS_HOSTand the currentFELIS_ORIGIN_SESSION_ID.Cascade:
docs/reference/keybindings.md(origin variables are never inherited),docs/explanation/security-model.md"Process and environment boundary" if it enumerates the scrubbed lists, CHANGELOG (Fixed).