clusterfuzz icon indicating copy to clipboard operation
clusterfuzz copied to clipboard

Changing CWD to where the fuzzer executable lives

Open xx24678 opened this issue 4 years ago • 3 comments

I've been working on many fuzzing projects and quite some of them require loading some data files at start. Currently ClusterFuzz supports a "data archive" to include the required data files. However, the data files are extracted side by side to the fuzzer executable and the absolute location is not pre-determined. Since clusterfuzz currently won't change the current working directory (CWD) to where the fuzzer executable stays. The fuzzer has to implement logic at runtime to figure out the data file location by replacing the filename part of argv[0] with the name of the data file. Doing this is annoying and it's a pain in the ass if you are loading tons of files like this.

It would be much more elegant if we can do one of the following:

  1. clusterfuzz can start the fuzzer with CWD set to fuzzer's directory, or,
  2. clusterfuzz extract the data file to CWD, no matter where its pointing to so that the fuzzer can refer those files using hardcoded path like "./data/<my_file>".

xx24678 avatar Jul 22 '21 22:07 xx24678

Why not unpack fuzzer in the root directory, that is the model that works well, fuzzer cwd set to root of directory where all fuzzers are. also, you can always calculate data directory relative to directory where you fuzzer is in.

inferno-chromium avatar Jul 23 '21 00:07 inferno-chromium

  1. "unpack fuzzer" has to be done by the clusterfuzz runtime, fuzzer can't do that by itself.
  2. "fuzzer cwd set to root of directory" fuzzer can probably do it by itself but this is dangerous and also sometimes not practical: first it can break assumptions clusterfuzz runtime has for CWD (if there is any) second, now this fuzzer has a hardcoded dependency of root directory, which means this fuzzer binary cannot run on any systems where the root is not writable.

xx24678 avatar Jul 23 '21 20:07 xx24678

leaving to @oliverchang for any thoughts here.

inferno-chromium avatar Jul 23 '21 20:07 inferno-chromium