OSV 1.4.0 · github-reviewed · 修改于 2026-06-09 18:25
发布时间
2026-05-15 00:23
GitHub 审查时间
2026-05-15 00:23
NVD 发布时间
2026-05-29 06:16
源文件
advisories/github-reviewed/2026/05/GHSA-m8fg-67j7-cx4v/GHSA-m8fg-67j7-cx4v.json
Portainer's backup restore feature accepts a .tar.gz archive and extracts it to a target directory on the server. The extraction function (ExtractTarGz in api/archive/targz.go) constructed output paths using filepath.Clean(filepath.Join(outputDirPath, header.Name)). This combination does not prevent directory traversal — a tar entry named ../../etc/cron.d/evil resolves to a path outside the extraction root, so a crafted archive can write files to arbitrary locations on the server filesystem.
Medium
CWE-22 — Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')
Exploitation requires administrator access to Portainer's backup restore endpoint. An administrator who is deceived into restoring a malicious archive, or whose credentials are compromised, can use this path to write files outside the Portainer data directory.
The vulnerability exists in every Portainer release prior to 2.39.0 — ExtractTarGz has used filepath.Clean(filepath.Join()) since it was introduced. The fix shipped with 2.39.0 (patched on develop before the 2.39 branch cut); 2.34.x–2.38.x STS releases are also affected but are end-of-life and will not receive a fix.
| Branch | First vulnerable | Fixed in |
|---|---|---|
| 2.33.x (LTS) | 2.33.0 | 2.33.8 |
Portainer 2.39.0 and later are not affected — the fix was present from the initial 2.39.0 release. All releases prior to 2.33.0 are end-of-life and will not receive a fix; users on EOL versions should upgrade to a supported release.
Administrators who cannot immediately upgrade should:
Neither of these replaces the fix.
ExtractTarGz in api/archive/targz.go constructed output paths without safe containment:
// api/archive/targz.go (pre-fix)
case tar.TypeReg:
p := filepath.Clean(filepath.Join(outputDirPath, header.Name))
filepath.Join resolves ../ components lexically and filepath.Clean normalises the result, but neither verifies the final path remains inside outputDirPath. The fix replaces this with filesystem.JoinPaths, which forces all path components to be relative to the trusted root:
// api/archive/targz.go (post-fix)
case tar.TypeReg:
p := filesystem.JoinPaths(outputDirPath, header.Name)
The practical severity is reduced because exploitation requires administrative privileges within Portainer.
Reported by Kolega.