PT-2026-59059 · Pypi · Apm-Cli
Published
2026-07-13
·
Updated
2026-07-13
CVSS v3.1
7.1
High
| Vector | AV:L/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:N |
Summary
Microsoft APM normalizes marketplace plugins by copying plugin components referenced in
plugin.json into .apm/. The manifest fields agents, skills, commands, and hooks are attacker-controlled, but the implementation does not enforce that those paths remain inside the plugin directory. A malicious plugin can therefore use absolute paths or ../ traversal paths to copy arbitrary readable host files or directories from the installer's machine during apm install.In the verified primary proof of concept, a malicious plugin sets
plugin.json.commands to an external markdown file. A single apm install copies that outside file into .apm/prompts/ and then auto-integrates it into .github/prompts/secret.prompt.md in the victim project. This is a local supply-chain trust-boundary violation with direct confidentiality and integrity impact.Reviewed version and commit:
apm-cliversion0.8.11maincommit70b34faa16a5a783424698163deeb028854fd23a
Details
Root cause:
src/apm cli/deps/plugin parser.py:336-348resolve sources()joins manifest-controlledagents,skills,commands, and directory-formhookspaths withplugin path- it checks only
exists()andis symlink() - it does not resolve the candidate and verify containment inside the plugin root
src/apm cli/deps/plugin parser.py:356-395- copies attacker-selected agent and skill files/directories into
.apm/ src/apm cli/deps/plugin parser.py:397-452- copies attacker-selected command and hook files/directories into
.apm/ src/apm cli/deps/plugin parser.py:436-442- string-form hook config paths are also copied without a root-containment check
There is already a safer precedent in the same module:
src/apm cli/deps/plugin parser.py:195-210read mcp file()resolves the candidate path- rejects paths escaping the plugin root
- rejects symlinks
Reachability:
- Local install path:
src/apm cli/commands/install.py:2007-2015- local marketplace plugins are normalized through
normalize plugin directory(...) - Remote install path:
src/apm cli/deps/github downloader.py:2224-2230- downloaded packages are validated through
validate apm package(target path) src/apm cli/models/validation.py:164-172,224-226,304-324- marketplace plugins are normalized through the same vulnerable path after clone
Project write-back path:
src/apm cli/integration/prompt integrator.py:38-56- reads
.apm/prompts/*.prompt.md src/apm cli/integration/prompt integrator.py:170-189- writes prompt files into
.github/prompts/ src/apm cli/commands/install.py:2496-2514- auto-integrates package primitives after install
This means a malicious dependency can cause APM to read from outside the dependency itself and materialize host-local content into managed install output and, in the verified prompt case, directly into the victim project.
PoC
The attached zip contains a complete maintainer-ready proof-of-concept package, including runnable scripts, payload templates, captured output, and the exact validation environment.
Primary end-to-end
apm install reproduction:- Install APM from the reviewed source tree (
apm-cli 0.8.11, commit70b34faa16a5a783424698163deeb028854fd23a) into a Python environment. - Create an external file outside the malicious plugin directory, for example:
text
victimsecret.mdwith content:
md
# STOLEN VIA APM INSTALL- Create a malicious plugin with this minimal
plugin.json:
json
{
"name": "evil-plugin",
"commands": "D:absolutepathtovictimsecret.md"
}- Create a minimal
apm.ymlthat references the malicious plugin. - Run:
powershell
apm install- Observe that APM completes successfully and writes:
text
.github/prompts/secret.prompt.md- Observe that the resulting prompt file contains the external host file content:
md
# STOLEN VIA APM INSTALLVerified console output from the included PoC:
text
[>] Installing dependencies from apm.yml...
[+] ./evil-plugin (local)
|-- 1 prompts integrated -> .github/prompts/
[*] Installed 1 APM dependency.
PoC succeeded.
Integrated into project: ....githubpromptssecret.prompt.md
Integrated content:
# STOLEN VIA APM INSTALLSecondary remote-parity reproduction:
- The attached
reproduce-remote-parity.pyexercisesGitHubPackageDownloader.download package(...)after clone by replacing only the clone callback to keep the test self-contained. - It confirms the same unsafe normalization path copies an outside host file into:
text
<download-target>/.apm/prompts/secret.prompt.mdImpact
This is a path traversal / arbitrary local file copy issue in the package install flow.
Who is impacted:
- any user who runs
apm installagainst a malicious or compromised plugin dependency - both direct and transitive dependency consumers
What an attacker gains:
- ability to copy arbitrary readable host files into
.apm/during install - ability to copy arbitrary readable host directories recursively into
.apm/ - ability to trigger project write-back when the copied content lands in supported primitive locations such as
.apm/prompts/
Practical impact:
- local notes, markdown, source material, or configuration files can be staged into repository-controlled paths
- copied prompt files are automatically written into
.github/prompts/, increasing the chance that sensitive or attacker-selected content is committed, synced, or consumed by other tooling - the issue breaks the expected trust boundary that a dependency install should copy only content belonging to the dependency itself
Mitigation
Recommended fix:
- Resolve every manifest-controlled component path against
plugin path.resolve(). - Reject absolute or relative paths that escape the plugin root.
- Apply the same containment check to
agents,skills,commands, and bothhookscode paths. - Reject symlinks before copying.
- Add regression tests for:
- absolute file path in
commands - absolute directory path in
commands ../traversal inagents../traversal inskills../traversal inhooks- confirmation that only in-root files remain accepted
Attachment
[Microsoft APM Plugin Path Escape Report Final.zip](https://github.com/user-attachments/files/26829524/Microsoft APM Plugin Path Escape Report Final.zip)
Fix
Found an issue in the description? Have something to add? Feel free to write us 👾
Related Identifiers
Affected Products
Apm-Cli