Skip to content

[Bug]: SFTP file operations do not use the requested SSH user #1755

Closed

Description

@DarkGhostHunter

Before submitting

  • I have searched existing issues to confirm this is not a duplicate
  • I am running the latest version of Devsy

What happened?

Devsy’s SSH server provides an SFTP subsystem, but the SFTP handler uses the SSH session username only to select the starting home directory. Unlike SSH command execution, it does not switch the SFTP server process to that user. Consequently, SFTP file operations run with the Devsy agent process’s OS permissions rather than the requested user’s permissions. For example, connecting as vscode@<workspace>.devsy does not make SFTP operations run as vscode, but root.

This means, trying to connect a remote container, an agent may upload a file via SFTP and proceed to lock itself due to not owning it.

What did you expect to happen instead?

SFTP file operations should run with the OS identity associated with the requested SSH username (for example, vscode), or Devsy should clearly document the limitation and provide a supported way to select the effective SFTP user. They should not unexpectedly inherit the agent process identity.

Steps to reproduce

  1. Start a Devsy workspace with an OS user such as vscode.
  2. Connect to the workspace’s SSH server using SFTP with that username (for example, sftp vscode@<workspace>.devsy).
  3. Try to list, read, or write files whose permissions differ between vscode and the user running the Devsy agent.
  4. Observe that SFTP access follows the agent process’s permissions rather than the requested session user’s permissions.

devcontainer.json

Error output / logs

How often does this happen?

Every time

Operating system

Linux

Linux distribution (if applicable)

No response

Architecture

AMD64

Desktop app or CLI?

Both

Devsy version

v1.26.0

Devsy provider

Docker

Provider version

No response

Screenshots

No response

Anything else?

The SFTP handler is implemented in pkg/ssh/server/sftp_handler.go. It reads sess.User() to determine the home directory, but does not apply the user-identity switching performed by SSH command execution. This may lead to surprising permission behavior when the agent runs as root or as another account.

Activity

  1. linked a pull request that will close this issuefix(ssh): run SFTP as requested user #1756on Nov 5, 2026
  2. skevetter commented on Nov 5, 2026

    @skevetter
    Contributor

    completed in linked PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions