Commit Graph
6 Commits
Author SHA1 Message Date
Philip Taron 6fa10dae73 ssh/tailssh: accept an empty --groups= in the incubator
Fixes #22158

Change-Id: I238244c34c96c444c258b9e006c0084f4aa8db27
Signed-off-by: Philip Taron <[email protected]>
2026-11-03 12:36:20 -08:00
Percy Wegmann b1582deed4 ssh/tailssh: set $LOGNAME to same value as $USER in incubator
When the ssh incubator runs the shell itself instead of using `su` or `login`,
it needs to set the `$LOGNAME` environment variable. Just like OpenSSH `sshd`,
it sets this to the same value as `$USER`.

Updates tailscale/corp#50380

Signed-off-by: Percy Wegmann <[email protected]>
2026-10-26 17:25:45 -05:00
James Tucker 79d5abe043 ssh/tailssh: launch sessions via the monitor
Launch incubator sessions through the per-connection monitor, passing
stdio and the optional environment pipe via SCM_RIGHTS. tailscaled
retains the parent I/O descriptors. Keep direct launch when no
tailscaled binary is available, and on Plan 9.

Wait for dispatched exec replies even after session cancellation so
the session retains ownership of any child that starts. Publish exit
status through persistent completion state. Identify monitor children
by PID and exec request ID, and validate both when signaling. Remove
raw-PID signaling after monitor teardown.

Normalize incubator identity flags and reject alternate spellings
that could override them. The monitor RPC caller remains trusted to
supply the executable and other arguments; this is not a privilege
boundary against tailscaled.

Pass default TERM and locale values through the environment pipe,
preserving last-value-wins defaults and policy-forwarded precedence.
Use a separately owned close-on-exec PTY descriptor for resizing.

Add regression tests for launch cancellation, exit delivery, signal
identity, descriptor ownership, and environment handling.

Updates tailscale/corp#50380

Signed-off-by: James Tucker <[email protected]>
2026-10-26 07:49:11 -07:00
James Tucker d484ac300e ssh/tailssh: refuse direct-exec fallback for non-root users as root
When tailscaledPath is empty, newIncubatorCommand runs the session's
shell directly, with no be-child incubator to drop privileges. A root
tailscaled could therefore run a non-root user's session as root.
Refuse that case, mirroring canSwitchToLocalUser's semantics.

Updates tailscale/corp#50380

Signed-off-by: James Tucker <[email protected]>
2026-10-24 13:52:48 -07:00
James Tucker ec40639b05 ssh/tailssh: extend dangerous env var denylist, re-check child-side
GCONV_PATH, LOCPATH, NLSPATH, HOSTALIASES and RES_OPTIONS can make
privileged processes (root su/login environments built from forwarded
vars) load attacker-controlled files or redirect resolver lookups; add
them to the isDangerousEnvVar denylist, and apply the same check in the
incubator child when it re-filters the inherited forwarded-env payload
(old parents may not have filtered them).

Updates tailscale/corp#50380

Signed-off-by: James Tucker <[email protected]>
2026-10-24 12:41:58 -07:00
Patrick O'DohertyandMike Jensen 9d48dbd561 ssh/tailssh: keep acceptEnv values and names out of the incubator cmdline (#20552)
Previously the acceptEnv variables forwarded to the incubator child were
JSON-encoded onto its command line (--encoded-env), so their values were
visible in /proc/<pid>/cmdline to any other local user and were logged in
the session-start argv (locally and to log.tailscale.com except where
--no-logs-no-support was specified).

This change now carries those variables through an os.Pipe file
descriptor as a json encoded payload. Added end-to-end testing
helps validate secrets reach the session but are not in flags or logged.

Fixes tailscale/corp#44903

Change-Id: I5b137b20e9c06feec6b70aaf4e6925e6db74017e

Signed-off-by: Mike Jensen <[email protected]>
Co-authored-by: Mike Jensen <[email protected]>
2026-07-30 09:57:55 -06:00