Skip to content

Commit 939b139

Browse files
committed
Add fuzzing infrastructure for improved security testing
- Initialize cargo-fuzz with 5 fuzz targets - Target critical protocol parsing areas (MySQL, PostgreSQL) - Focus on RUSTSEC-2024-0363 vulnerability area - Add fuzzing helper scripts for development - Configure workspace to exclude fuzz directory Fuzzing targets: - fuzz_mysql_lenenc: MySQL length-encoded integer parsing - fuzz_mysql_row_binary: Binary protocol row parsing - fuzz_mysql_handshake: Connection handshake parsing - fuzz_postgres_data_row: PostgreSQL data row parsing - fuzz_postgres_response: Error/notice response parsing This infrastructure enables continuous fuzzing to discover security vulnerabilities and protocol misinterpretation issues. Contributed by: Jared Reyes
1 parent 7248f64 commit 939b139

14 files changed

+2175
-0
lines changed

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ members = [
2525
"examples/sqlite/todos",
2626
"examples/sqlite/extension",
2727
]
28+
exclude = ["fuzz"]
2829

2930
[workspace.package]
3031
version = "0.9.0-alpha.1"

check_fuzzing_status.sh

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
#!/bin/bash
2+
3+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
4+
LOG_DIR="$SCRIPT_DIR/fuzz_logs"
5+
6+
echo "🔍 Fuzzing Status Check"
7+
echo "======================="
8+
echo ""
9+
10+
TARGETS=(
11+
"fuzz_arg_parser"
12+
"fuzz_shell_completion"
13+
"fuzz_help_generator"
14+
"fuzz_value_parser"
15+
"fuzz_subcommand_parser"
16+
"fuzz_env_parser"
17+
)
18+
19+
RUNNING_COUNT=0
20+
for TARGET in "${TARGETS[@]}"; do
21+
PID=$(pgrep -f "cargo-fuzz.*$TARGET" || true)
22+
if [ -n "$PID" ]; then
23+
echo "✅ Fuzzer $((++RUNNING_COUNT)) (PID $PID): RUNNING"
24+
else
25+
echo "❌ Fuzzer for $TARGET: NOT RUNNING"
26+
fi
27+
done
28+
29+
echo ""
30+
echo "Summary: $RUNNING_COUNT/6 fuzzers running"
31+
echo ""
32+
33+
echo "📊 Latest Stats:"
34+
echo "==============="
35+
echo ""
36+
37+
for TARGET in "${TARGETS[@]}"; do
38+
LOG_FILE=$(ls -t "$LOG_DIR/${TARGET}_"*.log 2>/dev/null | head -1)
39+
if [ -n "$LOG_FILE" ] && [ -f "$LOG_FILE" ]; then
40+
echo "$TARGET:"
41+
tail -100 "$LOG_FILE" | grep "^#" | tail -3 || echo " No stats yet"
42+
echo ""
43+
fi
44+
done
45+
46+
echo "💥 Crashes Found:"
47+
echo "================="
48+
49+
CRASH_DIR="$SCRIPT_DIR/fuzz/artifacts"
50+
if [ -d "$CRASH_DIR" ]; then
51+
CRASH_COUNT=$(find "$CRASH_DIR" -type f -name "crash-*" -o -name "leak-*" -o -name "timeout-*" 2>/dev/null | wc -l | tr -d ' ')
52+
if [ "$CRASH_COUNT" -gt 0 ]; then
53+
echo " Found $CRASH_COUNT crash(es)!"
54+
find "$CRASH_DIR" -type f \( -name "crash-*" -o -name "leak-*" -o -name "timeout-*" \) 2>/dev/null
55+
else
56+
echo " None found yet (keep running!)"
57+
fi
58+
else
59+
echo " None found yet (keep running!)"
60+
fi

fuzz/.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
target
2+
corpus
3+
artifacts
4+
coverage

0 commit comments

Comments
 (0)