Skip to content

Conversation

@cleemullins
Copy link
Contributor

@cleemullins cleemullins commented Dec 16, 2025

#minor

Potential fix for https://github.com/microsoft/botbuilder-dotnet/security/code-scanning/4

The fix is to ensure that any file path derived from the archive is not able to escape the intended extraction directory. The standard mitigation is to combine the extraction root (path) with the archive entry’s file name (as currently), then resolve this combined path to an absolute path (resolving traversals/links), and confirm it is still within the extraction root (also resolved to a canonical absolute path). If not, extraction should immediately abort with an exception. This must be done both for files and directory creation.

Specifically, in ExtractZipFolder:

  • After calculating the destination path with Path.Combine(path, entryName), use Path.GetFullPath on it.
  • Also get the full path of the extraction root, with a path separator at the end.
  • Before extracting (either directory creation or file extraction), check that the target path starts with the extraction root’s full path.
  • Throw an exception if any entry does not meet this.

This change needs to be applied to both branches: directory creation (line 167) and file extraction (line 171).

No additional dependencies are needed, but care needs to be taken to only change the vulnerable region.


Suggested fixes powered by Copilot Autofix. Review carefully before merging.

…ring archive extraction ("Zip Slip")

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@cleemullins cleemullins marked this pull request as ready for review December 16, 2025 17:43
@tracyboehrer tracyboehrer merged commit ee3cb4d into main Dec 16, 2025
6 of 7 checks passed
@tracyboehrer tracyboehrer deleted the alert-autofix-4 branch December 16, 2025 18:02
Copilot AI pushed a commit to rido-min/botbuilder-dotnet that referenced this pull request Dec 17, 2025
…ring archive extraction ("Zip Slip") (microsoft#6909)

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
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