mirror of
https://github.com/gnif/LookingGlass.git
synced 2026-08-22 15:11:31 +00:00
[idd] helper: run interactive process as desktop user
Explorer file copies were invisible to the Helper because the service launched its child with a duplicate of the LocalSystem token and changed only TokenSessionId. The child therefore remained a System-integrity process. Windows filtered Explorer's file clipboard formats across that integrity boundary. Basic text and bitmap formats continued to work. Keep only the SCM service privileged. Obtain the active session user's primary token with WTSQueryUserToken. For elevated accounts, prefer the linked limited token. Validate its session and security properties. Build the user environment and launch the interactive Helper on WinSta0\Default. Gate Helper activation until the service has rechecked the active session and registered the clipboard authority. Use random lifetime, stop, and activation objects owned by the service. Give the target logon SID synchronization access only. Recheck the active console session and service state before activation. Make the lifetime mutex terminate the Helper if the service exits unexpectedly. Restart it when the active session, IDD host, or authority changes. Replace the old process-handle mapping transfer with a device-bound authority protocol on the LGIdd device interface. The service verifies the exact driver host instance, duplicates only section map rights into that process, and registers the session, mapping identifier, and handle. Bind authority lifetime to its WDF file object, revoke it synchronously on cleanup, and poll the driver host identity while the child is active. Restrict the device stack to SYSTEM and isolate LGIdd in a unique UMDF device group. Restrict the shared section to SYSTEM and the target logon SID. Apply a medium mandatory label that prevents low-integrity readers and writers. Map it with read/write rights instead of all access. Give each clipboard mapping a second random authority identifier. Store it only inside the logon-SID-protected mapping and send it in the mandatory HELLO. LGIdd matches it against the service-injected mapping. This authenticates the user Helper without the unsupported UMDF call to GetNamedPipeClientSessionId. Have the Helper verify that its pipe server is in session zero. Extend the pipe endpoint with bounded authentication reads, cancellable overlapped I/O, periodic authorization checks, and explicit disconnects. Serialize authority changes with clipboard attach and detach. Prevent stale cleanup from tearing down a replacement mapping. Disconnect the user pipe immediately when its owning authority is revoked. Run clipboard, OLE, display, configuration, and file access in the user's interactive process. Retain its process token for worker-thread file operations instead of querying and impersonating the desktop user from a System process. Store Helper logs in LocalAppData and grant only the registry rights needed by interactive configuration and UMDF. Keep immediate, stage-specific Win32 and HRESULT diagnostics throughout clipboard capture. Probe CF_HDROP while holding the Win32 clipboard and enumerate the OLE object's advertised file formats. Validate returned storage and fall back to Shell item paths when direct retrieval fails. Validate clipboard sequence changes and defer retries during contention without publishing incomplete clipboard state. Complete the 1 MiB transfer work with full-sized Windows copy buffers. Use full-sized FUSE reads and retain the named 64 KiB X11 chunk limit. Validate the user-writable mapping with CClipboardRing before attaching. The pipe, mapping, and authority protocols change together. LGIdd.dll, the INF, and LGIddHelper.exe must be rebuilt and installed as one matching set.
This commit is contained in:
@@ -36,6 +36,36 @@ public:
|
||||
virtual void OnPipeConnected() {}
|
||||
virtual void OnPipeDisconnected() {}
|
||||
virtual bool ShouldReconnect() { return true; }
|
||||
virtual bool PipeServerIsAuthorized(_In_ HANDLE pipe)
|
||||
{
|
||||
(void) pipe;
|
||||
return true;
|
||||
}
|
||||
virtual bool PipeClientHelloRequired() const { return false; }
|
||||
virtual bool BuildPipeClientHello(
|
||||
_Out_writes_bytes_(size) void * message,
|
||||
_In_ size_t size)
|
||||
{
|
||||
(void) message;
|
||||
(void) size;
|
||||
return true;
|
||||
}
|
||||
virtual bool PipeClientAuthenticationRequired() const { return false; }
|
||||
virtual bool AuthenticatePipeClient(
|
||||
_In_ HANDLE pipe,
|
||||
_In_reads_bytes_(size) const void * message,
|
||||
_In_ size_t size)
|
||||
{
|
||||
(void) pipe;
|
||||
(void) message;
|
||||
(void) size;
|
||||
return true;
|
||||
}
|
||||
virtual bool PipeClientStillAuthorized(_In_ HANDLE pipe)
|
||||
{
|
||||
(void) pipe;
|
||||
return true;
|
||||
}
|
||||
virtual bool OnPipeMessage(
|
||||
_In_reads_bytes_(size) const void * message,
|
||||
_In_ size_t size) = 0;
|
||||
@@ -59,8 +89,12 @@ public:
|
||||
bool Start(
|
||||
_In_z_ const wchar_t * pipeName,
|
||||
_In_ Mode mode,
|
||||
_In_ size_t messageSize);
|
||||
_In_ size_t messageSize,
|
||||
_In_opt_ const SECURITY_ATTRIBUTES * serverSecurity = nullptr,
|
||||
_In_ DWORD serverOpenMode = 0,
|
||||
_In_ DWORD serverPipeMode = 0);
|
||||
void Stop();
|
||||
void DisconnectClient();
|
||||
|
||||
bool Send(
|
||||
_In_reads_bytes_(size) const void * message,
|
||||
@@ -82,12 +116,15 @@ private:
|
||||
Success,
|
||||
Disconnected,
|
||||
Stopped,
|
||||
TimedOut,
|
||||
Error,
|
||||
};
|
||||
|
||||
static const DWORD CLIENT_RETRY_INITIAL_MS;
|
||||
static const DWORD CLIENT_RETRY_MAX_MS;
|
||||
static const DWORD SERVER_RETRY_MS;
|
||||
static const DWORD AUTHENTICATION_TIMEOUT_MS;
|
||||
static const DWORD AUTHORIZATION_POLL_MS;
|
||||
static const DWORD WRITE_TIMEOUT_MS;
|
||||
static const DWORD WAIT_FIRST_OBJECT_VALUE;
|
||||
|
||||
@@ -103,7 +140,8 @@ private:
|
||||
_In_ HANDLE ioEvent,
|
||||
_Out_writes_bytes_(messageSize) void * message,
|
||||
_In_ DWORD messageSize,
|
||||
_Out_ DWORD * bytesRead);
|
||||
_Out_ DWORD * bytesRead,
|
||||
_In_ DWORD timeoutMs = INFINITE);
|
||||
PipeIoResult WriteMessage(
|
||||
_In_ HANDLE pipe,
|
||||
_In_reads_bytes_(messageSize) const void * message,
|
||||
@@ -120,10 +158,14 @@ private:
|
||||
void PublishPipe(_In_ HANDLE pipe);
|
||||
void ClosePipe(_In_ HANDLE pipe);
|
||||
|
||||
std::wstring m_pipeName;
|
||||
size_t m_messageSize = 0;
|
||||
Mode m_mode = Mode::Client;
|
||||
IPipeEndpointHandler * m_handler = nullptr;
|
||||
std::wstring m_pipeName;
|
||||
size_t m_messageSize = 0;
|
||||
Mode m_mode = Mode::Client;
|
||||
IPipeEndpointHandler * m_handler = nullptr;
|
||||
SECURITY_ATTRIBUTES m_serverSecurity = {};
|
||||
bool m_hasServerSecurity = false;
|
||||
DWORD m_serverOpenMode = 0;
|
||||
DWORD m_serverPipeMode = 0;
|
||||
|
||||
std::atomic<bool> m_running { false };
|
||||
std::atomic<bool> m_connected { false };
|
||||
|
||||
Reference in New Issue
Block a user