Skip to content

fix(agent): compare broker client executables by file identity - #1869

Merged
Benoît Cortier (CBenoit) merged 1 commit into
masterfrom
vnikonov-devolutions-dgw-419-file-id-identity-check
Jul 27, 2026
Merged

fix(agent): compare broker client executables by file identity#1869
Benoît Cortier (CBenoit) merged 1 commit into
masterfrom
vnikonov-devolutions-dgw-419-file-id-identity-check

Conversation

@vnikonov-devolutions

Copy link
Copy Markdown
Contributor

The package broker authenticated pipe clients by comparing executable path strings using a lossy, ASCII-case-insensitive comparison. This was fragile for a security-relevant identity check, as it could be tripped up by Unicode casing rules, invalid UTF-8, and other path representation edge cases.

The broker now opens both executables and compares their file identity directly (volume serial number + 128-bit file ID via GetFileInformationByHandleEx/FILE_ID_INFO), which is immune to these edge cases.

Issue: DGW-419

Replaces the lossy, case-insensitive path string comparison used to
authenticate package broker pipe clients with a direct file identity
check based on GetFileInformationByHandleEx (FILE_ID_INFO), which is
immune to Unicode casing and invalid UTF-8 edge cases. Also removes
the redundant canonicalize helper.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings July 27, 2026 13:35
@github-actions

Copy link
Copy Markdown

Let maintainers know that an action is required on their side

  • Add the label release-required Please cut a new release (Devolutions Gateway, Devolutions Agent, Jetsocat, PowerShell module) when you request a maintainer to cut a new release (Devolutions Gateway, Devolutions Agent, Jetsocat, PowerShell module)

  • Add the label release-blocker Follow-up is required before cutting a new release if a follow-up is required before cutting a new release

  • Add the label publish-required Please publish libraries (`Devolutions.Gateway.Utils`, OpenAPI clients, etc) when you request a maintainer to publish libraries (Devolutions.Gateway.Utils, OpenAPI clients, etc.)

  • Add the label publish-blocker Follow-up is required before publishing libraries if a follow-up is required before publishing libraries

@vnikonov-devolutions

Copy link
Copy Markdown
Contributor Author

Implementation notes:

  • Replaces the canonicalize + to_string_lossy().eq_ignore_ascii_case() path comparison with a handle-based identity check, addressing feat(agent): implement package broker #1847 (comment) and feat(agent): implement package broker #1847 (comment).
  • file_id() opens the file with FILE_READ_ATTRIBUTES access and full sharing, then queries FileIdInfo via GetFileInformationByHandleEx. Identity = volume serial number + 128-bit file ID, robust against Unicode casing, invalid UTF-8, 8.3 short names, symlinks/junctions, and subst drives.
  • The redundant canonicalize_for_comparison helper and same_windows_path are removed.
  • Tests: two new unit tests verify that different path spellings of the same file (casing, redundant . component) yield the same identity, and that distinct files yield different identities.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Replaces fragile executable path-string comparison with Windows file identity checks for broker client authentication.

Changes:

  • Compares volume serial numbers and 128-bit file IDs.
  • Adds tests for equivalent paths and distinct files.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@CBenoit Benoît Cortier (CBenoit) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@CBenoit
Benoît Cortier (CBenoit) merged commit 5b0844d into master Jul 27, 2026
45 checks passed
@CBenoit
Benoît Cortier (CBenoit) deleted the vnikonov-devolutions-dgw-419-file-id-identity-check branch July 27, 2026 16:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

4 participants