Summary
A path traversal and symlink-following flaw in oras-go layer extraction can allow a malicious OCI artifact to write files outside the intended store directory. When an attacker-controlled artifact is pulled, the issue may overwrite files writable by the extraction process and could enable code execution.
Affected context
The vulnerability affects oras-go deployments that use content/file.Store to extract OCI layers marked for unpacking. Risk arises when an attacker can supply or influence an OCI artifact and the extraction process handles archive entries involving symlinks and regular files. The impact depends on the files writable by the process performing extraction.
Exploit preconditions
- Attack surface: OCI artifact or layer extraction through
content/file.Store - Required access: Ability to cause the application to pull or process a malicious artifact
- Trigger point: Extraction of an archive containing a crafted symlink chain followed by a same-named regular-file entry
- Why exploitation is possible: Lexical path checks can treat the target as being within the extraction root while filesystem resolution follows a terminal symlink to an attacker-selected absolute path
- Privilege dependency: The resulting overwrite is limited by the filesystem permissions of the extraction process
Why this happens
The underlying bug combines incomplete path containment checks with unsafe symlink handling during archive extraction. Validation examines paths lexically, while certain root-level entries do not receive complete parent-symlink resolution, and regular-file creation can follow a terminal symlink. This maps primarily to CWE-22: Improper Limitation of a Pathname to a Restricted Directory, with CWE-59: Improper Link Resolution Before File Access describing the unsafe interaction between validation and filesystem link resolution.
Potential impact
- A malicious artifact may overwrite files outside the intended extraction directory.
- The attacker could modify application, configuration, or startup files writable by the process.
- The vulnerability may enable code execution when an overwritten file is later loaded or executed.
- An affected process could suffer data loss, service disruption, or integrity compromise.
- Broader compromise could occur if the extraction process has excessive filesystem privileges.
General mitigation guidance
Mitigation generally focuses on making archive extraction resistant to symlink-based escapes and enforcing containment against resolved filesystem paths.
Common defensive patterns include:
- Extracting into an isolated, dedicated directory with narrowly scoped permissions.
- Rejecting or safely neutralizing symlink and hard-link entries unless they are explicitly required.
- Validating canonicalized paths and filesystem objects before creation or overwrite.
- Using filesystem APIs and extraction modes that do not follow untrusted links.
- Applying least privilege, read-only mounts, and sandboxing to the extraction process.
- Treating externally sourced OCI artifacts as untrusted and enforcing provenance or policy checks before processing.
How teams detect issues like this
Organizations can look for this class of issue through:
- Static analysis rules covering archive extraction, path joining, symlink creation, and file opening.
- Code review checks for lexical-only containment validation and follows of terminal symlinks.
- Tests using archives with nested links, root-level entries, absolute targets, and conflicting file names.
- Runtime monitoring for writes outside designated extraction directories.
- Policy enforcement that restricts artifact sources and blocks untrusted layers from privileged workloads.
- Automated security review tools that flag path traversal and link-resolution patterns.

