Details
I also verified overwrite, not just creation, by pre-creating a writable target file and then running the same install path. The existing file contents changed from ORIGINAL-MAIN to OVERWRITTEN-MAIN before rejection.
I further verified overwrite of a pre-existing project workflow file. Before the run, the target file contained:
name: safe
on: [push]
jobs:
build:
runs-on: ubuntu-latest
steps:
- run: echo safe
After the run, the same file contained attacker-controlled replacement YAML:
name: overwritten
on: [push]
jobs:
build:
runs-on: ubuntu-latest
steps:
- run: echo overwritten-by-archive
Observed command output on latest main:
[!] Install interrupted after 0.0s.
Usage: python -m apm_cli.cli install [OPTIONS] [PACKAGES]...
Try 'python -m apm_cli.cli install --help' for help.
Error: 'D:\apm\run-main-install\input\legacy-bundle.tar.gz' was packed with '--format apm' (legacy format). 'apm install <bundle>' requires the plugin format. Repack with 'apm pack --format plugin --archive', or use 'apm unpack' to deploy the legacy bundle.
Reproduction steps for latest release v0.12.4:
- Check out tag
v0.12.4/ commit6aceef72be490a9c716547f600a2659f3f2826b7. - Use the same Windows Python 3.11 runtime.
- Ensure the
apm_cliimport resolves to thev0.12.4tree. - Create the same malicious tarball shape, for example with:
D:/apm/run-release-install/outside/legacy-probe-outside-release.txt
- Run:
python -m apm_cli.cli install D:\apm\run-release-install\input\legacy-bundle.tar.gz
Observed result on latest release:
- the import path resolved to the checked-out
v0.12.4tree, - the command ended with the expected legacy-format rejection,
- the process exit code was
2, - and the file below had already been created outside the temporary extraction root:
D:\apm\run-release-install\outside\legacy-probe-outside-release.txt
The file contained:
outside write via install release
I also verified overwrite, not just creation, on the latest release by pre-creating a writable target file. The existing file contents changed from ORIGINAL-RELEASE to OVERWRITTEN-RELEASE before rejection. The same workflow-file overwrite pattern was also reproducible on the latest release.
Observed command output on latest release:
[!] Install interrupted after 0.0s.
Usage: python -m apm_cli.cli install [OPTIONS] [PACKAGES]...
Try 'python -m apm_cli.cli install --help' for help.
Error: 'D:\apm\run-release-install\input\legacy-bundle.tar.gz' was packed with '--format apm' (legacy format). 'apm install <bundle>' requires the plugin format. Repack with 'apm pack --format plugin --archive', or use 'apm unpack' to deploy the legacy bundle.
Additional same-family affected surface:
apm unpackon latestmainand latest release also created an outside file when given a tarball containing a Windows absolute member name.- In that path the command completed successfully with exit code
0, which further confirms that the Windows absolute-path validation gap is present outside the primary install probe as well.
Impact
This is an arbitrary local file overwrite outside the intended extraction root during a current APM install path. The impacted population is Windows users running APM on supported Python 3.10 or 3.11 runtimes. The attacker capability required is the ability to supply a crafted local bundle and induce the victim to run apm install on it.
The strongest demonstrated real-world consequence is attacker-controlled overwrite of an existing writable file at an attacker-selected Windows path outside the extraction root, using the privileges of the user running APM. An overwrite of a project-controlled GitHub Actions workflow file with attacker-controlled YAML before rejection was verified. Workflow execution from this report hasn't been claimed; the demonstrated consequence is high-integrity modification of a trusted automation file outside the intended extraction boundary.
The issue is currently reachable on:
- latest
mainat2b7a931d58a73cbfc0bcf086cea332d204075e27 - latest release
v0.12.4
Mitigation
- Reuse the existing pre-extraction validation already implemented in
detect_local_bundle()for_looks_like_legacy_apm_bundle(). - Reject Windows absolute member names before any extraction step.
- Apply equivalent Windows absolute-path validation to the unpacker in
src/apm_cli/bundle/unpacker.py. - Add regression tests for:
- Windows absolute member paths in the legacy-bundle probe path
- Windows absolute member paths in the unpack path
- confirmation that no host write occurs before the legacy-format rejection is raised
Attachment
apm-legacy-probe-windows-absolute-path-write-20260511.zip