### Summary 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. ## Severity **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. ## Affected Versions 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. ## Workarounds Administrators who cannot immediately upgrade should: - **Only restore archives from trusted sources.** Do not restore archives received from untrusted parties or transmitted over unencrypted channels. - **Use backup encryption.** Portainer's optional backup encryption requires the correct passphrase to decrypt before extraction; an attacker without the passphrase cannot craft a valid encrypted archive. Neither of these replaces the fix. ## Affected Code `ExtractTarGz` in `api/archive/targz.go` constructed output paths without safe containment: ```go // 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: ```go // api/archive/targz.go (post-fix) case tar.TypeReg: p := filesystem.JoinPaths(outputDirPath, header.Name) ``` ### Impact - Arbitrary file write at any path accessible to the Portainer process (typically root in containerised deployments), overriding filesystem boundaries of the data directory. - Potential host persistence by writing to cron directories, SSH authorised key files, or executable paths, depending on how the container is configured and what host paths are accessible. The practical severity is reduced because exploitation requires administrative privileges within Portainer. ## Timeline - 2026-02-16: Fix merged to develop ([#1875](https://github.com/portainer/portainer-suite/pull/1875)). - 2026-02-25: 2.39.0 released with fix. - 2026-05-07: 2.33.8 released with backport fix. ### Credits Reported by [Kolega](https://kolega.ai).
### Summary 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. ## Severity **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. ## Affected Versions 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. ## Workarounds Administrators who cannot immediately upgrade should: - **Only restore archives from trusted sources.** Do not restore archives received from untrusted parties or transmitted over unencrypted channels. - **Use backup encryption.** Portainer's optional backup encryption requires the correct passphrase to decrypt before extraction; an attacker without the passphrase cannot craft a valid encrypted archive. Neither of these replaces the fix. ## Affected Code `ExtractTarGz` in `api/archive/targz.go` constructed output paths without safe containment: ```go // 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: ```go // api/archive/targz.go (post-fix) case tar.TypeReg: p := filesystem.JoinPaths(outputDirPath, header.Name) ``` ### Impact - Arbitrary file write at any path accessible to the Portainer process (typically root in containerised deployments), overriding filesystem boundaries of the data directory. - Potential host persistence by writing to cron directories, SSH authorised key files, or executable paths, depending on how the container is configured and what host paths are accessible. The practical severity is reduced because exploitation requires administrative privileges within Portainer. ## Timeline - 2026-02-16: Fix merged to develop ([#1875](https://github.com/portainer/portainer-suite/pull/1875)). - 2026-02-25: 2.39.0 released with fix. - 2026-05-07: 2.33.8 released with backport fix. ### Credits Reported by [Kolega](https://kolega.ai).
Update github.com/portainer/portainer to 2.33.8 if you use the affected versions. Test the change in a non-production environment first.
Local check
hol-guard supply-chain scanPortainer has a path traversal in backup archive extraction that allows arbitrary file write affects github.com/portainer/portainer (go). Severity is medium. ### Summary 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. ## Severity **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. ## Affected Versions 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. ## Workarounds Administrators who cannot immediately upgrade should: - **Only restore archives from trusted sources.** Do not restore archives received from untrusted parties or transmitted over unencrypted channels. - **Use backup encryption.** Portainer's optional backup encryption requires the correct passphrase to decrypt before extraction; an attacker without the passphrase cannot craft a valid encrypted archive. Neither of these replaces the fix. ## Affected Code `ExtractTarGz` in `api/archive/targz.go` constructed output paths without safe containment: ```go // 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: ```go // api/archive/targz.go (post-fix) case tar.TypeReg: p := filesystem.JoinPaths(outputDirPath, header.Name) ``` ### Impact - Arbitrary file write at any path accessible to the Portainer process (typically root in containerised deployments), overriding filesystem boundaries of the data directory. - Potential host persistence by writing to cron directories, SSH authorised key files, or executable paths, depending on how the container is configured and what host paths are accessible. The practical severity is reduced because exploitation requires administrative privileges within Portainer. ## Timeline - 2026-02-16: Fix merged to develop ([#1875](https://github.com/portainer/portainer-suite/pull/1875)). - 2026-02-25: 2.39.0 released with fix. - 2026-05-07: 2.33.8 released with backport fix. ### Credits Reported by [Kolega](https://kolega.ai).
AI coding agents often install or upgrade packages automatically in go. A medium vulnerability in a dependency can be pulled into a project through a normal install or update without a human reviewing the change, expanding the blast radius from a single package to every agent workspace that depends on it.
| Package | Affected range | Fixed version |
|---|---|---|
| github.com/portainer/portainergo | >=2.33.0,<2.33.8 | 2.33.8 |
Fixed versions are reported by the source feed; confirm compatibility before updating.
Reported by GitHub Security Advisories (ghsa).
HOL Guard can help your team review package activity against supported protection paths.
Explore HOL GuardUpdate github.com/portainer/portainer to 2.33.8 if you use the affected versions. Test the change in a non-production environment first.
Local check
hol-guard supply-chain scanPortainer has a path traversal in backup archive extraction that allows arbitrary file write affects github.com/portainer/portainer (go). Severity is medium. ### Summary 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. ## Severity **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. ## Affected Versions 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. ## Workarounds Administrators who cannot immediately upgrade should: - **Only restore archives from trusted sources.** Do not restore archives received from untrusted parties or transmitted over unencrypted channels. - **Use backup encryption.** Portainer's optional backup encryption requires the correct passphrase to decrypt before extraction; an attacker without the passphrase cannot craft a valid encrypted archive. Neither of these replaces the fix. ## Affected Code `ExtractTarGz` in `api/archive/targz.go` constructed output paths without safe containment: ```go // 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: ```go // api/archive/targz.go (post-fix) case tar.TypeReg: p := filesystem.JoinPaths(outputDirPath, header.Name) ``` ### Impact - Arbitrary file write at any path accessible to the Portainer process (typically root in containerised deployments), overriding filesystem boundaries of the data directory. - Potential host persistence by writing to cron directories, SSH authorised key files, or executable paths, depending on how the container is configured and what host paths are accessible. The practical severity is reduced because exploitation requires administrative privileges within Portainer. ## Timeline - 2026-02-16: Fix merged to develop ([#1875](https://github.com/portainer/portainer-suite/pull/1875)). - 2026-02-25: 2.39.0 released with fix. - 2026-05-07: 2.33.8 released with backport fix. ### Credits Reported by [Kolega](https://kolega.ai).
AI coding agents often install or upgrade packages automatically in go. A medium vulnerability in a dependency can be pulled into a project through a normal install or update without a human reviewing the change, expanding the blast radius from a single package to every agent workspace that depends on it.
| Package | Affected range | Fixed version |
|---|---|---|
| github.com/portainer/portainergo | >=2.33.0,<2.33.8 | 2.33.8 |
Fixed versions are reported by the source feed; confirm compatibility before updating.
Reported by GitHub Security Advisories (ghsa).
HOL Guard can help your team review package activity against supported protection paths.
Explore HOL Guard