Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(remote-desktop): support source-mode lock-screen setup
Lizid7e68d9b3776
diff --git a/apps/desktop/native/remote-desktop/windows-host/Cargo.toml b/apps/desktop/native/remote-desktop/windows-host/Cargo.tomlindex 99bf992b0f..13c9ac0ae8 100644--- a/apps/desktop/native/remote-desktop/windows-host/Cargo.toml+++ b/apps/desktop/native/remote-desktop/windows-host/Cargo.toml@@ -18,7 +18,7 @@ jpeg-encoder = "0.6"napi = { version = "2", features = ["napi6", "tokio_rt"] }napi-derive = "2"tokio = { version = "1", features = ["rt"] }-windows-sys = { version = "0.59", features = ["Win32_Foundation", "Win32_Security", "Win32_Security_Authentication_Identity", "Win32_Security_Authorization", "Win32_Storage_FileSystem", "Win32_System_IO", "Win32_System_Pipes", "Win32_System_Threading", "Win32_System_Services", "Win32_System_RemoteDesktop", "Win32_System_StationsAndDesktops", "Win32_System_Diagnostics_ToolHelp", "Win32_System_Memory", "Win32_System_Environment", "Win32_System_Com", "Win32_UI_Shell", "Win32_UI_WindowsAndMessaging", "Win32_UI_HiDpi", "Win32_Graphics_Gdi"] }+windows-sys = { version = "0.59", features = ["Win32_Foundation", "Win32_Security", "Win32_Security_Authentication_Identity", "Win32_Security_Authorization", "Win32_Storage_FileSystem", "Win32_System_IO", "Win32_System_Pipes", "Win32_System_Threading", "Win32_System_Services", "Win32_System_RemoteDesktop", "Win32_System_StationsAndDesktops", "Win32_System_Diagnostics_ToolHelp", "Win32_System_Memory", "Win32_System_Environment", "Win32_System_Com", "Win32_System_SystemInformation", "Win32_UI_Shell", "Win32_UI_WindowsAndMessaging", "Win32_UI_HiDpi", "Win32_Graphics_Gdi"] }[features]default = ["windows-sys/Win32_System_JobObjects", "windows-sys/Win32_System_Registry", "windows-sys/Win32_System_SystemServices", "windows-sys/Win32_UI_Input_KeyboardAndMouse"]diff --git a/apps/desktop/native/remote-desktop/windows-host/src/main.rs b/apps/desktop/native/remote-desktop/windows-host/src/main.rsindex 3c5d91dd28..b17894cf2e 100644--- a/apps/desktop/native/remote-desktop/windows-host/src/main.rs+++ b/apps/desktop/native/remote-desktop/windows-host/src/main.rs@@ -9,23 +9,35 @@ mod staging;mod win;use naming::Installation;use sha2::{Digest, Sha256};+use std::path::Path;use win::*;/// The service name used before the executable moved into a protected/// directory: a hash of this bundled helper's own path. Removal still looks/// for it, so a machine that enabled the feature under an older build is not/// left with a stale registration no one deletes.-fn legacy_service_name() -> Result<String> {- let path = std::env::current_exe()?- .canonicalize()?- .to_string_lossy()- .to_lowercase();+fn legacy_service_name_for(path: &Path) -> Result<String> {+ let path = path.canonicalize()?.to_string_lossy().to_lowercase();Ok(format!("CindyRemoteDesktop-{:x}", Sha256::digest(path.as_bytes()))[..35].to_string())}+fn legacy_service_name() -> Result<String> {+ legacy_service_name_for(&std::env::current_exe()?)+}+/// This executable's own installation, for the modes that run from inside one.fn bundled() -> Staged<Installation> {- Installation::of_bundled(&std::env::current_exe().stage(Step::ProtectedOpen)?)+ bundled_from(&std::env::current_exe().stage(Step::ProtectedOpen)?)+}++fn bundled_from(path: &Path) -> Staged<Installation> {+ if !path+ .file_name()+ .is_some_and(|name| name.eq_ignore_ascii_case(naming::HOST_EXE))+ {+ return refuse(Step::ProtectedOpen);+ }+ Installation::of_bundled(path)}fn run() -> Staged<()> {@@ -52,6 +64,37 @@ fn run() -> Staged<()> {service::install(&installation)?;service::authorize(&installation, pid)}+ Some("--install-from") if args.len() == 3 || args.len() == 4 => {+ let source = std::path::PathBuf::from(&args[1]);+ let pid = args[2]+ .parse::<u32>()+ .map_err(|_| Failure::new(Step::Args, 0))?;+ let development = args.get(3).is_some_and(|arg| arg == "--development");+ if args.len() == 4 && !development {+ return refuse(Step::Args);+ }+ let installation = if development {+ bundled_from(&source)?.for_development()+ } else {+ bundled_from(&source)?+ };+ // This process is the protected bootstrap. Stop the old service+ // before replacing its host and input binaries, then stage bytes+ // read from the user installation as data.+ service::uninstall(&installation.service())?;+ staging::stage_from(&installation, &source)?;+ service::install_staged(&installation)?;+ service::authorize(&installation, pid)+ }+ Some("--uninstall-from") if args.len() == 2 => {+ let source = std::path::PathBuf::from(&args[1]);+ let installation = bundled_from(&source)?;+ service::uninstall(&installation.service())?;+ if let Ok(legacy) = legacy_service_name_for(&source) {+ service::uninstall(&legacy)?;+ }+ Ok(())+ }Some("--uninstall") => {let installation = bundled()?;service::uninstall(&installation.service())?;@@ -75,14 +118,23 @@ fn run() -> Staged<()> {};let (_main, _) = security::authorize_client(pid, &installation.install, development).stage(Step::ClientIdentity)?;- let command = if development {- format!("--install {pid} --development")- } else {- format!("--install {pid}")- };- service::elevate(&command)+ service::elevate(+ &installation,+ &[+ "--install-from".to_owned(),+ pid.to_string(),+ if development {+ "--development".to_owned()+ } else {+ String::new()+ },+ ][..if development { 3 } else { 2 }],+ )+ }+ Some("--elevate-uninstall") => {+ let installation = bundled()?;+ service::elevate(&installation, &["--uninstall-from".to_owned()])}- Some("--elevate-uninstall") => service::elevate("--uninstall"),Some("--status") => {let status = match bundled() {Ok(installation) if service::pid(&installation.service()).is_ok() => {diff --git a/apps/desktop/native/remote-desktop/windows-host/src/naming.rs b/apps/desktop/native/remote-desktop/windows-host/src/naming.rsindex 1b4fc04335..4b2d2bc9d6 100644--- a/apps/desktop/native/remote-desktop/windows-host/src/naming.rs+++ b/apps/desktop/native/remote-desktop/windows-host/src/naming.rs@@ -16,6 +16,9 @@ use windows_sys::Win32::{System::Com::CoTaskMemFree, UI::Shell::*};pub const HOST_EXE: &str = "cindy-windows-desktop-host.exe";pub const INPUT_EXE: &str = "cindy-windows-desktop-input.exe";+/// A copy used only as the elevated setup bootstrap. It is never registered+/// as the service image and is removed with the staging directory.+pub const BOOTSTRAP_EXE: &str = "cindy-windows-desktop-bootstrap.exe";/// Records which installation this staged copy serves. It lives in the/// protected directory, so the service reads an administrator-written value/// rather than trusting a path handed to it over the pipe.@@ -116,6 +119,9 @@ impl Installation {pub fn host(&self) -> PathBuf {self.staged.join(HOST_EXE)}+ pub fn bootstrap(&self) -> PathBuf {+ self.staged.join(BOOTSTRAP_EXE)+ }}/// What the staged copy can work out about itself from its own location,diff --git a/apps/desktop/native/remote-desktop/windows-host/src/service.rs b/apps/desktop/native/remote-desktop/windows-host/src/service.rsindex c115e4fd83..8ab1b8516d 100644--- a/apps/desktop/native/remote-desktop/windows-host/src/service.rs+++ b/apps/desktop/native/remote-desktop/windows-host/src/service.rs@@ -1,5 +1,7 @@use crate::naming::{InstallRecord, Installation, StagedCopy};use crate::{pipe::Pipe, win::*};+use base64::Engine;+use sha2::{Digest, Sha256};use std::{io::{self, BufRead, Write},mem, ptr,@@ -81,6 +83,18 @@ pub fn pid(name: &str) -> Result<u32> {/// copy rather than the executable inside the installation.pub fn install(installation: &Installation) -> Staged<()> {let staged = crate::staging::stage(installation)?;+ install_registered(installation, staged)+}++/// Registers files that were staged by the protected setup bootstrap. The+/// bootstrap is a separate file, so this path never tries to overwrite the+/// executable that is currently running.+pub fn install_staged(installation: &Installation) -> Staged<()> {+ let _handles = crate::security::protected_staging(&installation.staged)?;+ install_registered(installation, installation.host())+}++fn install_registered(installation: &Installation, staged: std::path::PathBuf) -> Staged<()> {let manager = manager(SC_MANAGER_CREATE_SERVICE | SC_MANAGER_CONNECT).stage(Step::ScmOpen)?;let name = wide(&installation.service());let command = wide(&format!("\"{}\" --service", staged.display()));@@ -186,8 +200,7 @@ pub fn uninstall(name: &str) -> Staged<()> {&& process_status.dwCurrentState != SERVICE_STOPPED&& process_status.dwProcessId != 0{- let raw = unsafe { OpenProcess(SYNCHRONIZE, 0, process_status.dwProcessId) };- Some(Handle::new(raw).stage(Step::ServiceStop)?)+ Some(process(process_status.dwProcessId).stage(Step::ServiceStop)?)} else {None}@@ -228,21 +241,94 @@ pub fn uninstall(name: &str) -> Staged<()> {fn last_error() -> i32 {unsafe { GetLastError() as i32 }}-/// Relaunches this executable elevated, to run one setup command.-///-/// There is deliberately no check on where this executable lives: Cindy-/// installs per user by default, so it normally sits in a directory the-/// current user can write. What the elevated child does with that is the-/// subject of `staging` — it copies the helpers somewhere only administrators-/// can write before registering anything as SYSTEM.-pub fn elevate(command: &str) -> Staged<()> {- let executable = wide(- &std::env::current_exe()- .stage(Step::ElevateLaunch)?- .to_string_lossy(),+/// Quotes a value for a single-quoted PowerShell literal. The complete script+/// is passed as UTF-16LE base64, so installation paths never become shell code.+fn powershell_literal(value: &str) -> String {+ format!("'{}'", value.replace('\'', "''"))+}++fn powershell_script(+ source: &std::path::Path,+ bootstrap: &std::path::Path,+ source_hash: &str,+ child_args: &[String],+ remove_staging: bool,+) -> String {+ let args = child_args.to_vec();+ let source_expr = "('\"' + $source + '\"')";+ let args = args+ .iter()+ .enumerate()+ .map(|(index, value)| {+ if index == 1 {+ source_expr.to_owned()+ } else {+ powershell_literal(value)+ }+ })+ .collect::<Vec<_>>()+ .join(",");+ let mut script = String::from("$ErrorActionPreference='Stop'; $source=");+ script.push_str(&powershell_literal(&source.to_string_lossy()));+ script.push_str("; $bootstrap=");+ script.push_str(&powershell_literal(&bootstrap.to_string_lossy()));+ script.push_str("; $expectedHash=");+ script.push_str(&powershell_literal(source_hash));+ script.push_str("; $bootstrapDir=Split-Path -Parent $bootstrap; $stagingRoot=Split-Path -Parent $bootstrapDir; $programFiles=Split-Path -Parent $stagingRoot;");+ script.push_str(" $trusted=@('S-1-5-18','S-1-5-32-544','S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464');");+ script.push_str(" $writeMask=[System.Security.AccessControl.FileSystemRights]::Write -bor [System.Security.AccessControl.FileSystemRights]::WriteData -bor [System.Security.AccessControl.FileSystemRights]::AppendData -bor [System.Security.AccessControl.FileSystemRights]::WriteAttributes -bor [System.Security.AccessControl.FileSystemRights]::WriteExtendedAttributes -bor [System.Security.AccessControl.FileSystemRights]::Delete -bor [System.Security.AccessControl.FileSystemRights]::DeleteSubdirectoriesAndFiles -bor [System.Security.AccessControl.FileSystemRights]::ChangePermissions -bor [System.Security.AccessControl.FileSystemRights]::TakeOwnership;");+ script.push_str(" function Test-Protected([string]$Path) { $item=Get-Item -LiteralPath $Path -Force -ErrorAction Stop; if (($item.Attributes -band [System.IO.FileAttributes]::ReparsePoint) -ne 0) { return $false }; $acl=$item.GetAccessControl(); if ($trusted -notcontains $acl.GetOwner([System.Security.Principal.SecurityIdentifier]).Value) { return $false }; foreach ($rule in $acl.Access) { if ($rule.AccessControlType -ne 'Allow') { continue }; $sid=$rule.IdentityReference.Translate([System.Security.Principal.SecurityIdentifier]).Value; if (($trusted -notcontains $sid) -and (($rule.FileSystemRights -band $writeMask) -ne 0)) { return $false } }; return $true };");+ script.push_str(" if (-not (Test-Path -LiteralPath $programFiles) -or -not (Test-Protected $programFiles)) { exit 1 };");+ script.push_str(" foreach ($dir in @($stagingRoot,$bootstrapDir)) { if (Test-Path -LiteralPath $dir) { if (-not (Test-Protected $dir)) { exit 1 } } else { New-Item -ItemType Directory -Path $dir -Force | Out-Null }; $security=New-Object System.Security.AccessControl.DirectorySecurity; $security.SetSecurityDescriptorSddlForm('O:BAG:BAD:P(A;OICI;FA;;;SY)(A;OICI;FA;;;BA)(A;OICI;0x1200a9;;;BU)'); Set-Acl -LiteralPath $dir -AclObject $security; if (-not (Test-Protected $dir)) { exit 1 } };");+ script.push_str(" if ((Get-FileHash -LiteralPath $source -Algorithm SHA256).Hash.ToLowerInvariant() -ne $expectedHash) { exit 1 }; Copy-Item -LiteralPath $source -Destination $bootstrap -Force; if (-not (Test-Protected $bootstrap)) { exit 1 }; if ((Get-FileHash -LiteralPath $bootstrap -Algorithm SHA256).Hash.ToLowerInvariant() -ne $expectedHash) { exit 1 }; $child=Start-Process -FilePath $bootstrap -ArgumentList @(");+ script.push_str(&args);+ script.push_str(") -Wait -PassThru -WindowStyle Hidden;");+ if remove_staging {+ script.push_str(" if ($child.ExitCode -eq 0) { Remove-Item -LiteralPath $bootstrapDir -Recurse -Force -ErrorAction Stop };");+ }+ script.push_str(" exit $child.ExitCode");+ script+}++fn encode_powershell(script: &str) -> String {+ let bytes = script+ .encode_utf16()+ .flat_map(u16::to_le_bytes)+ .collect::<Vec<_>>();+ base64::engine::general_purpose::STANDARD.encode(bytes)+}++/// Uses the protected Windows PowerShell binary as the UAC bootstrap. The+/// user-writable helper is copied as data, then only the copy under Program+/// Files is started elevated, so an adjacent VCRUNTIME140.dll cannot be+/// loaded from Cindy's install directory.+pub fn elevate(installation: &Installation, child_args: &[String]) -> Staged<()> {+ let source = std::env::current_exe().stage(Step::ElevateLaunch)?;+ let _source_lock = read_lock(&source).stage(Step::ElevateLaunch)?;+ let _input_lock =+ read_lock(&source.with_file_name(crate::naming::INPUT_EXE)).stage(Step::ElevateLaunch)?;+ let source_hash = Sha256::digest(std::fs::read(&source).stage(Step::ElevateLaunch)?);+ let source_hash = format!("{source_hash:x}");+ let mut child_args = child_args.to_vec();+ child_args.insert(1, source.to_string_lossy().into_owned());+ let remove_staging = child_args+ .first()+ .is_some_and(|arg| arg == "--uninstall-from");+ let script = powershell_script(+ &source,+ &installation.bootstrap(),+ &source_hash,+ &child_args,+ remove_staging,);+ let powershell_path =+ system_file("WindowsPowerShell\\v1.0\\powershell.exe").stage(Step::ElevateLaunch)?;+ let executable = wide(&powershell_path.to_string_lossy());+ let parameters = wide(&format!(+ "-NoLogo -NoProfile -NonInteractive -ExecutionPolicy Bypass -EncodedCommand {}",+ encode_powershell(&script)+ ));let verb = wide("runas");- let parameters = wide(command);let mut info: SHELLEXECUTEINFOW = unsafe { mem::zeroed() };info.cbSize = mem::size_of_val(&info) as u32;info.fMask = SEE_MASK_NOCLOSEPROCESS;@@ -859,3 +945,50 @@ fn send_sas(owner: &Handle) -> Result<()> {}Ok(())}++#[cfg(test)]+mod tests {+ use super::*;+ use std::{path::Path, process::Command};++ /// The UAC bootstrap is security-sensitive generated PowerShell. Parse the+ /// exact production script through the system PowerShell parser so quoting+ /// or a syntax regression cannot turn setup into an opaque retry.+ #[test]+ fn elevated_bootstrap_script_parses() {+ let args = vec![+ "--install-from".to_owned(),+ r"C:\Users\dev user\resources\tools\remote-desktop\cindy-windows-desktop-host.exe"+ .to_owned(),+ "1234".to_owned(),+ "--development".to_owned(),+ ];+ let script = powershell_script(+ Path::new(+ r"C:\Users\dev user\resources\tools\remote-desktop\cindy-windows-desktop-host.exe",+ ),+ Path::new(+ r"C:\Program Files\Cindy Remote Desktop\abc\cindy-windows-desktop-bootstrap.exe",+ ),+ "0123456789abcdef",+ &args,+ false,+ );+ let encoded = encode_powershell(&script);+ let command = format!(+ "[void][ScriptBlock]::Create([Text.Encoding]::Unicode.GetString([Convert]::FromBase64String('{}'))); exit 0",+ encoded+ );+ let powershell = system_file("WindowsPowerShell\\v1.0\\powershell.exe")+ .expect("System32 PowerShell is required on Windows");+ let output = Command::new(powershell)+ .args(["-NoProfile", "-NonInteractive", "-Command", &command])+ .output()+ .expect("PowerShell parser should start");+ assert!(+ output.status.success(),+ "generated bootstrap script did not parse: {}",+ String::from_utf8_lossy(&output.stderr)+ );+ }+}diff --git a/apps/desktop/native/remote-desktop/windows-host/src/staging.rs b/apps/desktop/native/remote-desktop/windows-host/src/staging.rsindex c2fe584a80..f1eb447439 100644--- a/apps/desktop/native/remote-desktop/windows-host/src/staging.rs+++ b/apps/desktop/native/remote-desktop/windows-host/src/staging.rs@@ -184,7 +184,14 @@ fn write_protected(path: &Path, bytes: &[u8], rights: &Descriptor) -> Staged<()>/// service already stopped so the files it uses can be replaced.pub fn stage(installation: &Installation) -> Staged<PathBuf> {let bundled = std::env::current_exe().stage(Step::StageRead)?;- let host = read_exclusively(&bundled)?;+ stage_from(installation, &bundled)+}++/// Stages an installation while running from the protected setup bootstrap.+/// The bootstrap itself is already in Program Files, so the helper from the+/// user-writable installation is treated strictly as input bytes.+pub fn stage_from(installation: &Installation, bundled: &Path) -> Staged<PathBuf> {+ let host = read_exclusively(bundled)?;let input = read_exclusively(&bundled.with_file_name(INPUT_EXE))?;let directory_rights = Descriptor::parse(DIRECTORY_RIGHTS)?;diff --git a/apps/desktop/native/remote-desktop/windows-host/src/win.rs b/apps/desktop/native/remote-desktop/windows-host/src/win.rsindex 6afc7b98d8..df0b9df03e 100644--- a/apps/desktop/native/remote-desktop/windows-host/src/win.rs+++ b/apps/desktop/native/remote-desktop/windows-host/src/win.rs@@ -3,9 +3,14 @@//! subset — the setup steps below belong to the executable — so items unused by//! one of them are expected here rather than dead.#![allow(dead_code)]-use std::{io, ptr};+use std::{+ io,+ path::{Path, PathBuf},+ ptr,+};+use windows_sys::Win32::System::SystemInformation::GetSystemDirectoryW;use windows_sys::Win32::{- Foundation::*, Security::*, Storage::FileSystem::SYNCHRONIZE, System::Threading::*,+ Foundation::*, Security::*, Storage::FileSystem::*, System::Threading::*,};pub type Result<T> = io::Result<T>;pub fn error() -> io::Error {@@ -15,6 +20,34 @@ pub fn denied<T>() -> Result<T> {Err(io::Error::from(io::ErrorKind::PermissionDenied))}+/// Resolves a Windows system binary without consulting the user's PATH.+/// Elevation must never launch a name that an ordinary process can shadow.+pub fn system_file(name: &str) -> Result<PathBuf> {+ let mut buffer = vec![0u16; 32_768];+ let length = unsafe { GetSystemDirectoryW(buffer.as_mut_ptr(), buffer.len() as u32) };+ if length == 0 || length as usize >= buffer.len() {+ return Err(error());+ }+ Ok(PathBuf::from(String::from_utf16_lossy(&buffer[..length as usize])).join(name))+}++/// Keeps a bundled helper and its input companion from being replaced while+/// the protected PowerShell bootstrap copies them. The handle is held by the+/// unelevated helper until the elevated child has finished.+pub fn read_lock(path: &Path) -> Result<Handle> {+ Handle::new(unsafe {+ CreateFileW(+ wide(&path.to_string_lossy()).as_ptr(),+ GENERIC_READ,+ FILE_SHARE_READ,+ ptr::null(),+ OPEN_EXISTING,+ FILE_ATTRIBUTE_NORMAL,+ ptr::null_mut(),+ )+ })+}+/// The elevated child is hidden, so its step and raw Win32 error have to cross/// the UAC process boundary in the one value Windows gives us: the exit code./// The low byte is the step (plus one); the remaining 24 bits carry the usualdiff --git a/apps/desktop/src/main/remote-desktop/__tests__/windowsLockScreenSetup.test.ts b/apps/desktop/src/main/remote-desktop/__tests__/windowsLockScreenSetup.test.tsindex a28c268e8f..9216e4e49f 100644--- a/apps/desktop/src/main/remote-desktop/__tests__/windowsLockScreenSetup.test.ts+++ b/apps/desktop/src/main/remote-desktop/__tests__/windowsLockScreenSetup.test.ts@@ -5,13 +5,20 @@// carry the helper's step code through, and that a helper which cannot work out// where it would install is not offered to the user as a setup they can finish.import { afterEach, describe, expect, it, vi } from 'vitest';+import os from 'node:os';+import path from 'node:path';const execFile = vi.hoisted(() => vi.fn());+const electronApp = vi.hoisted(() => ({+ isPackaged: true,+ getAppPath: vi.fn(),+ getPath: vi.fn(),+}));vi.mock('node:child_process', async (importOriginal) => ({...(await importOriginal<typeof import('node:child_process')>()),execFile,}));-vi.mock('electron', () => ({ app: { isPackaged: true } }));+vi.mock('electron', () => ({ app: electronApp }));vi.mock('../../logger', () => ({createLogger: () => ({trace: vi.fn(),@@ -44,6 +51,9 @@ function helperPrints(stdout: string, exitCode = 0): void {const platform = process.platform;afterEach(() => {+ electronApp.isPackaged = true;+ electronApp.getAppPath.mockReset();+ electronApp.getPath.mockReset();Object.defineProperty(process, 'platform', { value: platform });execFile.mockReset();});@@ -86,6 +96,17 @@ describe('windows lock-screen setup diagnostics', () => {expect(await readWindowsDesktopSupport()).toBe('missing');});+ it('does not compile source helpers during a status-only read', async () => {+ electronApp.isPackaged = false;+ electronApp.getAppPath.mockReturnValue(path.join(process.cwd(), 'apps', 'desktop'));+ electronApp.getPath.mockReturnValue(+ path.join(os.tmpdir(), `cindy-lock-screen-status-${process.pid}`),+ );++ expect(await readWindowsDesktopSupport()).toBe('missing');+ expect(execFile).not.toHaveBeenCalled();+ });+it('does not offer setup when the helper cannot locate an installation', async () => {// `installRequired` from the helper means it could not work out where it// would install at all. Reporting that as a pending setup would leave thediff --git a/docs/remote-desktop.md b/docs/remote-desktop.mdindex 5206bd0967..478ef28850 100644--- a/docs/remote-desktop.md+++ b/docs/remote-desktop.md@@ -1004,13 +1004,17 @@ Setup always stops the service, restages and restarts, so an upgraded Cindy doesnot keep running the previous version's copy. Removal deletes the service, thestaged directory, and a service registered under the pre-staging name.-What this does not cover: the elevated setup child itself is launched from the-installation directory, which the installing account can write. Anything able to-replace files there before the user confirms the prompt could have replaced that-child too, and a program checking its own signature proves nothing about itself.-This is the same exposure the Cindy updater already accepts when it elevates to-write into a protected directory. What staging removes is the standing risk: the-executable the service starts afterwards is out of reach.+The UAC transition does not launch the helper from that user-writable+directory. It starts the absolute-path Windows PowerShell binary from+`System32` with `-NoProfile -NonInteractive -EncodedCommand`; the script checks+the Program Files parent and staging directory for administrator/SYSTEM-only+ACLs and reparse points, copies the helper there, and starts only that protected+copy. The unelevated helper holds read-only handles on both bundled helpers+until the elevated copy and setup finish, so a same-user writer cannot swap the+bytes during the transition or inject an adjacent `VCRUNTIME140.dll`.++What staging removes is the standing risk: the executable the service starts+afterwards is out of reach of ordinary processes.Because Cindy's own uninstaller runs per user without administrator rights, itcannot delete the staged directory or the service registration. Removing them is@@ -1033,9 +1037,10 @@ Restarting Cindy or the service requires fresh administrator approval. This is apost-reboot support. No authorization secrets or screenshots are persisted.Registration is accepted only from an elevated process whose image has the same-contents as the running service's own image: the setup child runs from the-installation and the service from its protected copy, so their paths differ by-design and identical contents is what shows they are one build. Which+contents as the running service's own image: the setup bootstrap runs from the+protected staging directory and the service from its protected host copy, so+their paths differ by design and identical contents is what shows they are one+build. Whichinstallation may then drive the service comes from `install.txt` in theprotected directory — an administrator-written value rather than a path handedover the pipe — and it is accepted only if it hashes back to the directory's own