Every CVE Search/ Get API key

CVE-2026-45390

In OCaml-tar before 3.4.0, a crafted archive with ../ path segments in its name allows escaping...

9.1 CriticalFix available

In OCaml-tar before 3.4.0, a crafted archive with ../ path segments in its name allows escaping the current working directory. This is not desired behavior, and tar(1) rejects such extractions, but ocaml-tar decompresses it anyway. The impact is that it allows arbitrary file writes outside of the desired extraction directory (to an attacker that can reach a tar decompression endpoint).

Attack profile

How easy it is to exploit

Attack vector
Network
Complexity
Low
Privileges needed
None
User interaction
None

What an attacker can affect

Confidentiality
High
Integrity
High
Availability
None

Exploit likelihood

0.37%Up 0.2 points since Jun 16, 2026
90%50%10%1%

What each source reports

CVE List Score used 9.1

In OCaml-tar before 3.4.0, a crafted archive with ../ path segments in its name allows escaping the current working directory. This is not desired behavior, and tar(1) rejects such extractions, but ocaml-tar decompresses it anyway. The impact is that it allows arbitrary file writes outside of the desired extraction directory (to an attacker that can reach a tar decompression endpoint).

Record
CVE-2026-45390
CVSS 3.1
9.1 CriticalCVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:N
Weakness
CWE-22
Updated
2026-11-02
EUVDEUVD-2026-36766 9.1

In OCaml-tar before 3.4.0, a crafted archive with ../ path segments in its name allows escaping the current working directory. This is not desired behavior, and tar(1) rejects such extractions, but ocaml-tar decompresses it anyway. The impact is that it allows arbitrary file writes outside of the desired extraction directory (to an attacker that can reach a tar decompression endpoint).

Record
EUVD-2026-36766
CVSS 3.1
9.1 CriticalCVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:N
Updated
2026-11-02
GitHub AdvisoriesGHSA-x4gv-m4gg-cwm5 9.1

In OCaml-tar before 3.4.0, a crafted archive with ../ path segments in its name allows escaping...

In OCaml-tar before 3.4.0, a crafted archive with ../ path segments in its name allows escaping the current working directory. This is not desired behavior, and tar(1) rejects such extractions, but ocaml-tar decompresses it anyway. The impact is that it allows arbitrary file writes outside of the desired extraction directory (to an attacker that can reach a tar decompression endpoint).

Record
GHSA-x4gv-m4gg-cwm5
CVSS 3.1
9.1 CriticalCVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:N
Weakness
CWE-22
Updated
2026-11-02
NVD 9.1

In OCaml-tar before 3.4.0, a crafted archive with ../ path segments in its name allows escaping the current working directory. This is not desired behavior, and tar(1) rejects such extractions, but ocaml-tar decompresses it anyway. The impact is that it allows arbitrary file writes outside of the desired extraction directory (to an attacker that can reach a tar decompression endpoint).

Record
CVE-2026-45390
CVSS 3.1
9.1 CriticalCVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:N
Weakness
CWE-22
Updated
2026-11-02
OSVOSEC-2026-08 8.2

Path traversal vulnerability in ocaml-tar

A malicious archive with ../ path segments in its name allows escaping the current working directory. This is not desired behavior, and tar(1) rejects such extractions, but ocaml-tar decompresses it anyway. The impact is that it allows arbitrary file write outside of the desired extraction directory to an attacker that can reach a tar decompression endpoint. In terms of severity, similar vulnerabilities in different ecosystems (python, node, go) have been assigned CVSS scores of 6.8 MEDIUM, 7.1 HIGH, and 8.2 HIGH.

Details

Function Tar_unix.extract uses Filename.concat.

let extract ?(filter = fun _ -> true) ~src dst =
  let f ?global:_ hdr () =
    if filter hdr then
      match hdr.Tar.Header.link_indicator with
      | Tar.Header.Link.Normal ->
        begin match Result.map_error unix_err_to_msg
            (safe Unix.(openfile (Filename.concat dst hdr.Tar.Header.file_name)
                          [ O_WRONLY ; O_CREAT ]) hdr.Tar.Header.file_mode) with
        | Error _ as err -> Tar.return err
        | Ok dst ->
          try copy ~dst_fd:dst (Int64.to_int hdr.Tar.Header.file_size)
          with exn -> safe_close dst; Tar.return (Error (`Exn exn))
        end
        (* TODO set owner / mode / mtime etc. *)
      | _ ->
        (* TODO handle directories, links, etc. *)
        let open Tar.Syntax in
        let* () = Tar.seek (Int64.to_int hdr.Tar.Header.file_size) in
        Tar.return (Ok ())
    else
      let open Tar.Syntax in
      let* () = Tar.seek (Int64.to_int hdr.Tar.Header.file_size) in
      Tar.return (Ok ())
  in
  fold f src ()

Filename.concat does not perform any sanitation:

# Filename.concat "/tmp" "../../../etc/passwd";;
- : string = "/tmp/../../../etc/passwd"

Hence, calling Unix.openfile on such a path will result in opening /etc/passwd.

I only confirmed it in the following setting (see PoC below), and a proper fix would require investigating it in more details:

version targeted: 3.3.0, which seems to be the only version of ocaml-tar. But use of Filename.concat seems to have been there since the beginning.

Impact

This is a path traversal vulnerability that allows an attacker to perform an arbitrary file write outside of the intended extraction directory. Vulnerable users are the users relying on ocaml-tar, which includes (according to the readme of ocaml-tar):

  • xapi (confirmed not vulnerable by maintainers)
  • obuilder

Related CVEs

  • CVE-2007-4559: same problem in python's implementation of tar
  • CVE-2025-0377: similar problem in hashicorp's go implementation of tar
  • CVE-2026-24842: similar problem in node-tar

Fix

The fix is to sanitize paths before calling Unix.openfile. In the presence of symlink support, extra validation is needed.

Timeline

  • 2026-05-07: reported via GitHub (on https://github.com/ocaml/security-advisories)
  • 2025-05-20: initial fix developed and asked for review, also informed xapi and obuilder teams
  • 2025-05-22: fixed tar released, security advisory announced
Record
OSEC-2026-08
CVSS 3.1
8.2 HighCVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:H/I:L/A:N
Updated
2026-11-06

Affected packages

Affected packages
PackageAffectedFixed
tar
opam
before 3.5.0, plus listed versions
0.8.00.9.01.0.01.0.11.1.0
Show 16 moreShow less
2.0.02.0.12.1.02.2.02.2.12.2.22.3.02.4.02.5.02.5.12.6.03.0.03.1.13.1.23.2.03.3.0
3.5.0

History

History
RecordedChangedSources
affected, factsOSV
first indexedCVE List, EUVD, GitHub Advisories, NVD, OSV

Dates are when Every CVE recorded each change. Upstream dates may differ.

In short

CVE-2026-45390 is a critical vulnerability (CVSS 9.1) in tar, published May 22, 2026. No source lists public exploit code. EPSS puts the chance of exploitation in the next 30 days at 0.37%, the 31st percentile. Fixed in tar 3.5.0.

References

MoveEnter Open