Skip to content

[v14] Read ~/.tsh/environment as the target user#52139

Merged
r0mant merged 1 commit intobranch/v14from
eriktate/v14/tshenvfix
Feb 13, 2025
Merged

[v14] Read ~/.tsh/environment as the target user#52139
r0mant merged 1 commit intobranch/v14from
eriktate/v14/tshenvfix

Conversation

@r0mant
Copy link
Copy Markdown
Collaborator

@r0mant r0mant commented Feb 13, 2025

This PR adds a readfile sub-command that can be reexec'd in order to read a file as a target user. This is useful in cases where we need to do some processing on file contents as root, but we want to make sure the target user has access to the file at the time of reading it (e.g. to prevent arbitrary file reads as root on behalf of the user). It works by passing an os.Pipe to the subcommand in order to send the file contents back to the parent process. To support future use cases, ProcessFileAsUser is generic and accepts a process() callback responsible for reading file contents from an io.Reader and marshaling into some type T.

changelog: Fixed security issue with arbitrary file reads on SSH nodes.

@r0mant r0mant added this pull request to the merge queue Feb 13, 2025
Merged via the queue into branch/v14 with commit 1520ba6 Feb 13, 2025
@r0mant r0mant deleted the eriktate/v14/tshenvfix branch February 13, 2025 18:57
@camscale camscale mentioned this pull request Feb 13, 2025
trublast pushed a commit to trublast/teleport-oidc that referenced this pull request Dec 26, 2025
…ravitational#52139)

instead of root

Co-authored-by: Erik Tate <erik.tate@goteleport.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants