Summary
Microsoft APM's plugin normalization logic allowed attacker-controlled paths in plugin manifests to escape the plugin directory and copy arbitrary readable files or directories from the host into the .apm/ directory.
When a user installed a malicious marketplace plugin, the plugin could leverage absolute or traversal paths to exfiltrate host files during apm install, exposing sensitive local data to the plugin's consumer or subsequent tooling.
Affected context
This vulnerability occurs in environments where developers or operators install third-party or community-provided Microsoft APM plugins.
During apm install, the tool normalizes plugins by copying components referenced from plugin.json into a .apm/ workspace, but it does not restrict the referenced paths to remain under the plugin's own directory.
In setups where users run apm on their local machines or CI systems and install untrusted or lightly reviewed plugins, this behavior can expose files from the host filesystem to the plugin's artifact set.
Exploit preconditions
- Attack surface: The
apm installcommand processing plugin manifests from a marketplace or other distribution channel. - Required access: Ability to publish or otherwise supply a malicious plugin with crafted
plugin.jsonfields (agents,skills,commands,hooks) to a target user or automation workflow. - Trigger point: A victim runs
apm install(or equivalent install flow) for the malicious plugin, causing APM to copy files based on attacker-controlled paths. - Why exploitation is possible: The implementation trusts manifest paths and copies files into
.apm/without canonicalizing and validating that the resolved paths stay within the plugin's directory, allowing../traversal or absolute paths to reach arbitrary readable host files.
Why this happens
The core issue is a lack of proper path normalization and confinement when handling file paths sourced from untrusted manifest fields.
The plugin manifest (plugin.json) exposes several fields (agents, skills, commands, hooks) that describe which files should be copied during normalization.
Instead of treating these as potentially hostile inputs, APM directly uses them to construct filesystem operations, failing to:
- Canonicalize the target paths (e.g., via realpath)
- Enforce that the resolved paths remain inside the plugin's directory root
- Reject absolute or traversal paths
This aligns with CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal') and is closely related to CWE-73: External Control of File Name or Path, because external data fully controls which paths are accessed.
Potential impact
- A malicious plugin may copy arbitrary readable files (e.g., SSH configs, API keys, environment configuration files) from the installer's machine into
.apm/, where they might be packaged, uploaded, or inspected. - Sensitive project files, such as proprietary code or configuration, could be unintentionally exposed to other systems integrated with
.apm/output. - Build pipelines or CI environments running
apm installcould leak secrets or internal configuration into build artifacts or logs. - The copied files could be used as stepping stones for broader compromise if they contain credentials or tokens.
General mitigation guidance
Effective mitigation typically focuses on constraining filesystem access and validating all externally influenced paths before use.
Common defensive patterns include:
- Canonicalizing all manifest-supplied paths (resolving symbolic links, relative segments, and
..) and verifying they remain confined within the intended plugin root directory. - Explicitly rejecting absolute paths, paths containing
.., or paths that resolve outside the allowed directory tree. - Building a strict mapping between manifest entries and a known safe directory structure, rather than copying arbitrary paths.
- Running dependency tooling (such as APM) with least-privilege filesystem access and avoiding unnecessary exposure of sensitive directories to tools that consume untrusted input.
- Treating plugin manifests as untrusted configuration and subjecting them to schema validation, including path-format constraints.
How teams detect issues like this
Detection efforts can target both code-level patterns and operational signals:
- Static analysis and code review:
- Flag uses of file copy, open, or directory operations where the source or destination path is derived from plugin manifests or other external configuration without normalization and boundary checks.
- Look for missing checks around canonicalized paths (e.g., ensuring
resolved_path.startswith(plugin_root)or equivalent logic). - Highlight acceptance of absolute paths or paths containing
..segments in manifest handling logic. - Policy and tooling:
- Enforce secure coding guidelines for path handling in dependency managers and plugin systems, with specific rules for confining file access to designated directories.
- Use automated code scanning tools that include rules for CWE-22/CWE-73 to detect external control of file paths and path traversal risks.
- Operational monitoring:
- In sensitive environments, log and audit file operations performed by tooling that consumes third-party plugins, to identify unexpected reads outside plugin directories.

