Skip to content

Commit 3a59d0c

Browse files
committed
Add WebKitFuzz
1 parent c3fe850 commit 3a59d0c

2 files changed

Lines changed: 460 additions & 0 deletions

File tree

WebKitFuzz/README.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
### WebKit Fuzzing
2+
3+
webkit.patch is a patch file that makes it easier to build WebKitGTK+ with ASan and Fuzz it.
4+
5+
The patch file was made with WebKitGTK+ version 2.20.2 (https://webkitgtk.org/releases/webkitgtk-2.20.2.tar.xz) and might not work as is on other versions.
6+
7+
List of changes:
8+
9+
- Fixes to be able to build WebKitGTK+ with ASan
10+
11+
- Changed window.alert() implementation to immediately call the garbage collector instead of displaying a message window.
12+
13+
- As soon as any web process crashes, exit the main process with the same exit code.
14+
15+
- Created a custom target binary (webkitfuzz)
16+
17+
After applying the patch, you can build using the following commands:
18+
19+
```
20+
export CC=/usr/bin/clang
21+
export CXX=/usr/bin/clang++
22+
export CFLAGS="-fsanitize=address"
23+
export CXXFLAGS="-fsanitize=address"
24+
export LDFLAGS="-fsanitize=address"
25+
export ASAN_OPTIONS="detect_leaks=0"
26+
27+
mkdir build
28+
cd build
29+
30+
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=. -DCMAKE_SKIP_RPATH=ON -DPORT=GTK -DLIB_INSTALL_DIR=./lib -DUSE_LIBHYPHEN=OFF -DENABLE_MINIBROWSER=ON -DUSE_SYSTEM_MALLOC=ON -DENABLE_GEOLOCATION=OFF -DENABLE_GTKDOC=OFF -DENABLE_INTROSPECTION=OFF -DENABLE_OPENGL=OFF -DENABLE_ACCELERATED_2D_CANVAS=OFF -DENABLE_CREDENTIAL_STORAGE=OFF -DENABLE_GAMEPAD_DEPRECATED=OFF -DENABLE_MEDIA_STREAM=OFF -DENABLE_WEB_RTC=OFF -DENABLE_PLUGIN_PROCESS_GTK2=OFF -DENABLE_SPELLCHECK=OFF -DENABLE_VIDEO=OFF -DENABLE_WEB_AUDIO=OFF -DUSE_LIBNOTIFY=OFF -DENABLE_SUBTLE_CRYPTO=OFF -DUSE_WOFF2=OFF -Wno-dev ..
31+
32+
make -j 4
33+
34+
mkdir -p libexec/webkit2gtk-4.0
35+
cp bin/WebKit*Process libexec/webkit2gtk-4.0/
36+
37+
```
38+
39+
And install dependencies when it complains. Note that some of the dependencies were already removed via `-DENABLE_...=OFF` flags. These flags are mosly not necessary, but you will need to install additional dependencies if you remove them.
40+
41+
After it builds, you can run the fuzzer binary as:
42+
43+
`ASAN_OPTIONS=detect_leaks=0,exitcode=42 ASAN_SYMBOLIZER_PATH=/path/to/llvm-symbolizer LD_LIBRARY_PATH=./lib ./bin/webkitfuzz /path/to/sample <timeout>`
44+
45+
Note that exit code 42 will indicate an ASan crash.
46+

0 commit comments

Comments
 (0)