Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Environment:0sec labs 0 QEMU

From Leeroopedia
Knowledge Sources
Domains Binary_Analysis, Fuzzing, Emulation
Last Updated 2026-10-30 00:00 GMT

Overview

QEMU (via AFL++ `afl-qemu-trace`) for harness reproduction and QEMU-mode fuzzing of stripped binaries in the 0verse security review pipeline.

Description

QEMU is used by 0verse in two contexts: (1) AFL++ QEMU-mode fuzzing — for stripped binaries with no source, `afl-fuzz -Q` execs `afl-qemu-trace` to instrument the binary at runtime; (2) harness reproduction — Tier-2/3 C/C++ harness generation and validation runs binaries under QEMU for cross-arch testing. The `afl-qemu-trace` helper must be built separately from the AFL++ source tree (the Ubuntu `afl++` package does NOT ship it). It must be the same AFLplusplus version as `afl-fuzz` — version skew causes a fork-server deadlock, not an error message. Cross-arch QEMU-mode needs a per-arch trace built with `CPU_TARGET=<cpu> ./build_qemu_support.sh`.

Usage

Use this environment for the Harness_Reproduction stage of the Source Code Security Review workflow (Tier-2/3 harness validation) and for AFL++ QEMU-mode fuzzing of stripped binaries in the Binary Vulnerability Discovery workflow.

System Requirements

Category Requirement Notes
OS Linux QEMU and AFL++ are Linux tools
Hardware 8+ CPU cores, 16GB RAM Fuzzing is CPU-intensive
Disk 10GB AFL++ source tree + QEMU build + target binaries

Dependencies

System Packages

  • `afl-fuzz` and `afl-qemu-trace` (MUST be the same AFLplusplus version)
  • `qemu-user` (`qemu-mips`, `qemu-aarch64` for cross-arch emulation)
  • A C compiler (`gcc`/`clang`) for harness compilation

Build Requirements

  • AFL++ source tree (full clone, NOT shallow — `build_qemu_support.sh` runs `git checkout` which degrades on shallow clones)
  • QEMU source (via `qemu_mode/build_qemu_support.sh`)

Credentials

No credentials required. This is a local execution environment.

Quick Install

# Clone AFL++ FULL (not shallow)
git clone https://github.com/AFLplusplus/AFLplusplus.git
cd AFLplusplus

# Build afl-qemu-trace for host arch
./qemu_mode/build_qemu_support.sh

# For cross-arch (e.g., MIPS):
CPU_TARGET=mips ./qemu_mode/build_qemu_support.sh

# Verify version match
afl-fuzz --version
afl-qemu-trace --version  # MUST match

Code Evidence

QEMU-mode availability probe from `0verse/src/zeroverse/fuzz/aflpp.py:143-152`:

def afl_qemu_available(arch: str = "") -> bool:
    """QEMU-mode needs ``afl-qemu-trace`` (built separately from the AFL++ source
    tree; we degrade honestly when it is absent)."""
    if not arch:
        return afl_qemu_trace_path("") is not None
    if afl_qemu_trace_path(cpu) is not None:
        return True
    return arch == host_arch() and afl_qemu_trace_path("") is not None

QEMU-mode degradation when trace is missing from `0verse/src/zeroverse/fuzz/aflpp.py:575-579`:

if config.qemu_mode and self.qemu_path is None:
    which = config.qemu_arch or "host"
    # degrade honestly:
    note=f"QEMU-mode requested but afl-qemu-trace ({which}) is missing "
    "(build it via CPU_TARGET=<cpu> AFLplusplus/build_qemu_support.sh); "

AFL version skew warning from `0verse/AGENTS.md:92-96`:

`afl-fuzz` and `afl-qemu-trace` must be the same AFLplusplus version.
The failure is a deadlock, not an error message: 4.09c terminates the fork
server with SIGTERM, while an older `afl-compiler-rt` has an `at_exit` of
`kill(child_pid,9); ret` with no `_exit`, so the server survives and
afl-fuzz blocks forever in `waitpid` (#313).

Common Errors

Error Message Cause Solution
Fork-server deadlock (afl-fuzz blocks forever in `waitpid`) afl-fuzz and afl-qemu-trace version mismatch Rebuild both from the same AFLplusplus version
`QEMU-mode requested but afl-qemu-trace is missing` afl-qemu-trace not built Run `./qemu_mode/build_qemu_support.sh` from AFL++ source
Silent stall (no crash, no progress) Shallow AFL++ clone — `build_qemu_support.sh` degrades to master HEAD Re-clone AFL++ full (not shallow)
`kernel.core_pattern` pipe causes AFL stall Piped core_pattern downgrades AFL abort to silent stall pipe`

Compatibility Notes

  • Ubuntu afl++ package: Does NOT ship `afl-qemu-trace` — must be built from source.
  • Shallow clones: `build_qemu_support.sh` runs `git checkout $(cat QEMUAFL_VERSION)` which silently degrades on shallow clones. Clone full.
  • Cross-arch: Each target arch needs its own `afl-qemu-trace-<cpu>` built with `CPU_TARGET=<cpu>`.
  • kernel.core_pattern: Must not be a pipe (`|pipe`) — AFL aborts on one, but `AFL_I_DONT_CARE_ABOUT_MISSING_CRASHES` downgrades this to a silent stall.

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment