Skip to content
Fencer Intel
high 8.1

GHSA-xm96-gfjx-jcrc json

ORAS Java: Path traversal in pullArtifact via attacker-controlled org.opencontainers.image.title annotation

published 5mo ago modified 5mo ago

cvss
8.1
version 3.1, GitHub
cisa kev
Not listed
not in CISA's catalog
epss
—
no score, EPSS covers CVEs only
public exploits
0
none known

Summary

### Summary

The `pullArtifact` methods in `Registry` and `OCILayout` use the `org.opencontainers.image.title` annotation from a pulled manifest as a filename, resolving it against the caller supplied output directory without normalization or a containment check. A manifest publisher can set this annotation to a path that escapes the output directory, causing the SDK to write the layer's blob anywhere the JVM process can write.

### Details

Two call sites are affected.

`src/main/java/land/oras/Registry.java`, `pullLayer` (reached from `Registry.pullArtifact`):

```java Path targetPath = path.resolve(layer.getAnnotations().get(Const.ANNOTATION_TITLE)); ... Files.copy(is, targetPath, StandardCopyOption.REPLACE_EXISTING); ```

`src/main/java/land/oras/OCILayout.java`, `OCILayout.pullArtifact`:

```java Files.copy(blobPath, path.resolve(layer.getAnnotations().get(Const.ANNOTATION_TITLE))); ```

The annotation comes from the remote manifest. `Path.resolve` treats an absolute argument as a full override of the base, and follows `..` segments upward, so the annotation controls the destination. `REPLACE_EXISTING` overwrites files that exist at that destination.

The unpack branch of `pullLayer` (taken when the layer carries `io.deis.oras.content.unpack=true`) is not affected, because it dispatches through `ArchiveUtils.untar` / `unzip`, which apply `outputPath.startsWith(normalizedTarget)` after normalization. The non unpack branch and `OCILayout.pullArtifact` lack the equivalent check.

`fetchBlob(ContainerRef, Path)` is not affected. The caller passes the destination path and the title annotation is not consulted.

Patch / fix

  • maven land.oras:oras-java-sdk 0.6.2

Is GHSA-xm96-gfjx-jcrc in your dependencies? Fencer shows which of your repositories are affected as soon as an advisory lands, and opens the fix as a pull request.

Check with Fencer

CVSS scores

assigned by version score vector
GitHub 3.1 8.1 CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:H/A:H

Affected packages

ecosystem package affected fixed in
maven land.oras:oras-java-sdk
<0.6.2
0.6.2

Classification

Weakness
  • CWE-22 Improper Limitation of a Pathname to a Restricted Directory

References

Sources

Fencer Intel keeps one entry per vulnerability: the CVE id wins, then GHSA, and records that alias each other are merged, except that two CVEs always keep separate entries. The same data is available as JSON.