Skip to content

Commit 74d0587

Browse files
committed
wasm-fuzzers: support docker in place of podman, refactoring
1 parent faf5c73 commit 74d0587

14 files changed

+63
-201
lines changed

README.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ Note: We have not evaluated the effectiveness of these passes yet.
7878
- Exits if a crash is found
7979
- No core pinning
8080
- Does not support LibAFL-style network scaling (we use simple ad-hoc in-process message passing and structure sharing, no `llmp`)
81-
- Only partial support of WebAssembly 2.0 features. (Does not support the _Component Model_)
81+
- No support for the WebAssembly 2.0 _Component Model_.
8282

8383
## Harness Suite ([./harness-suite/](./harness-suite/))
8484

@@ -92,6 +92,8 @@ Building these requires a Docker/Podman and Python installation. Use `make -C ha
9292

9393
- Optimized builds with full debug info: Harness modules also contain their source code so we can emit coverage reports without any additional files.
9494

95+
We target the [Lime1](https://github.com/WebAssembly/tool-conventions/blob/main/Lime.md#lime1) series of WebAssembly, which is WebAssembly 1.0 in combination with a few standardized post-1.0 features like the `bulk-memory-opt` extension.
96+
9597

9698
## WASM Variants of Other Fuzzers ([./wasm-fuzzers/](./wasm-fuzzers/))
9799

harness-suite/make-one.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
tag = f"wasmfuzz-builder-{name}"
1111
cid = f"{tag}-extract"
1212

13-
PODMAN = "podman" if shutil.which("podman") else "docker"
13+
PODMAN = os.environ.get("PODMAN", "podman" if shutil.which("podman") else "docker")
1414

1515
subprocess.run([
1616
PODMAN, "build",

wasm-fuzzers/Dockerfile

-63
This file was deleted.

wasm-fuzzers/Dockerfile.aflpp-w2c2

+2-4
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,8 @@ WORKDIR /AFLplusplus
2222
RUN make NO_NYX=1 IS_DOCKER=1 install
2323

2424
WORKDIR /
25-
COPY afl++-w2c2.sh /usr/bin/
26-
RUN chmod +x /usr/bin/afl++-w2c2.sh
27-
ENV AFL_SKIP_CPUFREQ=1
28-
ENV AFL_I_DONT_CARE_ABOUT_MISSING_CRASHES=1
25+
COPY afl++-w2c2.sh run-afl-fuzz.sh /usr/bin/
26+
RUN chmod +x /usr/bin/afl++-w2c2.sh /usr/bin/run-afl-fuzz.sh
2927

3028
RUN mkdir -p /seeds/ && echo -n "YELLOW SUBMARINE" > /seeds/seed && mkdir -p /corpus/
3129
ENTRYPOINT [ "afl++-w2c2.sh" ]

wasm-fuzzers/Dockerfile.aflpp-wasm2c

+2-4
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,8 @@ WORKDIR /AFLplusplus
2222
RUN make NO_NYX=1 IS_DOCKER=1 install
2323

2424
WORKDIR /
25-
COPY afl++-wasm2c.sh /usr/bin/
26-
RUN chmod +x /usr/bin/afl++-wasm2c.sh
27-
ENV AFL_SKIP_CPUFREQ=1
28-
ENV AFL_I_DONT_CARE_ABOUT_MISSING_CRASHES=1
25+
COPY afl++-wasm2c.sh run-afl-fuzz.sh /usr/bin/
26+
RUN chmod +x /usr/bin/afl++-wasm2c.sh /usr/bin/run-afl-fuzz.sh
2927

3028
RUN mkdir -p /seeds/ && echo -n "YELLOW SUBMARINE" > /seeds/seed && mkdir -p /corpus/
3129
ENTRYPOINT [ "afl++-wasm2c.sh" ]

wasm-fuzzers/Dockerfile.fuzzm

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ RUN wget https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-11/w
1616
tar xvf wasi-sdk-11.0-linux.tar.gz
1717
RUN cd AFL-wasm && make install
1818

19-
COPY fuzzm.sh /usr/bin/fuzzm.sh
20-
RUN chmod +x /usr/bin/fuzzm.sh
19+
COPY fuzzm.sh run-afl-fuzz.sh /usr/bin/fuzzm.sh
20+
RUN chmod +x /usr/bin/fuzzm.sh /usr/bin/run-afl-fuzz.sh
2121
WORKDIR /
2222
ENTRYPOINT [ "fuzzm.sh" ]

wasm-fuzzers/Dockerfile.wafl

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ RUN ninja && ninja install && \
3838
patchelf --add-needed /usr/local/lib/libWAVM.so /usr/local/bin/wavm
3939

4040
WORKDIR /
41-
COPY wafl.sh shim-for-wafl.sh /usr/bin/
42-
RUN chmod +x /usr/bin/wafl.sh /usr/bin/shim-for-wafl.sh
41+
COPY wafl.sh shim-for-wafl.sh run-afl-fuzz.sh /usr/bin/
42+
RUN chmod +x /usr/bin/wafl.sh /usr/bin/shim-for-wafl.sh /usr/bin/run-afl-fuzz.sh
4343
RUN mkdir -p /seeds/ && echo -n "YELLOW SUBMARINE" > /seeds/seed && mkdir -p /corpus/
4444
ENTRYPOINT [ "wafl.sh" ]

wasm-fuzzers/Dockerfile.wasmfuzz

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
# ubuntu:24.04 is rustc 1.75
22
# ubuntu:24.10 is rustc 1.80
3+
# ubuntu:25.04 is rustc 1.81
34
# libafl needs 1.82 for `&raw const GLOBAL_MUT`
4-
5-
FROM ubuntu:24.04
5+
FROM ubuntu:24.04 AS builder
66
RUN apt-get update && apt-get install -y rustup git clang
77
RUN rustup toolchain add 1.82 --no-self-update
88
RUN git clone https://github.com/CISPA-SysSec/wasmfuzz && git -C wasmfuzz checkout ac17ec0ce7cfd7d5988cf6bb76418b3219def4fe
9-
RUN cargo install --no-default-features --path /wasmfuzz && ln -s /root/.cargo/bin/wasmfuzz /usr/bin/
9+
RUN cargo install --locked --no-default-features --path /wasmfuzz
10+
11+
FROM ubuntu:24.04
12+
COPY --from=builder /root/.cargo/bin/wasmfuzz /usr/bin/
1013
COPY wasmfuzz.sh /usr/bin/
1114
RUN chmod +x /usr/bin/wasmfuzz.sh
1215
RUN mkdir -p /seeds/ && echo -n "YELLOW SUBMARINE" > /seeds/seed && mkdir -p /corpus/

wasm-fuzzers/Makefile

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
PODMAN_BUILD := podman build --cache-ttl=72h
2-
FUZZERS := libfuzzer-wasm2c libfuzzer-w2c2 aflpp-wasm2c aflpp-w2c2 libafl-libfuzzer-wasm2c wasmfuzz wafl fuzzm
1+
PODMAN_BUILD ?= podman build --cache-ttl=72h
2+
FUZZERS := libfuzzer-wasm2c libfuzzer-w2c2 aflpp-wasm2c aflpp-w2c2 libafl-libfuzzer-wasm2c wasmfuzz wasmfuzz-rel wafl
3+
# fuzzm
34

45
.PHONY: all $(FUZZERS) wasm-fuzzers-wasm2c-base wasm-fuzzers-w2c2-base
56
# $(addprefix wasm-fuzzers-,$(FUZZERS))

wasm-fuzzers/afl++-w2c2.sh

+2-30
Original file line numberDiff line numberDiff line change
@@ -5,34 +5,6 @@ name=`basename $1`
55

66
source prepare-w2c2-fuzzer.sh "$1"
77

8-
export AFL_LLVM_CMPLOG=1
8+
AFL_LLVM_CMPLOG=1 afl-clang-fast -O2 -g -o "$name-fuzzer" $CC_CMD
99

10-
afl-clang-fast -O2 -g -o "$name-fuzzer" $CC_CMD
11-
12-
export AFL_SKIP_CPUFREQ=1 AFL_I_DONT_CARE_ABOUT_MISSING_CRASHES=1 AFL_NO_AFFINITY=1
13-
14-
export AFL_BENCH_UNTIL_CRASH=1
15-
16-
function sync() {
17-
while true; do
18-
rsync -r /sync/default/queue/ /corpus/ --exclude=".state"
19-
rsync -r /sync/default/crashes/ /corpus/ --exclude="README.txt"
20-
sleep 5
21-
done
22-
}
23-
mkdir -p /sync/
24-
sync &
25-
26-
afl-fuzz -G 4096 -i /seeds -o /sync -M default -c "./$name-fuzzer" -- "./$name-fuzzer" &
27-
pids["1"]=$!
28-
for i in $(seq 2 "${FUZZER_CORES:-1}")
29-
do
30-
afl-fuzz -G 4096 -i /seeds -o /sync -S "core-$i" -c "./$name-fuzzer" -- "./$name-fuzzer" > /dev/null &
31-
pids[${i}]=$!
32-
done
33-
for pid in ${pids[*]}; do
34-
wait $pid
35-
done
36-
37-
rsync -r /sync/default/queue/ /corpus/ --exclude=".state"
38-
rsync -r /sync/default/crashes/ /corpus/ --exclude="README.txt"
10+
run-afl-fuzz.sh -c "./$name-fuzzer" -- "./$name-fuzzer"

wasm-fuzzers/afl++-wasm2c.sh

+2-30
Original file line numberDiff line numberDiff line change
@@ -5,34 +5,6 @@ name=`basename $1`
55

66
source prepare-wasm2c-fuzzer.sh "$1"
77

8-
export AFL_LLVM_CMPLOG=1
8+
AFL_LLVM_CMPLOG=1 afl-clang-fast -O2 -g -o "$name-fuzzer" $CC_CMD
99

10-
afl-clang-fast -O2 -g -o "$name-fuzzer" $CC_CMD
11-
12-
export AFL_SKIP_CPUFREQ=1 AFL_I_DONT_CARE_ABOUT_MISSING_CRASHES=1 AFL_NO_AFFINITY=1
13-
14-
export AFL_BENCH_UNTIL_CRASH=1
15-
16-
function sync() {
17-
while true; do
18-
rsync -r /sync/default/queue/ /corpus/ --exclude=".state"
19-
rsync -r /sync/default/crashes/ /corpus/ --exclude="README.txt"
20-
sleep 5
21-
done
22-
}
23-
mkdir -p /sync/
24-
sync &
25-
26-
afl-fuzz -G 4096 -i /seeds -o /sync -M default -c "./$name-fuzzer" -- "./$name-fuzzer" &
27-
pids["1"]=$!
28-
for i in $(seq 2 "${FUZZER_CORES:-1}")
29-
do
30-
afl-fuzz -G 4096 -i /seeds -o /sync -S "core-$i" -c "./$name-fuzzer" -- "./$name-fuzzer" > /dev/null &
31-
pids[${i}]=$!
32-
done
33-
for pid in ${pids[*]}; do
34-
wait $pid
35-
done
36-
37-
rsync -r /sync/default/queue/ /corpus/ --exclude=".state"
38-
rsync -r /sync/default/crashes/ /corpus/ --exclude="README.txt"
10+
run-afl-fuzz.sh -c "./$name-fuzzer" -- "./$name-fuzzer"

wasm-fuzzers/fuzzm.sh

+3-31
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,9 @@ set -e
44
target="$1"
55
name=`basename $1`
66

7-
export AFL_SKIP_CPUFREQ=1 AFL_I_DONT_CARE_ABOUT_MISSING_CRASHES=1 AFL_SKIP_BIN_CHECK=1
7+
export AFL_SKIP_BIN_CHECK=1
88
export __AFL_PERSISTENT=1 __AFL_SHM_FUZZ=1 AFL_FORKSRV_INIT_TMOUT=9999999
9-
export AFL_NO_AFFINITY=1
10-
11-
12-
export WASM_MODE=1 AFL_SKIP_CPUFREQ=1 AFL_I_DONT_CARE_ABOUT_MISSING_CRASHES=1
9+
export WASM_MODE=1
1310

1411

1512

@@ -21,30 +18,5 @@ afl_branch "$target" "/tmp/$name-cov.wasm"
2118

2219
# shim-for-wafl.sh "$target" "/tmp/$name-wafl.wasm"
2320

24-
function sync() {
25-
while true; do
26-
rsync -r /sync/default/queue/ /corpus/ --exclude=".state"
27-
sleep 5
28-
done
29-
}
30-
mkdir -p /sync/
31-
sync &
32-
33-
34-
# LD_LIBRARY_PATH=../AFL-wasm/wasmtime-v0.20.0-x86_64-linux-c-api/lib/ ../public-project-repo/fuzzm-project/AFL-wasm/afl-fuzz -i testcases/ -o findings ./vuln-cov-canaries.wasm
35-
21+
run-afl-fuzz.sh "/tmp/$name-cov.wasm"
3622

37-
if [ "$FUZZER_CONFIG" == "multicore" ]; then
38-
afl-fuzz -G 4096 -i /seeds -o /sync -M default "/tmp/$name-cov.wasm" &
39-
pids["1"]=$!
40-
for i in {2..8}
41-
do
42-
afl-fuzz -G 4096 -i /seeds -o /sync -S "core-$i" "/tmp/$name-cov.wasm" > /dev/null &
43-
pids[${i}]=$!
44-
done
45-
for pid in ${pids[*]}; do
46-
wait $pid
47-
done
48-
else
49-
afl-fuzz -G 4096 -i /seeds -o /sync "/tmp/$name-cov.wasm"
50-
fi

wasm-fuzzers/run-afl-fuzz.sh

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/usr/bin/env bash
2+
set -e
3+
4+
export AFL_SKIP_CPUFREQ=1
5+
export AFL_I_DONT_CARE_ABOUT_MISSING_CRASHES=1
6+
export AFL_NO_AFFINITY=1
7+
export AFL_BENCH_UNTIL_CRASH=1
8+
9+
function syncOne() {
10+
rsync -r /sync/default/queue/ /corpus/ --exclude=".state" --chmod=ugo=rwX
11+
rsync -r /sync/default/crashes/ /corpus/ --exclude="README.txt" --chmod=ugo=rwX
12+
}
13+
function syncForever() {
14+
while true; do
15+
syncOne; sleep 5
16+
done
17+
}
18+
19+
mkdir -p /sync/
20+
syncForever &
21+
22+
afl-fuzz -G 4096 -i /seeds -o /sync -M default $@ &
23+
pids["1"]=$!
24+
for i in $(seq 2 "${FUZZER_CORES:-1}")
25+
do
26+
afl-fuzz -G 4096 -i /seeds -o /sync -S "core-$i" $@ > /dev/null &
27+
pids[${i}]=$!
28+
done
29+
for pid in ${pids[*]}; do
30+
wait $pid
31+
done
32+
33+
syncOne

wasm-fuzzers/wafl.sh

+2-28
Original file line numberDiff line numberDiff line change
@@ -4,35 +4,9 @@ set -e
44
target="$1"
55
name=`basename $1`
66

7-
export AFL_SKIP_CPUFREQ=1 AFL_I_DONT_CARE_ABOUT_MISSING_CRASHES=1 AFL_SKIP_BIN_CHECK=1
7+
export AFL_SKIP_BIN_CHECK=1
88
export __AFL_PERSISTENT=1 __AFL_SHM_FUZZ=1 AFL_FORKSRV_INIT_TMOUT=9999999
9-
export AFL_NO_AFFINITY=1
109

1110
shim-for-wafl.sh "$target" "/tmp/$name-wafl.wasm"
1211

13-
export AFL_BENCH_UNTIL_CRASH=1
14-
15-
function sync() {
16-
while true; do
17-
rsync -r /sync/default/queue/ /corpus/ --exclude=".state"
18-
rsync -r /sync/default/crashes/ /corpus/ --exclude="README.txt"
19-
sleep 30
20-
done
21-
}
22-
mkdir -p /sync/
23-
sync &
24-
25-
26-
afl-fuzz -G 4096 -i /seeds -o /sync -M default wavm run "/tmp/$name-wafl.wasm" &
27-
pids["1"]=$!
28-
for i in $(seq 2 "${FUZZER_CORES:-1}")
29-
do
30-
afl-fuzz -G 4096 -i /seeds -o /sync -S "core-$i" wavm run "/tmp/$name-wafl.wasm" > /dev/null &
31-
pids[${i}]=$!
32-
done
33-
for pid in ${pids[*]}; do
34-
wait $pid
35-
done
36-
37-
rsync -r /sync/default/queue/ /corpus/ --exclude=".state"
38-
rsync -r /sync/default/crashes/ /corpus/ --exclude="README.txt"
12+
run-afl-fuzz.sh wavm run "/tmp/$name-wafl.wasm"

0 commit comments

Comments
 (0)