nikic/php-fuzzer
A coverage-guided fuzzing tool for PHP that helps uncover crashes, assertion failures, and security bugs in PHP itself and extensions. Uses AFL-style instrumentation and supports running targets under various sanitizers for fast, automated bug hunting.
Start by installing nikic/php-fuzzer via Composer (composer require --dev nikic/php-fuzzer) and creating a minimal fuzzer script—typically a small callable that accepts a string input and passes it to the target function or library. For example:
<?php
require 'vendor/autoload.php';
use Fuzzer\Runner;
$runner = new Runner();
$runner->fuzz(function (string $input): void {
// Target code under test — e.g., a parser
try {
my_parser($input);
} catch (Throwable $e) {
// Fuzzer ignores exceptions unless configured otherwise
}
});
Then run it from the CLI: php fuzz.php. By default, it runs indefinitely, logging any crashes or fatal errors. The first use case is verifying that your parser or extension handles malformed input gracefully.
json_decode, a custom tokenizer) and let the fuzzer feed it arbitrary strings, binary data, or truncated payloads.$runner->fuzz($callback, [
'seeds' => ['{ "key": "value" }', '[1,2,3]', ''],
]);
--corpus to save discovered inputs that trigger new execution paths, enabling iterative refinement.error_log() for debugging.max_execution_time or memory limits. Use CLI-specific settings (php -d max_execution_time=0) or wrap in pcntl_fork() for isolation.gdb -- php test_repro.php).--ext=... to test specific extensions (e.g., curl, intl) by constructing inputs that trigger extension functions in edge cases.E_WARNING in parse_url() on invalid URIs) using custom exception handlers or try/catch with ignore_warnings settings.How can I help you explore Laravel packages today?