1
0
mirror of https://github.com/BurntSushi/ripgrep.git synced 2024-12-12 19:18:24 +02:00
ripgrep/crates
Andrew Gallant 229d1a8d41
cli: fix arbitrary execution of program bug
This fixes a bug only present on Windows that would permit someone to
execute an arbitrary program if they crafted an appropriate directory
tree. Namely, if someone put an executable named 'xz.exe' in the root of
a directory tree and one ran 'rg -z foo' from the root of that tree,
then the 'xz.exe' executable in that tree would execute if there are any
'xz' files anywhere in the tree.

The root cause of this problem is that 'CreateProcess' on Windows will
implicitly look in the current working directory for an executable when
it is given a relative path to a program. Rust's standard library allows
this behavior to occur, so we work around it here. We work around it by
explicitly resolving programs like 'xz' via 'PATH'. That way, we only
ever pass an absolute path to 'CreateProcess', which avoids the implicit
behavior of checking the current working directory.

This fix doesn't apply to non-Windows systems as it is believed to only
impact Windows. In theory, the bug could apply on Unix if '.' is in
one's PATH, but at that point, you reap what you sow.

While the extent to which this is a security problem isn't clear, I
think users generally expect to be able to download or clone
repositories from the Internet and run ripgrep on them without fear of
anything too awful happening. Being able to execute an arbitrary program
probably violates that expectation. Therefore, CVE-2021-3013[1] was
created for this issue.

We apply the same logic to the --pre command, since the --pre command is
likely in a user's config file and it would be surprising for something
that the user is searching to modify which preprocessor command is used.

The --pre and -z/--search-zip flags are the only two ways that ripgrep
will invoke external programs, so this should cover any possible
exploitable cases of this bug.

[1] - https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2021-3013
2021-05-29 09:36:48 -04:00
..
cli cli: fix arbitrary execution of program bug 2021-05-29 09:36:48 -04:00
core cli: fix arbitrary execution of program bug 2021-05-29 09:36:48 -04:00
globset doc: update CI links in crate READMEs 2020-11-16 19:07:16 -05:00
grep doc: update CI links in crate READMEs 2020-11-16 19:07:16 -05:00
ignore ignore/types: add po files to supported types 2021-05-28 12:06:10 -04:00
matcher doc: update CI links in crate READMEs 2020-11-16 19:07:16 -05:00
pcre2 doc: update CI links in crate READMEs 2020-11-16 19:07:16 -05:00
printer printer: fix --vimgrep for multi-line mode 2021-05-15 08:27:59 -04:00
regex impl: fix --multiline anchored match bug 2021-05-29 07:37:28 -04:00
searcher searcher: update outdated comment for buffer size 2021-03-31 08:18:38 -04:00