/

CVE-2026-45539

Severity:

HIGH RISK

(7.4)

Insecure Symlink Handling in Microsoft APM CLI Prompt and

CVE-2026-45539

Deferred

Vulnerability type

Category:

Insecure Symlink Handling

CWE:

CWE-59, CWE-200

Impact:

Unintended File Exposure and Supply-Chain Content Injection

Severity:

HIGH RISK

(7.4)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

Microsoft APM's CLI improperly follows symbolic links when integrating prompt and agent files from dependencies, allowing arbitrary filesystem content to be read and copied into deployment directories.

An attacker who controls a remote APM dependency can inject symlinks that cause sensitive or unexpected files to be included in a project's deploy tree and source control, bypassing integrity checks and pre-deploy scanning.

Affected context

This issue affects projects using Microsoft APM CLI versions 0.5.4 through 0.12.4 that:

  • Depend on remote APM packages containing prompt or agent definitions under:
  • .apm/prompts/<x>.prompt.md
  • .apm/agents/<x>.agent.md
  • Use the primitive integrators that enumerate files via Path.glob() / Path.rglob() and read them with Path.read_text() without restricting symlinks
  • Rely on the auto-generated .gitignore and built-in integrity checks (content_hash, SecurityGate scan, apm audit) to catch unsafe content

In these conditions, symlinks preserved into apm_modules/ may be transparently dereferenced during integration, with their resolved content written into deploy directories that are not ignored by default.

Exploit preconditions

  • Attack surface: Supply-chain dependencies in the APM ecosystem (remote APM packages).
  • Required access: Ability to publish or modify an APM dependency consumed by the target project, or to influence which dependency versions are pulled.
  • Trigger point: Running the APM CLI integrators that:
  • Clone or update dependencies into apm_modules/
  • Enumerate prompt/agent files under .apm/prompts/ or .apm/agents/ via Path.glob() / Path.rglob()
  • Read and rewrite each matched file into the project's deploy directories.
  • Why exploitation is possible:
  • Symlinks inside dependencies are preserved when cloned into apm_modules/.
  • The integrators do not filter or special-case symlinks and use Path.read_text() directly, causing symlinks to be dereferenced.
  • The resulting materialized files in deploy directories are treated as regular content, not flagged by content_hash, SecurityGate, or apm audit.
  • Deploy roots are not automatically ignored by .gitignore, so git add stages these files by default.

Why this happens

The root cause is insecure handling of filesystem traversal and symlinks in the APM CLI's integration logic.

The integrators use Path.glob() / Path.rglob() to enumerate prompt and agent files and Path.read_text() to read each match, implicitly trusting that all discovered paths are regular files. Symbolic links are treated the same as real files, so a symlink within a dependency pointing to an arbitrary location is transparently followed. The resolved content is then copied into the deploy directories as if it originated from the dependency's prompt or agent definition.

This behavior maps to CWE-59: Improper Link Resolution Before File Access ('Link Following') because the code does not constrain or validate link targets before accessing them. The additional association with CWE-200: Exposure of Sensitive Information to an Unauthorized Actor arises because symlink targets can include sensitive local files whose contents become embedded in project artifacts and even committed to version control.

Potential impact

  • A malicious dependency could cause arbitrary local files (e.g., configuration files, private prompts, API keys stored in text files) to be read and embedded into the project's deploy directories.
  • Sensitive information available on the development machine or CI environment may be exposed if the generated deploy files are committed to source control or distributed with application artifacts.
  • Untrusted or unexpected content may be injected into prompts or agent definitions, potentially altering AI agent behavior in subtle or malicious ways.
  • Integrity assumptions based on content_hash, SecurityGate scan, and apm audit may be undermined, as they do not flag symlink-based content substitution in this workflow.
  • Downstream consumers of the project may unknowingly redistribute files that originated from symlink-resolved paths, amplifying data exposure or supply-chain risks.

General mitigation guidance

Mitigation focuses on enforcing strict file-type and path controls when traversing dependency content and on limiting the trust placed in downstream deployment artifacts.

Useful defensive patterns include:

  • Symlink-aware file traversal: Explicitly check Path.is_symlink() before reading files discovered via glob or rglob, and either skip symlinks or handle them under a tightly scoped policy (e.g., only within a known safe tree).
  • Canonicalization and path constraints: Normalize and validate file paths, ensuring that resolved paths remain within expected directories (e.g., under .apm/prompts/ or .apm/agents/) and do not escape via .. segments or symlinks.
  • Separation of build and source trees: Treat deploy directories as build artifacts, not as source, and avoid automatically staging them in version control. Default .gitignore patterns can be configured to exclude deploy roots.
  • Least-privilege filesystem design: Avoid placing highly sensitive files in locations that could be reached by automated tooling, and isolate secrets or confidential prompts in dedicated locations with stricter access control.
  • Defense-in-depth scanning: Apply generic content and secret scanning to generated deploy directories, regardless of whether they passed earlier integrity or audit checks.

How teams detect issues like this

Detection can be approached by combining static analysis of integration code, runtime monitoring of filesystem access, and policy enforcement in CI/CD.

Potential strategies include:

  • Static analysis rules: Flag usage of Path.glob() / Path.rglob() combined with direct Path.read_text() or similar read operations where is_symlink() or path canonicalization checks are absent. Tools can be configured to highlight file traversal logic that does not explicitly handle symbolic links.
  • Code review signals: Reviewers should pay special attention to:
  • Any integration or packaging code that walks directories and copies files into deployment or build output locations.
  • Cases where "all files" under a directory are processed without constraints on file type or symlink resolution.
  • Situations where deployment artifacts are placed under version-controlled paths by default.
  • Policy enforcement in CI/CD: Enforce policies that:
  • Prevent deploy directories from being checked into source control or require justification for such patterns.
  • Run content and secret scanners over generated artifacts to detect unexpected inclusion of sensitive files.
  • Automated tooling: Optional use of automated code review or SAST tools to track link-following behavior and identify potential CWE-59 patterns across the codebase, particularly in build and integration scripts.

Sources

SourceLink
github.comgithub.com/microsoft/apm/security/advisories/GHSA-q5pp-gvjg-h7v4

Frequently asked

questions

Exploitation relies on the supply chain rather than direct remote access. An attacker must be able to publish or modify an APM dependency that your project consumes. Once that dependency is integrated by the APM CLI, the symlink-based behavior can be triggered without additional remote interaction.

The attacker needs control over or the ability to influence a dependency used by the target project—such as owning a package in the APM ecosystem or compromising a dependency source. Local filesystem or shell access to the victim environment is not required, as long as the environment runs the vulnerable integrator against the attacker-controlled dependency.

The safest pattern is to treat symlinks as untrusted by default: ensure integration code explicitly detects symlinks, restricts or disallows them in dependency content, and confines all resolved paths to well-defined directories. Additionally, treat deploy directories as build outputs, exclude them from version control by default, and ensure any file copying logic validates both source and destination paths.

Preventing similar issues involves adopting secure filesystem traversal patterns, enforcing path canonicalization and link-awareness in all code that walks directories, and institutionalizing policies that separate build artifacts from source. Regular security reviews of packaging and integration tooling, combined with automated checks that flag unsafe link-following or unchecked glob usage, help catch these patterns before they ship.

Find out what's already
exploitable in your codebase.