mirror of
https://github.com/BurntSushi/ripgrep.git
synced 2024-12-12 19:18:24 +02:00
229d1a8d41
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 |
||
---|---|---|
.. | ||
app.rs | ||
args.rs | ||
config.rs | ||
logger.rs | ||
main.rs | ||
messages.rs | ||
path_printer.rs | ||
README.md | ||
search.rs | ||
subject.rs |
ripgrep core
This is the core ripgrep crate. In particular, main.rs
is where the main
function lives.
Most of ripgrep core consists of two things:
- The definition of the CLI interface, including docs for every flag.
- Glue code that brings the
grep-matcher
,grep-regex
,grep-searcher
andgrep-printer
crates together to actually execute the search.
Currently, there are no plans to make ripgrep core available as an independent library. However, much of the heavy lifting of ripgrep is done via its constituent crates, which can be reused independent of ripgrep. Unfortunately, there is no guide or tutorial to teach folks how to do this yet.