Skip to content

Fix file permissions check - #833

Merged
Tess Gauthier (tgauth) merged 8 commits into
PowerShell:latestw_allfrom
tgauth:fix-file-perm-check
May 11, 2026
Merged

Tess Gauthier (tgauth) merged 8 commits into
PowerShell:latestw_allfrom
tgauth:fix-file-perm-check

Conversation

@tgauth

@tgauth Tess Gauthier (tgauth) commented Apr 13, 2026 •

Copy link
Copy Markdown
Collaborator

PR Summary

  • expand file & folder permissions checks to include WRITE_DAC, WRITE_OWNER, and DELETE
  • refactor code to use macro instead of duplicating definition of expected permissions
  • add corresponding Pester tests

Copilot AI review requested due to automatic review settings April 13, 2026 16:11
@tgauth

Copy link
Copy Markdown
Collaborator Author

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR tightens Windows OpenSSH file/folder permission validation by treating WRITE_DAC, WRITE_OWNER, and DELETE as unsafe “write-like” rights, and adds regression coverage to ensure the new checks behave as expected.

Changes:

  • Expand Windows secure permission checks to flag WRITE_DAC, WRITE_OWNER, and DELETE on files/folders.
  • Add Pester negative tests for private keys, host keys, and authorized_keys when another account has those rights.
  • Add Setup test coverage to confirm sshd logs an Operational warning (but still starts) when the ProgramData\ssh folder grants those rights.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
regress/pesterTests/Userkey_fileperm.Tests.ps1 Adds negative ssh private-key tests for ChangePermissions/TakeOwnership/Delete.
regress/pesterTests/Setup.Tests.ps1 Adds Operational event-log warning tests for insecure ssh folder rights.
regress/pesterTests/Hostkey_fileperm.Tests.ps1 Adds negative sshd host-key tests for ChangePermissions/TakeOwnership/Delete.
regress/pesterTests/Authorized_keys_fileperm.Tests.ps1 Adds negative authorized_keys tests for ChangePermissions/TakeOwnership/Delete.
contrib/win32/win32compat/w32-sshfileperm.c Extends “write-like” access mask checks to include WRITE_DAC/WRITE_OWNER/DELETE.

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

Comment thread regress/pesterTests/Setup.Tests.ps1 Resolved
@tgauth

Copy link
Copy Markdown
Collaborator Author

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
1 pipeline(s) require an authorized user to comment /azp run to run.

@tgauth Tess Gauthier (tgauth) changed the title Fix file perm check Fix file permissions check Apr 15, 2026
@tgauth

Copy link
Copy Markdown
Collaborator Author

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
1 pipeline(s) require an authorized user to comment /azp run to run.

@tgauth

Tess Gauthier (tgauth) commented Apr 15, 2026 •

Copy link
Copy Markdown
Collaborator Author

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@tgauth

Copy link
Copy Markdown
Collaborator Author

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@tgauth

Copy link
Copy Markdown
Collaborator Author

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@tgauth
Tess Gauthier (tgauth) merged commit b91ebb3 into PowerShell:latestw_all May 11, 2026
7 checks passed
@tgauth
Tess Gauthier (tgauth) deleted the fix-file-perm-check branch May 11, 2026 19:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

⌂ 换网址