rustdesk icon indicating copy to clipboard operation
rustdesk copied to clipboard

Terminal (beta) always runs as SYSTEM instead of the logged-in user when RustDesk is portable (service installed manually)

Open Thinker-Joe opened this issue 2 months ago • 0 comments

Bug description

When connecting to a Windows machine using the Terminal (beta) feature, the shell always runs as SYSTEM if the controlled RustDesk is running in portable mode (a manually installed service pointing to a non-default directory). On an installed (setup.exe) deployment, the terminal correctly runs as the currently logged-on console user. Portable users get no way to obtain a user-context terminal.

Environment

  • Controlled side: Windows 11 x64, RustDesk 1.4.9, portable exe + --service (service runs as LocalSystem), user logged on via console
  • Connecting side: RustDesk 1.4.9, Terminal (beta) tab

Steps to reproduce

  1. Run RustDesk portable from a custom folder (e.g. C:\Tools\rustdesk), install the service (rustdesk.exe --service).
  2. Log on to Windows with a normal user session.
  3. From another machine, open Terminal (beta) to this machine.
  4. Run whoami → returns the machine account (NT AUTHORITY\SYSTEM), not the logged-on user. Working directory is C:\Windows\System32\config\systemprofile.

Root cause (1.4.9 source)

  1. src/client.rs (handle_login_process, ~line 3580): terminal connections always send empty OS credentials:
let is_terminal = lc.read().unwrap().conn_type.eq(&ConnType::TERMINAL);
let (os_username, os_password) = if is_terminal {
    ("".to_owned(), "".to_owned()) // terminal: always empty
}
  1. src/server/connection.rs (fill_terminal_user_token, ~line 3688): with empty username, the user token of the active console session is only used when crate::platform::is_installed() is true; otherwise it falls back to TerminalUserToken::SelfUser (the SYSTEM service). Portable deployments can never reach the handle_installed_user() path.

Additional limitation: inside the SYSTEM terminal, runas fails with "Access is denied" because CreateProcessWithLogonW cannot be called from a service/session-0 context, so there is no user-level workaround inside the terminal either.

Expected behavior

Terminal sessions should run as the currently logged-on console user on portable deployments as well (i.e., drop or relax the is_installed() gate in fill_terminal_user_token, or expose an OS-login / "run as user" option in the Terminal client UI).

Suggested fix

Either reuse handle_installed_user() (token of the active console session) regardless of install mode, or allow the client to pass os_login credentials for terminal connections (currently hardcoded to empty in src/client.rs).

Thinker-Joe avatar Sep 04 '26 08:09 Thinker-Joe