/

CVE-2026-40090

Severity:

HIGH RISK

(7.1)

Path Traversal in Zarf SBOM & Documentation Inspect Output

CVE-2026-40090

Analyzed

Vulnerability type

Category:

Path Traversal / Directory Traversal

CWE:

CWE-22

Impact:

Arbitrary File Write

Severity:

HIGH RISK

(7.1)

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

Zarf package inspection commands trusted the Metadata.Name field from untrusted package manifests when constructing output paths, enabling directory traversal.

If a user inspects a malicious Zarf package, the attacker-controlled metadata can cause SBOM or documentation files to be written to arbitrary locations on the filesystem within the permissions of the inspecting user.

Affected context

This vulnerability affects environments where Zarf is used to inspect packages, particularly with the zarf package inspect sbom and zarf package inspect documentation subcommands.

The risk is present when:

  • Users inspect packages obtained from untrusted or partially trusted sources.
  • The inspecting user has filesystem permissions to sensitive paths (e.g., cron directories, SSH keys, application config).
  • The package manifest (zarf.yaml) can be modified after creation, bypassing initial Metadata.Name validation.

The issue materializes during inspection, when output paths are built by joining a user-specified directory with the untrusted Metadata.Name value from the package.

Exploit preconditions

  • Attack surface: Local CLI usage of Zarf on a workstation, CI runner, or automation host.
  • Required access: Ability to supply or influence a Zarf package that a user or automation later inspects.
  • Trigger point: Running zarf package inspect sbom or zarf package inspect documentation against a malicious package, with an output directory that allows writes to the eventual resolved path.
  • Why exploitation is possible: The code constructs file paths by concatenating a user-controlled output directory with Metadata.Name taken directly from the package's zarf.yaml, without normalizing or rejecting path traversal sequences (e.g., ../) or dangerous absolute paths. This enables the content in SBOMS.tar or related artifacts to be written outside the intended output directory.

Why this happens

The underlying bug class is path traversal via unsafe file path construction, corresponding to CWE-22.

Zarf's inspect commands treated Metadata.Name from the package manifest as a trusted path segment, combining it with the chosen output directory to determine where to write extracted SBOM or documentation files.

Because this value came from an untrusted package and was not revalidated or sanitized at inspect time, an attacker could embed traversal sequences (../../) or absolute paths (/home/user/.ssh/authorized_keys). When the inspect command extracted files from SBOMS.tar using these paths, it wrote attacker-controlled data to filesystem locations chosen by the attacker, within the privileges of the process.

Potential impact

  • Overwriting user or system configuration files with attacker-controlled content.
  • Dropping or modifying cron jobs (e.g., in /etc/cron.d) that may be executed automatically, potentially leading to code execution.
  • Tampering with SSH-related files (e.g., authorized_keys) to gain unauthorized access if used by an SSH service.
  • Planting malicious scripts or binaries in directories that are later executed by users or automation.
  • Corrupting application data or logs by overwriting files in writable application directories.

General mitigation guidance

Effective mitigation focuses on treating all metadata from packages as untrusted input and on removing path traversal capabilities in path construction logic.

Recommended defensive patterns include:

  • Normalize and validate paths at use time: Resolve the final path and ensure it remains within the intended output directory (e.g., through canonicalization checks and "jail" enforcement).
  • Reject traversal and absolute paths: Explicitly disallow .., leading path separators, and absolute paths in any field that will be used as part of a filesystem path.
  • Separate identifiers from paths: Use internal, sanitized identifiers or generated directory names for extraction, rather than directly embedding user-controlled metadata into paths.
  • Least-privilege execution: Run Zarf inspections under accounts with minimal filesystem access and avoid running them with elevated privileges.
  • Treat packages as untrusted by default: Apply the same validation and sanitization rules during inspection as during package creation, so post-creation tampering does not bypass checks.

How teams detect issues like this

To detect similar vulnerabilities and potential abuse, organizations can:

  • Static analysis: Define rules that flag path construction using untrusted data (e.g., joins of user or file-derived fields into filesystem paths without normalization and bounds checking).
  • Code review practices: During review, scrutinize any code that:
  • Constructs file paths using metadata or manifest fields.
  • Extracts archives (tar/zip) into user-specified or computed locations.
  • Writes files based on values read from untrusted sources.
  • Runtime monitoring: Monitor for unusual file writes originating from Zarf invocations, especially to sensitive directories like /etc, user SSH directories, or system cron paths.
  • Policy enforcement: Use CI checks or security linters that enforce safe file handling patterns, and flag the use of path segments directly derived from untrusted manifests.

Sources

SourceLink
github.comgithub.com/zarf-dev/zarf/pull/4793
github.comgithub.com/zarf-dev/zarf/security/advisories/GHSA-pj97-4p9w-gx3q

Frequently asked

questions

Not directly. Exploitation typically requires convincing a user or automation system to inspect a malicious Zarf package. However, if packages are pulled and inspected automatically from remote sources (e.g., in CI/CD), the impact can resemble remote exploitation.

The attacker needs the ability to supply or modify a Zarf package that will be inspected—such as publishing a malicious package or tampering with a package in transit or at rest. They do not need shell access to the victim system, but the damage is constrained by the filesystem permissions of the user running the zarf package inspect command.

The safest pattern is to canonicalize and validate all file paths before writing, ensuring the resolved path stays within a pre-defined output directory, and to reject any metadata values containing traversal or absolute path constructs. Additionally, decouple user-visible names from on-disk directory names by using sanitized or generated identifiers.

Future prevention relies on a standard approach to path handling: treat all external input (including manifest metadata) as untrusted, avoid embedding it directly into filesystem paths, add normalization and boundary checks around every file write, and enforce these patterns through code review, static analysis, and secure coding guidelines.

Find out what's already
exploitable in your codebase.