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 sbomorzarf package inspect documentationagainst 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.Nametaken directly from the package'szarf.yaml, without normalizing or rejecting path traversal sequences (e.g.,../) or dangerous absolute paths. This enables the content inSBOMS.taror 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.

