8000 fuzz: add libFuzzer harnesses and OSS-Fuzz build script for nstun and mount options by phenomenon0 · Pull Request #418 · google/nsjail · GitHub
[go: up one dir, main page]

Skip to content

fuzz: add libFuzzer harnesses and OSS-Fuzz build script for nstun and mount options - #418

Open
phenomenon0 wants to merge 1 commit into
google:masterfrom
phenomenon0:nstun-libfuzzer-ossfuzz
Open

phenomenon0 wants to merge 1 commit into
google:masterfrom
phenomenon0:nstun-libfuzzer-ossfuzz

Conversation

@phenomenon0
Copy link
Copy Markdown

Summary

Adds standalone, dependency-free libFuzzer harnesses (no protobuf or libnl required), seed corpora, a dictionary, Makefile targets (fuzz and fuzz-smoke), and an infra/oss-fuzz/build.sh script for nsjail's untrusted input parsers (addressing #309 part 2: libFuzzer / OSS-Fuzz).

Based directly on master with zero conflicts against #417:

  1. fuzz/nstun_packet_fuzzer.cc: Fuzzes nstun::handle_ip4(), nstun::handle_ip6(), skip_ipv6_ext_headers(), handle_udp4/6(), handle_icmp4/6(), and ICMP error/echo reply construction (send_to_guest_v() stub validates MTU bounds and touches every emitted byte for sanitizer coverage). Supports both raw malformed frames and a structure-aware checksum/source-IP fixup mode to reach deep L4/ICMP paths without creating real host sockets or leaking file descriptors.
  2. fuzz/nstun_encap_fuzzer.cc + fuzz/nstun_encap.dict: Fuzzes parse_socks5_auth_reply(), parse_socks5_connect_reply(), find_end_of_headers(), parse_http_connect_reply(), and socks5_udp_unwrap_for_flow() (IPv4 & IPv6) with subspan bounds invariants.
  3. fuzz/mnt_options_fuzzer.cc: Fuzzes mnt::extractGenericMountOptions() with VFS flag-isolation and idempotency invariants.
  4. fuzz/standalone_driver.cc + fuzz/corpus/: Standalone POSIX C++20 (-fno-exceptions) corpus runner + initial seed corpora so make fuzz-smoke works with GCC or Clang.
  5. infra/oss-fuzz/build.sh + Makefile: Standard OSS-Fuzz build script ($CXX $CXXFLAGS $LIB_FUZZING_ENGINE, *_seed_corpus.zip, .dict) and protobuf-free make fuzz / make fuzz-smoke targets.

Testing

  • make fuzz-smoke (GCC 15.2.1, -std=c++20 -fno-exceptions -Wall -Wextra -Werror, without protobuf/libnl): all 3 targets compiled with 0 warnings and passed all seed corpora (nstun_packet: 6 seeds, nstun_encap: 8 seeds, mnt_options: 4 seeds).
  • Verified infra/oss-fuzz/build.sh end-to-end (built all 3 binaries, packaged all 3 *_seed_corpus.zip archives, and installed nstun_encap_fuzzer.dict).
  • Executed 150,000 mutated stress-fuzz iterations (50,000 per target) with -D_GLIBCXX_ASSERTIONS -D_FORTIFY_SOURCE=3 -fstack-protector-strong: 0 crashes, 0 fd leaks.

… mount options

Add standalone, dependency-free libFuzzer targets (no protobuf or libnl required) and OSS-Fuzz packaging to address google#309 (part 2: libFuzzer / OSS-Fuzz):

- fuzz/nstun_packet_fuzzer.cc: fuzzes IPv4, IPv6, IPv6 extension-header chains, UDP4/6, ICMP4/6, and ICMP reply/error framing in both raw and structure-aware checksum/source-IP fixup modes with zero host socket creation.
- fuzz/nstun_encap_fuzzer.cc + fuzz/nstun_encap.dict: fuzzes SOCKS5 auth/connect reply parsing, HTTP CONNECT header framing/reply parsing, and SOCKS5 UDP IPv4/IPv6 unwrapping with subspan bounds invariants.
- fuzz/mnt_options_fuzzer.cc: fuzzes mnt::extractGenericMountOptions() with VFS flag-isolation and idempotency invariants.
- fuzz/standalone_driver.cc + fuzz/corpus/: standalone GCC/Clang corpus smoke runner and initial seed corpora.
- infra/oss-fuzz/build.sh + Makefile targets (fuzz, fuzz-smoke): OSS-Fuzz build script and protobuf-free Make targets.

Refs google#309.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

0