Skip to content

Fixing command injection vulnerability in file permission handling#29350

Merged
VeryEarly merged 1 commit intoAzure:mainfrom
DevanshG1:personal/degoswami/bugfix
Apr 8, 2026
Merged

Fixing command injection vulnerability in file permission handling#29350
VeryEarly merged 1 commit intoAzure:mainfrom
DevanshG1:personal/degoswami/bugfix

Conversation

@DevanshG1
Copy link
Copy Markdown
Contributor

@DevanshG1 DevanshG1 commented Mar 31, 2026

Description

Mandatory Checklist

  • SHOULD update ChangeLog.md file(s) appropriately
    • Update src/{{SERVICE}}/{{SERVICE}}/ChangeLog.md.
      • A snippet outlining the change(s) made in the PR should be written under the ## Upcoming Release header in the past tense.
    • Should not change ChangeLog.md if no new release is required, such as fixing test case only.
  • SHOULD regenerate markdown help files if there is cmdlet API change. Instruction
  • SHOULD have proper test coverage for changes in pull request.
  • SHOULD NOT adjust version of module manually in pull request

Copilot AI review requested due to automatic review settings March 31, 2026 06:51
@azure-client-tools-bot-prd
Copy link
Copy Markdown

Thanks for your contribution! The pull request validation has started. Please revisit this comment for updated status.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 hardens the Az.Sftp module against command/argument injection by tightening how user-provided values are validated/escaped when launching OpenSSH tools, and by removing external process calls from file-permission handling.

Changes:

  • Added command-line argument validation + centralized escaping for ProcessStartInfo.Arguments construction.
  • Replaced Windows/Unix permission-setting subprocesses (powershell.exe/icacls.exe/chmod) with direct ACL APIs and a native chmod P/Invoke.
  • Reduced public surface area of internal helper/model types and updated tests + changelog accordingly.

Reviewed changes

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

Show a summary per file
File Description
src/Sftp/Sftp/Sftp.csproj Adds AccessControl dependency needed for Windows ACL APIs.
src/Sftp/Sftp/Properties/AssemblyInfo.cs Adds assembly attributes + InternalsVisibleTo for test access.
src/Sftp/Sftp/Models/SFTPSession.cs Adds validation before building args; narrows API visibility to internal.
src/Sftp/Sftp/Models/SessionConfiguration.cs Narrows type visibility to internal.
src/Sftp/Sftp/Models/RuntimeState.cs Narrows type visibility to internal.
src/Sftp/Sftp/Models/ConnectionInfo.cs Narrows type visibility to internal.
src/Sftp/Sftp/Models/AuthenticationFIles.cs Narrows type visibility to internal.
src/Sftp/Sftp/Common/SftpUtils.cs Introduces validation + escaping helpers; uses them across process launches.
src/Sftp/Sftp/Common/SftpConstants.cs Narrows type visibility to internal.
src/Sftp/Sftp/Common/RSAParser.cs Narrows type visibility to internal.
src/Sftp/Sftp/Common/FileUtils.cs Replaces permission subprocesses with ACL API / native chmod; validates file paths.
src/Sftp/Sftp/CHANGELOG.md Documents the security fixes for upcoming release notes.
src/Sftp/Sftp.Test/ScenarioTests/SftpUtilsTests.cs Adds unit tests for new validation/escaping behavior.

Comment thread src/Sftp/Sftp/Common/SftpUtils.cs
Comment thread src/Sftp/Sftp.Test/ScenarioTests/SftpUtilsTests.cs
@VeryEarly VeryEarly self-assigned this Apr 1, 2026
@DevanshG1 DevanshG1 closed this Apr 6, 2026
@DevanshG1 DevanshG1 force-pushed the personal/degoswami/bugfix branch from 8fac27e to 7e45120 Compare April 6, 2026 04:52
@DevanshG1 DevanshG1 reopened this Apr 6, 2026
@DevanshG1
Copy link
Copy Markdown
Contributor Author

Hey @VeryEarly , please run the checks once

@VeryEarly
Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines
Copy link
Copy Markdown
Contributor

Azure Pipelines successfully started running 3 pipeline(s).

@VeryEarly VeryEarly merged commit 10bcc45 into Azure:main Apr 8, 2026
12 checks passed
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