{"id":"CVE-2026-45390","aliases":["EUVD-2026-36766","GHSA-x4gv-m4gg-cwm5","OSEC-2026-08"],"status":"published","title":"In OCaml-tar before 3.4.0, a crafted archive with ../ path segments in its name allows escaping...","description":"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).","severity":{"version":"3.1","score":9.1,"vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:N","level":"critical","assessor":"adp","from":"cve"},"epss":{"day":"2026-11-11","score":0.00373,"percentile":0.31631,"model":"v2026.06.15"},"facts":{"in_kev":false,"known_exploited":false,"public_exploit":false,"fix_available":true},"cwes":["CWE-22"],"published":"2026-05-22T20:55:00Z","modified":"2026-11-06T13:45:06Z","fixes":[{"ecosystem":"opam","package":"tar","fixed_in":["3.5.0"],"sources":["osv"]}],"affected":[{"source":"osv","ecosystem":"opam","package":"tar","ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"0"},{"fixed":"3.5.0"}]}],"versions":["0.8.0","0.9.0","1.0.0","1.0.1","1.1.0","2.0.0","2.0.1","2.1.0","2.2.0","2.2.1","2.2.2","2.3.0","2.4.0","2.5.0","2.5.1","2.6.0","3.0.0","3.1.1","3.1.2","3.2.0","3.3.0"]}],"references":[{"url":"https://osv.dev/vulnerability/OSEC-2026-08","tags":["exploit"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2026-45390"},{"url":"https://github.com/advisories/GHSA-x4gv-m4gg-cwm5"}],"sources":{"cve":[{"id":"CVE-2026-45390","description":"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).","status":"published","published":"2026-06-15T00:00:00Z","modified":"2026-06-16T14:02:18.195Z","cvss":[{"version":"3.1","score":9.1,"vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:N","level":"critical","assessor":"adp"}],"cwes":["CWE-22"],"updated_at":"2026-11-02T13:46:43.922571Z"}],"euvd":[{"id":"EUVD-2026-36766","description":"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).","status":"published","published":"2026-06-15T00:00:00Z","modified":"2026-06-16T14:02:18Z","cvss":[{"version":"3.1","score":9.1,"vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:N","level":"critical"}],"updated_at":"2026-11-02T18:20:40.605509Z"}],"ghsa":[{"id":"GHSA-x4gv-m4gg-cwm5","title":"In OCaml-tar before 3.4.0, a crafted archive with ../ path segments in its name allows escaping...","description":"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).","status":"published","published":"2026-06-15T21:30:39Z","modified":"2026-06-16T15:36:29Z","cvss":[{"version":"3.1","score":9.1,"vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:N","level":"critical"}],"cwes":["CWE-22"],"updated_at":"2026-11-02T15:08:48.835344Z"}],"nvd":[{"id":"CVE-2026-45390","description":"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).","status":"published","published":"2026-06-15T20:16:28.587Z","modified":"2026-06-17T10:52:00.017Z","cvss":[{"version":"3.1","score":9.1,"vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:N","level":"critical","assessor":"secondary"}],"cwes":["CWE-22"],"updated_at":"2026-11-02T14:12:23.846948Z"}],"osv":[{"id":"OSEC-2026-08","title":"Path traversal vulnerability in ocaml-tar","description":"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.\nThe 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.\n\n## Details\n\nFunction `Tar_unix.extract` uses `Filename.concat`.\n\n```OCaml\nlet extract ?(filter = fun _ -\u003e true) ~src dst =\n  let f ?global:_ hdr () =\n    if filter hdr then\n      match hdr.Tar.Header.link_indicator with\n      | Tar.Header.Link.Normal -\u003e\n        begin match Result.map_error unix_err_to_msg\n            (safe Unix.(openfile (Filename.concat dst hdr.Tar.Header.file_name)\n                          [ O_WRONLY ; O_CREAT ]) hdr.Tar.Header.file_mode) with\n        | Error _ as err -\u003e Tar.return err\n        | Ok dst -\u003e\n          try copy ~dst_fd:dst (Int64.to_int hdr.Tar.Header.file_size)\n          with exn -\u003e safe_close dst; Tar.return (Error (`Exn exn))\n        end\n        (* TODO set owner / mode / mtime etc. *)\n      | _ -\u003e\n        (* TODO handle directories, links, etc. *)\n        let open Tar.Syntax in\n        let* () = Tar.seek (Int64.to_int hdr.Tar.Header.file_size) in\n        Tar.return (Ok ())\n    else\n      let open Tar.Syntax in\n      let* () = Tar.seek (Int64.to_int hdr.Tar.Header.file_size) in\n      Tar.return (Ok ())\n  in\n  fold f src ()\n```\n\n`Filename.concat` does not perform any sanitation:\n\n```\n# Filename.concat \"/tmp\" \"../../../etc/passwd\";;\n- : string = \"/tmp/../../../etc/passwd\"\n```\n\nHence, calling `Unix.openfile` on such a path will result in opening `/etc/passwd`.\n\nI only confirmed it in the following setting (see PoC below), and a proper fix would require investigating it in more details:\n\nversion 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.\n\n## Impact\n\nThis is a path traversal vulnerability that allows an attacker to perform an arbitrary file write outside of the intended extraction directory.\nVulnerable users are the users relying on ocaml-tar, which includes (according to the readme of ocaml-tar):\n\n- xapi (confirmed not vulnerable by maintainers)\n- obuilder\n\nRelated CVEs\n\n- CVE-2007-4559: same problem in python's implementation of tar\n- CVE-2025-0377: similar problem in hashicorp's go implementation of tar\n- CVE-2026-24842: similar problem in node-tar\n\n## Fix\n\nThe fix is to sanitize paths before calling `Unix.openfile`. In the presence of symlink support, extra validation is needed.\n\n## Timeline\n\n- 2026-05-07: reported via GitHub (on https://github.com/ocaml/security-advisories)\n- 2025-05-20: initial fix developed and asked for review, also informed xapi and obuilder teams\n- 2025-05-22: fixed tar released, security advisory announced","status":"published","published":"2026-05-22T20:55:00Z","modified":"2026-11-06T13:45:06.953609434Z","cvss":[{"version":"3.1","score":8.2,"vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:H/I:L/A:N","level":"high"}],"updated_at":"2026-11-06T14:15:33.084084Z"}]}}
