feat(sandbox): add --no-login-shell to skip shell startup files on exec - #2852
feat(sandbox): add --no-login-shell to skip shell startup files on exec#2852letv1nnn wants to merge 5 commits into
Conversation
Signed-off-by: Artem Lytvyn <alytvyn@redhat.com>
…o-login-shell Signed-off-by: Artem Lytvyn <alytvyn@redhat.com>
Signed-off-by: Artem Lytvyn <alytvyn@redhat.com>
Signed-off-by: Artem Lytvyn <alytvyn@redhat.com>
johntmyers
left a comment
There was a problem hiding this comment.
gator-agent
PR Review Status
An operator who upgrades the gateway while an existing sandbox keeps its older supervisor can request non-login execution, but that supervisor accepts and ignores the new signal, so user-controlled startup files still run without any error.
Action required: add supervisor capability negotiation and fail closed for no_login_shell when the connected supervisor does not advertise support, with coverage for unary and interactive exec.
Blocking findings:
GATOR-7d79a247-01: the opt-out silently falls back to a login shell with a pre-change supervisor.
Carried findings:
- None
Gator metadata
- Validation: Project-valid through accepted issue #2668.
- Docs: Fern sandbox documentation and architecture documentation are updated.
- Checks: Current head has passing DCO and status-publication checks; required workflows have not yet been dispatched.
- E2E: Required for the sandbox/gateway/supervisor behavior change after review feedback is resolved.
- Head SHA:
7d79a247134fd446e9146759b92a6f423b6b7b45 - Base SHA:
20d2e867e0e25b24d383a78dd362ba5647ef12c8 - Merge base SHA:
20d2e867e0e25b24d383a78dd362ba5647ef12c8 - Patch ID:
24c2ca391d463bf4a7214e11fb9274058913da31 - Gator payload:
7 - Review mode:
initial - Previous reviewed SHA: none
- Review budget exhausted: no
- Maintainer decision required: no
- Next state:
gator:in-review
|
hey @johntmyers, summarizing what we've got. I don't think pre-0.1.0 fully covers us here, since it's less a versioning thing than a timing one. The supervisor is baked into each sandbox and never updates, while the gateway upgrades separately, so a sandbox created just before a gateway upgrade keeps its old supervisor. That can show up in a normal deploy, not only across releases. When it does, the old supervisor quietly ignores Then there are two possibilities to solve the problem.
Worth noting: this isn't exec-only. There are already two of these signals riding SSH env requests, My lean is that if we expect the gateway↔sandbox SSH surface to keep growing (more flags like this), the first option is worth building now, it turns "every new feature re-solves skew" into "every new feature adds one string." If this stays a one-off, then the second option is the cheaper fail-closed fix. Either way the outcome is the same fail-closed behavior: reject rather than silently fall back to the login shell. So my suggestion: land a minimal fail-closed gate here so this PR doesn't ship the silent fallback, and split the general session-scoped handshake into its own issue. |
Signed-off-by: Artem Lytvyn <alytvyn@redhat.com>
Author Follow-Up NudgeThis PR has been in @letv1nnn, please respond to the review comments or push an update. The pending action is to implement a fail-closed compatibility gate for |
|
Thanks for the nudge, this is still on, just pushed the fix. Went with the fail-closed gate (option 2 from my earlier comment). The supervisor now stamps its version into the SSH banner ( Filed the broader fail-closed capability negotiation (incl. |
|
Label |
johntmyers
left a comment
There was a problem hiding this comment.
gator-agent
Re-check After Author Update
Thanks @letv1nnn. I checked your current-head SSH banner gate against the older-supervisor fallback you described: both unary and interactive exec now reject --no-login-shell with FailedPrecondition unless the connected supervisor advertises the new OpenShell banner. The prior compatibility finding is resolved, and I found no new blocking issues in the author-only delta.
Blocking findings:
- No blocking findings remain
Carried findings:
GATOR-7d79a247-01: resolved by the current-head fail-closed banner gate and dual-path coverage
Gator metadata
- Validation: Project-valid through accepted issue #2668.
- Docs: Fern sandbox documentation and architecture documentation are updated.
- Checks: DCO and status publication pass; required branch, Helm, and E2E workflows are not yet dispatched for the current head.
- E2E:
test:e2eapplied; E2E Label Help is running and its instructions are pending. - Head SHA:
6fa8778bb206cec519f63fd4a6cf144b37738a00 - Base SHA:
20d2e867e0e25b24d383a78dd362ba5647ef12c8 - Merge base SHA:
20d2e867e0e25b24d383a78dd362ba5647ef12c8 - Patch ID:
ccf68c26397501a27c81465b03c96c858e410e25 - Gator payload:
7 - Review mode:
follow_up - Previous reviewed SHA:
7d79a247134fd446e9146759b92a6f423b6b7b45 - Review budget exhausted: no
- Maintainer decision required: no
- Next state:
gator:in-review
|
/ok to test 6fa8778 |
Summary
sandbox execalways ran commands through a login shell (bash -lc), so sandbox-user startup files (.profile,.bash_profile,.bashrc) were sourced before the requested command — letting them alter its output, create files, or block it, which madeexecunsuitable as a trusted execution boundary for automation and managed checks. This adds an opt-out (--no-login-shell/no_login_shell) that runs the command without sourcing those files, while the login-shell default is preserved for existing callers.Related Issue
Closes #2668
Changes
no_login_shellfield toExecSandboxRequestinproto/openshell.proto(defaultfalsepreserves current login-shell behavior).openshell-server): read the field and signal it to the supervisor over an SSHOPENSHELL_NO_LOGIN_SHELLenv request, sent beforeexecon both the non-interactive and interactive russh paths.openshell-supervisor-process): store the flag fromenv_request, thread it throughstart_shellto the PTY and pipe spawn sites, and selectbash -cinstead ofbash -lcwhen set.openshell-cli): add--no-login-shellflag tosandbox exec, wired through to both the streaming and interactive request builders.ExecOptions.no_login_shell), Go (ExecOptions.NoLoginShell), Python (no_login_shellkwarg), and TypeScript (noLoginShell) exec APIs. - Docs: document the flag and tradeoff indocs/sandboxes/manage-sandboxes.mdx; note the login-shell default and SSH env carrier inarchitecture/sandbox.md.Reproduction
Podman-backed sandbox with a profile marker seeded in
~/.bash_profile(echo PROFILE-RAN):Testing
mise run pre-commitpassesChecklist