Engineering
address-sanitizer avatar

address-sanitizer

Detects memory errors such as buffer overflows and use-after-free during fuzzing. Provides compilation patterns and runtime configuration for C/C++ memory safety.

Introduction

AddressSanitizer (ASan) is a critical instrumentation tool for identifying memory corruption vulnerabilities during the software testing lifecycle, specifically within fuzzing workflows. It is designed for developers and security researchers working with C/C++ codebases who need to proactively discover flaws that typically remain hidden during standard execution, such as heap-buffer-overflows, use-after-free, double-free, and memory leaks. By instrumenting code at compile time, ASan tracks memory allocation and access patterns with high precision, providing detailed stack traces and report data when illegal operations occur at runtime.

  • Instruments binaries using Clang or GCC via the -fsanitize=address flag for comprehensive memory safety monitoring during test execution.

  • Configures runtime behavior through the ASAN_OPTIONS environment variable, supporting verbosity controls, leak detection toggles, and abort-on-error triggers.

  • Optimized for deep integration with popular fuzzing engines like libFuzzer and AFL++, including specific guidance for disabling memory limits (e.g., -rss_limit_mb=0 or -m none) to accommodate the 20TB virtual memory mapping requirements.

  • Provides detailed diagnostic output containing error types, allocation/deallocation stack traces, and shadow memory state analysis for rapid root-cause debugging.

  • Supports advanced configurations including the combination of multiple sanitizers, such as -fsanitize=address,undefined, to detect broader classes of undefined behavior and security violations.

  • Apply this skill primarily during the development and testing phases; it is strictly discouraged for production use due to the approximately 2-4x performance overhead and potential security implications of the instrumentation.

  • Always compile with the -g debug flag to ensure ASan generates meaningful stack traces that reference actual source code lines.

  • Be aware that while ASan offers exceptional visibility on Linux, support on macOS and Windows may be limited or experimental, potentially affecting the reliability of reports on those platforms.

  • Use this for testing Rust code that utilizes unsafe blocks, as it can detect memory safety violations that arise during FFI or manual memory management.

  • Regularly review the generated reports for memory leaks or resource management issues that do not immediately crash the application but indicate architectural instability.

Repository Stats

Stars
4,856
Forks
421
Open Issues
29
Language
Python
Default Branch
main
Sync Status
Idle
Last Synced
Apr 28, 2026, 12:17 PM
View on GitHub