Summary
A relative path traversal flaw in libzypp's handling of the keyhint option within repomd.xml allows a malicious repository to write files outside the intended directory.
When a system consumes an attacker-controlled repository, this condition can lead to arbitrary file injection or overwrite as root, potentially enabling full system compromise.
Affected context
This vulnerability arises in environments where libzypp is used to manage software repositories and updates.
It becomes relevant when a client is configured, intentionally or accidentally, to trust or consume metadata from a repository whose contents can be influenced by an attacker.
The issue specifically involves parsing the repomd.xml metadata and honoring the keyhint option without adequately constraining or normalizing relative paths, allowing writes outside the expected repository or cache directory structure.
Exploit preconditions
- Attack surface: Package management infrastructure that uses libzypp to parse
repomd.xmlfrom configured repositories. - Required access: Ability to supply or control a repository, mirror, or metadata source consumed by libzypp (e.g., malicious repository URL, DNS/HTTP manipulation, or compromise of a third-party repo).
- Trigger point: Processing of
repomd.xmlmetadata, specifically thekeyhintoption, during repository refresh or package operations. - Why exploitation is possible: The
keyhintvalue is treated as a filesystem path without sufficient normalization or enforcement of a safe base directory, so relative path segments can traverse directories and target arbitrary locations writable by the libzypp process, which typically runs with root privileges.
Why this happens
The core issue is improper validation and normalization of file paths sourced from untrusted repository metadata.
libzypp accepts the keyhint field from repomd.xml and uses it to construct a file path, but fails to robustly reject or sanitize path constructs such as ../ that escape the intended directory.
This pattern is characteristic of CWE-23: Relative Path Traversal, where untrusted relative paths are concatenated or resolved against a base directory without enforcing strict boundaries or whitelisting safe locations.
As a result, an attacker can cause the application to read or write files in unintended directories under root-level privileges.
Potential impact
- Injection of new files in privileged system locations (e.g., configuration directories).
- Overwrite of existing system files that may influence service behavior or security posture.
- Introduction of malicious trusted keys or key configuration that undermines package verification.
- Facilitation of privilege escalation or persistent backdoors by modifying startup scripts or systemd units.
- Disruption of system operation through corruption of critical configuration or data files.
General mitigation guidance
Effective mitigation focuses on constraining file path handling and reducing trust in external metadata:
- Normalize and validate all paths derived from repository metadata before use, rejecting entries containing directory traversal markers or absolute paths.
- Resolve paths against a fixed, known-safe base directory and enforce that the final canonical path remains within that directory.
- Treat metadata fields such as
keyhintas untrusted input, applying strict allowlists for acceptable filenames or subdirectories. - Run package management operations with the minimum necessary privileges and separate roles where possible, so that metadata processing does not automatically imply unrestricted root-level filesystem access.
- Implement defense-in-depth by validating repository origins and signatures to reduce the likelihood of consuming attacker-controlled metadata.
How teams detect issues like this
Detection efforts can concentrate on both code and runtime behavior:
- Static analysis and review: Search for file path construction that directly uses values from
repomd.xmlor other remote metadata without normalization functions or bounds checks; flag uses of relative paths that are not validated. - Policy enforcement: Introduce coding guidelines requiring canonicalization and directory boundary checks for any filesystem interaction based on external repository data, enforced via code review checklists and automated linters.
- Runtime monitoring: Log and periodically audit file writes occurring during repository refresh or update operations, especially when they target unusual locations outside standard cache or key directories.
- Automated security testing: Use fuzzing or metadata mutation tools to supply
repomd.xmlwith craftedkeyhintvalues (including../components) in a controlled environment to detect unexpected file write behavior.

