Skip to content

Conversation

@locus-x64
Copy link

@locus-x64 locus-x64 commented Sep 12, 2025

Add filter='data' parameter to all tar.extractall() calls to prevent directory traversal (zipslip) vulnerabilities. This change ensures that tar extraction operations reject any archive members that attempt to write outside the intended extraction directory.

Affected modules:

  • amg: restore operations from Grafana archive files
  • aosm: helm package extraction for AOSM definitions
  • confcom: container image tar file processing and manifest extraction
  • connectedk8s: Arc Connectivity proxy binary extraction
  • containerapp: Java buildpack source code extraction
  • networkcloud: custom action result blob extraction
  • ssh: SSH proxy binary extraction from MCR packages

The filter='data' parameter is available in Python 3.11.4+ and provides built-in protection against malicious tar archives containing entries with absolute paths or relative paths that traverse outside the extraction directory.

References:


This checklist is used to make sure that common guidelines for a pull request are followed.

Related command

General Guidelines

  • Have you run azdev style <YOUR_EXT> locally? (pip install azdev required)
  • Have you run python scripts/ci/test_index.py -q locally? (pip install wheel==0.30.0 required)
  • My extension version conforms to the Extension version schema

For new extensions:

About Extension Publish

There is a pipeline to automatically build, upload and publish extension wheels.
Once your pull request is merged into main branch, a new pull request will be created to update src/index.json automatically.
You only need to update the version information in file setup.py and historical information in file HISTORY.rst in your PR but do not modify src/index.json.

Add filter='data' parameter to all tar.extractall() calls to prevent
directory traversal (zipslip) vulnerabilities. This change ensures that
tar extraction operations reject any archive members that attempt to
write outside the intended extraction directory.

Affected modules:
- amg: restore operations from Grafana archive files
- aosm: helm package extraction for AOSM definitions
- confcom: container image tar file processing and manifest extraction
- connectedk8s: Arc Connectivity proxy binary extraction
- containerapp: Java buildpack source code extraction
- networkcloud: custom action result blob extraction
- ssh: SSH proxy binary extraction from MCR packages

The filter='data' parameter is available in Python 3.11.4+ and provides
built-in protection against malicious tar archives containing entries with
absolute paths or relative paths that traverse outside the extraction directory.

References:
- https://docs.python.org/3/library/tarfile.html#tarfile.TarFile.extractall
- https://cwe.mitre.org/data/definitions/23.html
Copilot AI review requested due to automatic review settings September 12, 2025 10:04
@locus-x64 locus-x64 requested a review from Juliehzl as a code owner September 12, 2025 10:04
@azure-client-tools-bot-prd
Copy link

Validation for Breaking Change Starting...

Thanks for your contribution!

@azure-client-tools-bot-prd
Copy link

Hi @locus-x64,
Please write the description of changes which can be perceived by customers into HISTORY.rst.
If you want to release a new extension version, please update the version in setup.py as well.

@yonzhan
Copy link
Collaborator

yonzhan commented Sep 12, 2025

Thank you for your contribution! We will review the pull request and get back to you soon.

@github-actions
Copy link

The git hooks are available for azure-cli and azure-cli-extensions repos. They could help you run required checks before creating the PR.

Please sync the latest code with latest dev branch (for azure-cli) or main branch (for azure-cli-extensions).
After that please run the following commands to enable git hooks:

pip install azdev --upgrade
azdev setup -c <your azure-cli repo path> -r <your azure-cli-extensions repo path>

Copy link
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 adds the filter='data' parameter to all tar.extractall() calls across multiple Azure CLI extensions to prevent CWE-23 directory traversal (zipslip) vulnerabilities. This security enhancement ensures that tar extraction operations reject malicious archive members that attempt to write outside the intended extraction directory.

  • Adds built-in protection against zipslip attacks using Python's data filter
  • Applies the fix consistently across 8 different Azure CLI extensions
  • Maintains existing functionality while enhancing security posture

Reviewed Changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/ssh/azext_ssh/connectivity_utils.py Added filter parameter to SSH proxy binary extraction
src/networkcloud/azext_networkcloud/operations/custom_properties.py Added filter parameter to custom action result blob extraction
src/containerapp/azext_containerapp/tests/latest/test_containerapp_create_update_up_java.py Added filter parameter to Java buildpack source code extraction
src/connectedk8s/azext_connectedk8s/clientproxyhelper/_binaryutils.py Added filter parameter to Arc Connectivity proxy binary extraction
src/confcom/azext_confcom/tests/latest/test_confcom_tar.py Added filter parameter to container image tar file processing
src/confcom/azext_confcom/tests/latest/test_confcom_fragment.py Added filter parameter to container image tar file processing
src/confcom/azext_confcom/os_util.py Added filter parameter to tar.extract calls for manifest extraction
src/aosm/azext_aosm/common/utils.py Added filter parameter to helm package extraction
src/amg/azext_amg/restore.py Added filter parameter to Grafana archive file extraction

@microsoft-github-policy-service
Copy link
Contributor

Thank you for your contribution @locus-x64! We will review the pull request and get back to you soon.

@github-actions
Copy link

CodeGen Tools Feedback Collection

Thank you for using our CodeGen tool. We value your feedback, and we would like to know how we can improve our product. Please take a few minutes to fill our codegen survey

@locus-x64
Copy link
Author

@microsoft-github-policy-service agree company="Ebryx"

@github-actions
Copy link

github-actions bot commented Sep 12, 2025

…y fix

Update version numbers and HISTORY entries for extensions affected by
the zipslip security fix in commit 5de16cc:

- amg: 2.8.1 → 2.8.2
- aosm: 2.0.0b2 → 2.0.0b3
- confcom: 1.2.7 → 1.2.8
- connectedk8s: 1.10.8 → 1.10.9
- networkcloud: 3.0.0 → 3.0.1
- ssh: 2.0.6 → 2.1.0

Each extension's HISTORY file now documents the security fix that
prevents zipslip/directory traversal attacks during tar archive
extraction operations.

Resolves maintainer feedback for release preparation.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Auto-Assign Auto assign by bot Connected Kubernetes ContainerApp customer-reported Issues that are reported by GitHub users external to the Azure organization. extension/grafana az grafana

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants