find -execdir is (probably) not safe

find -execdir is (probably) not safe

As long as there is a relative path in the PATH environment variable, find -execdir is totally unsafe and highly unrecommended.

Assume that your PATH value is .:/usr/bin:/sbin:/bin:/snap/bin, in the directory which contains the file founded via find -execdir command, there is an executable file named cat. This fake cat contains a malicious code.

If you do find . -execdir cat {} \;, the malicious fake cat will be executed instead of your expected /bin/cat.

Buy Me A Coffee