{"id":"CVE-2021-3013","aliases":["CVE-2021-3013","GHSA-g4xg-fxmg-vcg5","RUSTSEC-2021-0071"],"related":[],"kind":"vulnerability","state":"published","title":"OS command injection in ripgrep","summary":"ripgrep before 13 on Windows allows attackers to trigger execution of arbitrary programs from the current working directory via the -z/--search-zip or --pre flag.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"ripgrep before 13 on Windows allows attackers to trigger execution of arbitrary programs from the current working directory via the -z/--search-zip or --pre flag.","source":"cvelist"},{"lang":"en","text":"On Windows in versions of `grep-cli` prior to `0.1.6`, it's possible for some\nof the routines to execute arbitrary executables. In particular, a quirk of\nthe Windows process execution API is that it will automatically consider the\ncurrent directory before other directories when resolving relative binary\nnames. Therefore, if you use `grep-cli` to read decompressed files in an\nuntrusted directory with that directory as the CWD, a malicious actor to could\nput, e.g., a `gz.exe` binary in that directory and `grep-cli` will use the\nmalicious actor's version of `gz.exe` instead of the system's.\n\nThis is also technically possible on Unix as well, but only if the `PATH`\nvariable contains `.`. Conventionally, they do not.\n\nA `DecompressionReader` has been fixed to automatically resolve binary names\nusing `PATH`, instead of relying on the Windows API to do it.\n\nIf you use `grep-cli`'s `CommandReader` with a `std::process::Command` value\non Windows, then it is recommended to either construct the `Command` with an\nabsolute binary name, or use `grep-cli`'s new\n[`resolve_binary`](https://docs.rs/grep-cli/0.1.6/grep_cli/fn.resolve_binary.html)\nhelper function.\n\nTo be clear, `grep-cli 0.1.6` mitigates this issue in two ways:\n\n* A `DecompressionReader` will resolve decompression programs to absolute\npaths automatically using the `PATH` environment variable, instead of relying\non Windows APIs to do it (which would result in the undesirable behavior of\nchecking the CWD for a program first).\n* A new function, `resolve_binary`, was added to help users of this crate\nmitigate this behavior when they need to create their own\n`std::process::Command`. For example,\n[ripgrep uses `grep_cli::resolve_binary`](https://github.com/BurntSushi/ripgrep/blob/7ce66f73cf7e76e9f2557922ac8e650eb02cf4ed/crates/core/search.rs#L119-L122)\non the argument given to its `--pre` flag.\n\nWhile the first mitigation fixes this issue for sensible values of `PATH`\nwhen doing decompression search, the second mitigation is imperfect. The more\nfundamental issue is that `std::process::Command` is itself vulnerable to this.","format":"markdown","source":"rustsec"},{"lang":"es","text":"ripgrep versiones anteriores a 13 en Windows permite a los atacantes desencadenar la ejecución de programas arbitrarios desde el directorio de trabajo actual a través de la bandera -z/--search-zip o --pre.","source":"nvd"}],"published":"2021-06-11T11:19:37.000Z","modified":"2026-06-17T04:04:33.780Z","severity":{"scorer":"NVD","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H","score":9.8,"rating":"CRITICAL"},"severities":[{"scorer":"GitHub","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H","score":9.8,"rating":"CRITICAL"},{"scorer":"RustSec Advisory Database","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H","score":9.8,"rating":"CRITICAL"},{"scorer":"NVD","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H","score":9.8,"rating":"CRITICAL"},{"scorer":"NVD","scheme":"CVSS:2.0","vector":"AV:N/AC:L/Au:N/C:P/I:P/A:P","score":7.5,"rating":"HIGH"}],"cwes":["CWE-78"],"affected":[{"ranges":[{"version":"n/a","status":"affected"}],"source":"cvelist"},{"ranges":[{"type":"semver","introduced":"0","status":"affected","fixed":"13.0.0"}],"ecosystem":"crates.io","package":"ripgrep","purl":"pkg:cargo/ripgrep","source":"ghsa"},{"ranges":[{"type":"semver","introduced":"0","status":"affected","fixed":"0.1.6"}],"ecosystem":"crates.io","package":"grep-cli","purl":"pkg:cargo/grep-cli","source":"ghsa"},{"ranges":[{"type":"semver","introduced":"0.0.0-0","status":"affected","fixed":"0.1.6"}],"ecosystem":"crates.io","package":"grep-cli","purl":"pkg:cargo/grep-cli","source":"rustsec"},{"ranges":[{"status":"affected","fixed":"13.0.0"}],"vendor":"ripgrep_project","product":"ripgrep","cpe":"cpe:2.3:a:ripgrep_project:ripgrep:*:*:*:*:*:*:*:*","source":"nvd"}],"references":[{"url":"https://github.com/BurntSushi/ripgrep/blob/master/CHANGELOG.md","tags":["patch","third-party-advisory","web","x-refsource-confirm","x-transferred"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/BurntSushi/ripgrep/blob/e48a17e1891e1ea9dd06ba0e48d5fb140ca7c0c4/CHANGELOG.md","tags":["release-notes","third-party-advisory","web","x-refsource-misc","x-transferred"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2021-3013","tags":["advisory"],"sources":["ghsa"]},{"url":"https://github.com/BurntSushi/ripgrep/issues/1773","tags":["report","web"],"sources":["ghsa","rustsec"]},{"url":"https://github.com/BurntSushi/ripgrep","tags":["package"],"sources":["ghsa"]},{"url":"https://github.com/BurntSushi/ripgrep/blob/master/CHANGELOG.md#1300-2021-06-12","tags":["web"],"sources":["ghsa"]},{"url":"https://rustsec.org/advisories/RUSTSEC-2021-0071.html","tags":["advisory","web"],"sources":["ghsa","rustsec"]},{"url":"https://crates.io/crates/grep-cli","tags":["package"],"sources":["rustsec"]}],"credits":[],"assigner":"mitre","sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2021-3013","url":"https://www.cve.org/CVERecord?id=CVE-2021-3013","licence":"CVE Terms of Use","modified":"2024-08-03T16:45:50.567Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-g4xg-fxmg-vcg5","url":"https://github.com/advisories/GHSA-g4xg-fxmg-vcg5","licence":"CC-BY-4.0","modified":"2023-11-08T04:05:44.745Z"},{"source":"rustsec","name":"RustSec Advisory Database","id":"RUSTSEC-2021-0071","url":"https://rustsec.org/advisories/RUSTSEC-2021-0071.html","licence":"CC0-1.0","modified":"2023-11-08T04:05:44.745Z"},{"source":"nvd","name":"NVD","id":"CVE-2021-3013","url":"https://nvd.nist.gov/vuln/detail/CVE-2021-3013","licence":"Public domain","modified":"2026-06-17T04:04:33.780Z"}],"updatedAt":"2026-11-25T22:58:01.785Z","epss":{"score":0.01934,"percentile":0.80643,"date":"2026-12-01T12:00:22.000Z"}}