php-internal-docs 8.4.8
Unofficial docs for php/php-src
|
The following ./configure
options can be used to enable the fuzzing SAPI, as well as all available fuzzers. If you don't build the exif/json/mbstring extensions, fuzzers for these extensions will not be built.
The --with-pic
option is required to avoid a linking failure. The --enable-debug-assertions
option can be used to enable debug assertions despite the use of a release build.
You can combine fuzzing with --enable-address-sanitizer
, --enable-undefined-sanitizer
or --enable-memory-sanitizer
. The first two options can also be used together.
You will need a recent version of clang that supports the -fsanitize=fuzzer-no-link
option.
When running make
it creates these binaries in sapi/fuzzer/
:
php-fuzz-parser
: Fuzzing language parser and compilerphp-fuzz-unserialize
: Fuzzing unserialize() functionphp-fuzz-unserializehash
: Fuzzing unserialize() for HashContext objectsphp-fuzz-json
: Fuzzing JSON parserphp-fuzz-exif
: Fuzzing exif_read_data()
function (requires –enable-exif)php-fuzz-mbstring
: Fuzzing mb_convert_encoding()
(requires --enable-mbstring
)php-fuzz-mbregex
: Fuzzing mb_ereg[i]()
(requires –enable-mbstring)php-fuzz-execute
: Fuzzing the executorphp-fuzz-function-jit
: Fuzzing the function JIT (requires –enable-opcache)php-fuzz-tracing-jit
: Fuzzing the tracing JIT (requires –enable-opcache)Some fuzzers have a seed corpus in sapi/fuzzer/corpus
. You can use it as follows:
For the unserialize fuzzer, a dictionary of internal classes should be generated first:
For the unserializehash fuzzer, generate a corpus of initial hash serializations:
For the parser fuzzer, a corpus may be generated from Zend test files:
For the execute, function-jit and tracing-jit fuzzers, a corpus may be generated from any set of test files:
For the mbstring fuzzer, a dictionary of encodings should be generated first:
For the mbregex fuzzer, you may want to build the libonig dependency with instrumentation. At this time, libonig is not clean under ubsan, so only the fuzzer and address sanitizers may be used.
This will link an instrumented libonig statically into the PHP binary.