Chuyển đến nội dung
Skillpedia
Kiểm thử8.0k · #12718

fuzzing-obstacles

Skill này làm gì

Skill này thay đổi chương trình chỉ trong các bản build dùng để fuzzing, để fuzzer vượt qua các kiểm tra như checksum và seed ngẫu nhiên. Skill dành cho lập trình viên thấy fuzzer bị kẹt ở bước xác thực đầu tiên.

Khi nào nên dùng

  • ✓Khi fuzzer liên tục thất bại ở một bước kiểm tra checksum hoặc hash trước khi tới code thật.
  • ✓Khi chương trình dùng thời gian hệ thống hoặc số ngẫu nhiên khiến kết quả fuzzing không lặp lại được.
  • ✓Khi độ phủ cho thấy các vùng code lớn bị chặn sau một kiểm tra xác thực duy nhất.

Liên kết skill

https://github.com/trailofbits/skills/blob/main/plugins/testing-handbook-skills/skills/fuzzing-obstacles/SKILL.md

Sao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.

Cách dùng

Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.

Tin nhắn có sẵn để dán

Hãy dùng skill này để giúp tôi: https://github.com/trailofbits/skills/blob/main/plugins/testing-handbook-skills/skills/fuzzing-obstacles/SKILL.md Đọc tệp SKILL.md tại liên kết đó và làm theo hướng dẫn cho việc của tôi.
Bạn muốn AI tự tìm những skill như thế này?Cài MCP Skillpedia miễn phí: chỉ một dòng, và AI sẽ tìm trong 15.000+ skill trước mỗi việc.Cài đặt trong 1 phút →

Ví dụ cách nhờ AI

“Fuzzer của tôi bị kẹt ở bước kiểm tra checksum trong trình đọc file định dạng. Bạn có thể giúp tôi vượt qua nó chỉ trong lúc fuzzing không?”

5 skill mới mỗi tuần. Đọc chỉ 1 phút.

Cách hoạt động

Agent tìm kiểm tra đang chặn, rồi bọc nó trong một điều kiện chỉ có hiệu lực trong bản build fuzzing. Hành vi production vẫn giữ nguyên, và skill cảnh báo về các dương tính giả mà bản vá có thể gây ra.

Nội dung kỹ thuật (SKILL.md gốc)

Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.

Overcoming Fuzzing Obstacles

Codebases often contain anti-fuzzing patterns that prevent effective coverage. Checksums, global state (like time-seeded PRNGs), and validation checks can block the fuzzer from exploring deeper code paths. This technique shows how to patch your System Under Test (SUT) to bypass these obstacles during fuzzing while preserving production behavior.

Overview

Many real-world programs were not designed with fuzzing in mind. They may:

  • Verify checksums or cryptographic hashes before processing input
  • Rely on global state (e.g., system time, environment variables)
  • Use non-deterministic random number generators
  • Perform complex validation that makes it difficult for the fuzzer to generate valid inputs

These patterns make fuzzing difficult because:

  1. Checksums: The fuzzer must guess correct hash values (astronomically unlikely)
  2. Global state: Same input produces different behavior across runs (breaks determinism)
  3. Complex validation: The fuzzer spends effort hitting validation failures instead of exploring deeper code

The solution is conditional compilation: modify code behavior during fuzzing builds while keeping production code unchanged.

Key Concepts

Concept Description
SUT Patching Modifying System Under Test to be fuzzing-friendly
Conditional Compilation Code that behaves differently based on compile-time flags
Fuzzing Build Mode Special build configuration that enables fuzzing-specific patches
False Positives Crashes found during fuzzing that cannot occur in production
Determinism Same input always produces same behavior (critical for fuzzing)

When to Apply

Apply this technique when:

  • The fuzzer gets stuck at checksum or hash verification
  • Coverage reports show large blocks of unreachable code behind validation
  • Code uses time-based seeds or other non-deterministic global state
  • Complex validation makes it nearly impossible to generate valid inputs
  • You see the fuzzer repeatedly hitting the same validation failures

Skip this technique when:

  • The obstacle can be overcome with a good seed corpus or dictionary
  • The validation is simple enough for the fuzzer to learn (e.g., magic bytes)
  • You're doing grammar-based or structure-aware fuzzing that handles validation
  • Skipping the check would introduce too many false positives
  • The code is already fuzzing-friendly

Quick Reference

Task C/C++ Rust
Check if fuzzing build #ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION cfg!(fuzzing)
Skip check during fuzzing #ifndef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION return -1; #endif if !cfg!(fuzzing) { return Err(...) }
Common obstacles Checksums, PRNGs, time-based logic Checksums, PRNGs, time-based logic
Supported fuzzers libFuzzer, AFL++, LibAFL, honggfuzz cargo-fuzz, libFuzzer

Step-by-Step

Step 1: Identify the Obstacle

Run the fuzzer and analyze coverage to find code that's unreachable. Common patterns:

  1. Look for checksum/hash verification before deeper processing
  2. Check for calls to rand(), time(), or srand() with system seeds
  3. Find validation functions that reject most inputs
  4. Identify global state initialization that differs across runs

Tools to help:

  • Coverage reports (see coverage-analysis technique)
  • Profiling with -fprofile-instr-generate
  • Manual code inspection of entry points

Step 2: Add Conditional Compilation

Modify the obstacle to bypass it during fuzzing builds.

C/C++ Example:

// Before: Hard obstacle
if (checksum != expected_hash) {
    return -1;  // Fuzzer never gets past here
}

// After: Conditional bypass
if (checksum != expected_hash) {
#ifndef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
    return -1;  // Only enforced in production
#endif
}
// Fuzzer can now explore code beyond this check

Rust Example:

// Before: Hard obstacle
if checksum != expected_hash {
    return Err(MyError::Hash);  // Fuzzer never gets past here
}

// After: Conditional bypass
if checksum != expected_hash {
    if !cfg!(fuzzing) {
        return Err(MyError::Hash);  // Only enforced in production
    }
}
// Fuzzer can now explore code beyond this check

Step 3: Verify Coverage Improvement

After patching:

  1. Rebuild with fuzzing instrumentation
  2. Run the fuzzer for a short time
  3. Compare coverage to the unpatched version
  4. Confirm new co
Câu hỏi thường gặp

Bản vá có thay đổi phiên bản phát hành không?

Không. Thay đổi chỉ giới hạn trong các bản build fuzzing thông qua biên dịch có điều kiện.

Bản vá có thể tạo ra lỗi giả không?

Có thể. Skill cảnh báo về dương tính giả và giải thích cách kiểm tra chúng.

Skill bao gồm những loại chướng ngại nào?

Checksum, kiểm tra hash, giá trị magic, seed theo thời gian và các trạng thái toàn cục không xác định khác.

Chi tiết

Mô tả gốc của tác giả

Patches past the barriers that stop a fuzzer making progress — checksum and hash verification, magic-value validation, time-based seeds, and other non-deterministic global state. Covers locating the blocking check, neutering it behind a fuzzing build flag, and avoiding the false positives a patch can introduce. Use when a fuzzer is stuck at validation, when coverage shows large regions behind a checksum, or when valid inputs are impractical to generate.

repo: trailofbits/skills

Độ phổ biến

Sao GitHub
8.0k
Vị trí xếp hạng
#12718
Giấy phép
CC-BY-SA-4.0
Cập nhật
2/11/2026

Skill này có hữu ích không?

0

Đăng nhập để bình chọn.

Bình luận

  • …

Thêm skill từ kho mã này

Skill tương tự