<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Apm-Cli — CraftedSignal Threat Feed</title><link>https://feed.craftedsignal.io/tags/apm-cli/</link><description>Trending threats, MITRE ATT&amp;CK coverage, and detection metadata. Fed continuously.</description><generator>Hugo</generator><language>en</language><managingEditor>hello@craftedsignal.io</managingEditor><webMaster>hello@craftedsignal.io</webMaster><lastBuildDate>Tue, 02 Jan 2024 12:00:00 +0000</lastBuildDate><atom:link href="https://feed.craftedsignal.io/tags/apm-cli/feed.xml" rel="self" type="application/rss+xml"/><item><title>Microsoft APM CLI Path Traversal Vulnerability</title><link>https://feed.craftedsignal.io/briefs/2024-01-apm-cli-path-traversal/</link><pubDate>Tue, 02 Jan 2024 12:00:00 +0000</pubDate><author>hello@craftedsignal.io</author><guid isPermaLink="true">https://feed.craftedsignal.io/briefs/2024-01-apm-cli-path-traversal/</guid><description>Microsoft APM CLI version 0.8.11 and earlier are vulnerable to path traversal, allowing a malicious plugin to copy arbitrary readable host files during installation by manipulating paths in the plugin.json file.</description><content:encoded><![CDATA[<p>The Microsoft APM CLI is vulnerable to a path traversal vulnerability in versions 0.8.11 and earlier. This vulnerability arises during the installation of marketplace plugins, where the CLI normalizes plugins by copying components referenced in the <code>plugin.json</code> file. The <code>agents</code>, <code>skills</code>, <code>commands</code>, and <code>hooks</code> fields in <code>plugin.json</code> are attacker-controlled. However, the implementation fails to validate that these paths remain within the plugin directory. Consequently, a malicious plugin can exploit this by using absolute paths or <code>../</code> traversal paths to copy arbitrary, readable host files or directories from the installer&rsquo;s machine during the <code>apm install</code> process. This allows attackers to stage local files into repository-controlled paths, potentially leading to the exposure of sensitive information.</p>
<h2 id="attack-chain">Attack Chain</h2>
<ol>
<li>Attacker crafts a malicious APM plugin with a <code>plugin.json</code> file.</li>
<li>The <code>plugin.json</code> file contains crafted paths within the <code>commands</code> field pointing to sensitive host files using absolute paths or relative path traversal (e.g., <code>commands: &quot;D:\\absolute\\path\\to\\victim\\secret.md&quot;</code> or <code>commands: &quot;../../../secret.md&quot;</code>).</li>
<li>A user executes the <code>apm install</code> command, referencing the malicious plugin either locally or remotely.</li>
<li>The <code>normalize_plugin_directory</code> function in <code>src/apm_cli/commands/install.py</code> processes the plugin.</li>
<li>The <code>_resolve_sources()</code> function in <code>src/apm_cli/deps/plugin_parser.py</code> resolves the component paths specified in <code>plugin.json</code> without proper validation.</li>
<li>The APM CLI copies the files pointed to by the malicious paths into the <code>.apm/</code> directory.</li>
<li>If the copied files are recognized as prompt files (e.g., end with <code>.prompt.md</code>), they are integrated into the <code>.github/prompts/</code> directory of the project via <code>prompt_integrator.py</code>.</li>
<li>The attacker gains access to sensitive information from the copied files, which may then be committed and synced.</li>
</ol>
<h2 id="impact">Impact</h2>
<p>Successful exploitation of this vulnerability allows an attacker to read arbitrary files from the victim&rsquo;s machine during the installation of a malicious APM plugin. This can lead to the disclosure of sensitive information, such as local notes, markdown files, source code, or configuration files. The copied files can be automatically written into <code>.github/prompts/</code>, increasing the likelihood 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.</p>
<h2 id="recommendation">Recommendation</h2>
<ul>
<li>Deploy the &ldquo;APM CLI Plugin Install Path Traversal - Absolute Path&rdquo; Sigma rule to detect attempts to use absolute paths in <code>plugin.json</code> configurations, which can be indicative of malicious plugin activity.</li>
<li>Deploy the &ldquo;APM CLI Plugin Install Path Traversal - Relative Path&rdquo; Sigma rule to detect attempts to use relative paths with traversal sequences in <code>plugin.json</code> configurations.</li>
<li>Upgrade to a patched version of <code>apm-cli</code> that includes the recommended fix of resolving manifest-controlled component paths against <code>plugin_path.resolve()</code>, rejecting absolute or relative paths that escape the plugin root.</li>
<li>Implement file integrity monitoring on the <code>.apm/</code> directory to detect unauthorized file modifications or additions, using file_event logging.</li>
</ul>
]]></content:encoded><category domain="severity">high</category><category domain="type">advisory</category><category>path-traversal</category><category>supply-chain</category><category>apm-cli</category></item></channel></rss>