fix(agent): authenticate and select the WTS session by SID - #1871
Conversation
…ay name Previously the package broker matched the pipe client identity against the request effective_user by comparing DOMAIN\name strings, and an unqualified effective_user ignored the domain entirely. On a host with both MACHINE\alice and DOMAIN\alice, the broker could run the operation in the wrong user's session. The caller SID is now captured at connect, threaded through ExecutionContext, and both authentication and WTS session selection compare SIDs instead of name strings. Issue: DGW-418 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
|
Implementation notes:
Addresses #1847 (comment) |
Let maintainers know that an action is required on their side
|
There was a problem hiding this comment.
Pull request overview
Updates the Windows package broker to consistently authenticate and select user sessions by SID.
Changes:
- Validates
effective_useragainst the pipe client SID. - Selects active WTS sessions by token SID.
- Propagates the authenticated SID into execution contexts.
Reviewed changes
Copilot reviewed 6 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
devolutions-agent/src/broker/server/mod.rs |
Passes authenticated SIDs into executions. |
devolutions-agent/src/broker/executor/windows/token.rs |
Matches sessions by token SID. |
devolutions-agent/src/broker/executor/windows/mod.rs |
Uses the matched session token. |
devolutions-agent/src/broker/executor/mod.rs |
Adds SID to execution context and logging. |
devolutions-agent/src/broker/auth.rs |
Implements SID-based validation and tests. |
devolutions-agent/Cargo.toml |
Adds widestring dependency. |
Cargo.lock |
Locks the new direct dependency. |
Comments suppressed due to low confidence (2)
devolutions-agent/src/broker/auth.rs:226
- The unqualified
SYSTEMdisplay name is localized as well, so this assertion is host-language dependent. Obtain the localized name from the well-known SID first; that preserves the intended unqualified-name coverage on every Windows locale.
fn resolve_account_sid_resolves_unqualified_name() {
let sid = resolve_account_sid("SYSTEM").expect("SYSTEM account should resolve");
devolutions-agent/src/broker/auth.rs:243
Everyoneis an English localized display name, so on localized Windows this lookup fails rather than testing the intended different-SID comparison. Build the world SID and use its host-localized account name instead.
fn validate_effective_user_rejects_different_account() {
// "Everyone" resolves to a different SID than the SYSTEM caller.
assert!(system_client().validate_effective_user("Everyone").is_err());
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| fn resolve_account_sid_resolves_qualified_name() { | ||
| let sid = resolve_account_sid("NT AUTHORITY\\SYSTEM").expect("SYSTEM account should resolve"); |
There was a problem hiding this comment.
Fixed in 733cbf0: the tests now resolve the well-known SIDs (LocalSystem, World) back to the host-localized qualified names via LookupAccountSidW before exercising the name-to-SID path, so they no longer depend on English display names.
Broker auth tests hard-coded English display names (NT AUTHORITY\SYSTEM, Everyone), which fail on non-English Windows installations. Resolve the well-known SIDs back to the host-localized names before exercising the name-to-SID path. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
48f9b0c
into
master
The package broker matched the pipe client identity against the request's
effective_userby comparingDOMAIN\namestrings, and an unqualified name ("alice") ignored the domain entirely. On a host with bothMACHINE\aliceandDOMAIN\alice, the authenticated caller and the session the operation was launched into could differ, allowing the broker to run the operation in the wrong user's session.The broker now captures the caller's SID at connect and uses it as the single source of truth for identity: the request's
effective_useris resolved to a SID and compared against the caller SID, and the target WTS session is selected by matching the session token's user SID instead of user/domain name strings. Two accounts sharing a display name can no longer be confused.Issue: DGW-418