/

CVE-2026-50163

Severity:

HIGH RISK

(7.1)

Hardlink Path Validation Flaw (CWE-22) in oras-go

CVE-2026-50163

Deferred

Vulnerability type

Category:

Path Traversal / Hardlink Handling

CWE:

CWE-22, CWE-59

Impact:

Local File Exposure and Tampering

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

oras-go contains a hardlink path validation flaw that allows certain tar entries to be resolved against the process working directory instead of the intended extraction base.

When exploited, this behavior can expose or tamper with sensitive local files if an attacker can supply a crafted OCI artifact and influence unpack behavior.

Affected context

This vulnerability occurs in environments using oras-go to unpack OCI artifacts that contain tar entries with Typeflag=TypeLink.

It is relevant when the unpack logic trusts header.Linkname and when the io.deis.oras.content.unpack annotation is set to "true" or similar behavior is enabled.

The issue manifests during extraction when hardlink targets are validated relative to the extraction base but then used in a way that allows resolution against the process current working directory.

Exploit preconditions

  • Attack surface: Artifact unpacking routines that rely on oras-go's content/file utilities.
  • Required access: Ability to provide or influence the OCI artifact being unpacked (e.g., push a crafted image or artifact).
  • Trigger point: Processing a tar entry such as payload.tar.gz/evil_cwd_link with Typeflag=TypeLink and Linkname="victim.secret" while unpack is enabled.
  • Why exploitation is possible: The ensureLinkPath helper validates the hardlink target relative to the extraction base but returns the unresolved target, allowing the subsequent os.Link call to resolve the link name against the current working directory instead of the controlled extraction path.

Why this happens

The root cause lies in incomplete path handling logic for hardlink extraction.

The function responsible for validating link paths confirms that a target appears safe with respect to the extraction base directory but then passes an unresolved path onward, relying on OS-level link resolution.

This pattern maps to CWE-22: Path Traversal and CWE-59: Improper Link Resolution Before File Access ('Link Following'), where link targets are not consistently resolved and constrained to a trusted base directory before being used.

Potential impact

  • Local files such as .env, .git/config, .aws/credentials, or ~/.ssh/config may be exposed through unintended linking.
  • Sensitive configuration files could be overwritten or tampered with.
  • Credential material stored in the user or application working directory can be indirectly accessed.
  • Build or deployment environments may be subtly poisoned via modified config files.

General mitigation guidance

Mitigation focuses on enforcing strict, consistent resolution of hardlink targets within a controlled extraction root.

Typical patterns include:

  • Normalizing and resolving link targets against the extraction base before any filesystem operations.
  • Rejecting or ignoring hardlinks whose resolved targets escape the intended unpack directory.
  • Treating unpacked artifact contents as untrusted and preventing them from referencing host-local configuration or secret files.
  • Running unpack processes with reduced privileges and isolation, limiting access to sensitive paths in the current working directory or home directory.

How teams detect issues like this

Detection can rely on several approaches:

  • Static analysis rules that flag uses of os.Link, symlink or hardlink operations where target paths are not normalized against a trusted base directory.
  • Code review guidelines that require explicit checks for path traversal and link resolution issues in unpack, archive, and extraction utilities.
  • Policy enforcement that prohibits unpack routines from operating in directories that contain sensitive configuration or credential files.
  • Security scanning tools configured to inspect archive-handling code for CWE-22 and CWE-59 patterns and to highlight validation functions that do not return constrained, fully-resolved paths.

Sources

SourceLink
github.comgithub.com/oras-project/oras-go/commit/c463c654ab3ef34422c1764cd619806cebf20451
github.comgithub.com/oras-project/oras-go/pull/1232
github.comgithub.com/oras-project/oras-go/releases/tag/v2.6.2
github.comgithub.com/oras-project/oras-go/security/advisories/GHSA-fxhp-mv3v-67qp

Frequently asked

questions

Not directly. It primarily enables exposure or modification of local files through unsafe hardlink handling rather than arbitrary code execution. Any escalation would depend on how those files are consumed by other components.

An attacker must be able to supply or control the OCI artifact or image that is being unpacked with oras-go. In many workflows, this corresponds to pushing a crafted artifact to a registry or otherwise influencing the source of artifacts.

The safest approach is to resolve all hardlink and symbolic link targets against a dedicated extraction root and reject any entry whose resolved path falls outside that root. Helper functions should return the fully-resolved, constrained path so that subsequent filesystem calls cannot escape the intended directory.

Treat archive contents as untrusted, apply strict path normalization and base-directory confinement for all file and link operations, and incorporate automated checks for path traversal and link resolution bugs in CI. Design unpack routines to operate in isolated directories with limited exposure to sensitive host files.

Find out what's already
exploitable in your codebase.