{"id":"CVE-2026-45390","aliases":["CVE-2026-45390","OSEC-2026-08"],"related":[],"kind":"vulnerability","state":"published","title":"Path traversal vulnerability in ocaml-tar","summary":"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).","summarySource":"cvelist","descriptions":[{"lang":"en","text":"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).","source":"cvelist"},{"lang":"en","text":"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 _ -> 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 ->\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 -> Tar.return err\n        | Ok dst ->\n          try copy ~dst_fd:dst (Int64.to_int hdr.Tar.Header.file_size)\n          with exn -> safe_close dst; Tar.return (Error (`Exn exn))\n        end\n        (* TODO set owner / mode / mtime etc. *)\n      | _ ->\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","format":"markdown","source":"osec"}],"published":"2026-05-22T20:55:00.000Z","modified":"2026-11-06T13:45:06.953Z","severity":{"scorer":"CISA-ADP","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:N","score":9.1,"rating":"CRITICAL"},"severities":[{"scorer":"CISA-ADP","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:N","score":9.1,"rating":"CRITICAL"},{"scorer":"OCaml Security Advisories","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:H/I:L/A:N","score":8.2,"rating":"HIGH"}],"cwes":["CWE-22"],"affected":[{"ranges":[{"version":"n/a","status":"affected"}],"source":"cvelist"},{"ranges":[{"type":"ecosystem","introduced":"0","status":"affected","fixed":"3.5.0"}],"ecosystem":"opam","package":"tar","purl":"pkg:opam/tar","source":"osec"},{"ranges":[{"type":"git","introduced":"0","status":"affected","fixed":"51ceb0a15982993503c169b9d84456fd50eabe99"}],"repo":"https://github.com/mirage/ocaml-tar","source":"osec"}],"references":[{"url":"https://osv.dev/vulnerability/OSEC-2026-08","tags":["exploit"],"sources":["cvelist","nvd"]}],"credits":["Quentin Stiévenart","Reynir Björnsson","Anil Madhavapeddy","Hannes Mehnert"],"assigner":"mitre","ssvc":{"scorer":"CISA-ADP","exploitation":"poc","automatable":"yes","technicalImpact":"total","date":"2026-06-16T13:59:55.486Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2026-45390","url":"https://www.cve.org/CVERecord?id=CVE-2026-45390","licence":"CVE Terms of Use","modified":"2026-06-16T14:02:18.195Z"},{"source":"osec","name":"OCaml Security Advisories","id":"OSEC-2026-08","url":"https://osv.dev/vulnerability/OSEC-2026-08","licence":"CC0-1.0","modified":"2026-11-06T13:45:06.953Z"},{"source":"nvd","name":"NVD","id":"CVE-2026-45390","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-45390","licence":"Public domain","modified":"2026-06-17T10:52:00.017Z"}],"updatedAt":"2026-11-25T22:59:24.654Z","epss":{"score":0.0045,"percentile":0.40798,"date":"2026-12-01T12:00:22.000Z"}}