address sanitizer

Other Community

Skill notes

Overview

ASan is a standard practice in fuzzing due to its effectiveness in identifying memory vulnerabilities. It instruments code at compile time to track memory allocations and accesses, detecting illegal operations at runtime.

Key Concepts

Concept · Description Instrumentation · ASan adds runtime checks to memory operations during compilation Shadow Memory · Maps 20TB of virtual memory to track allocation state Performance Cost · Approximately 2-4x slowdown compared to non-instrumented code Detection Scope · Finds buffer overflows, use-after-free, double-free, and memory leaks

When to Apply

Apply this technique when: Fuzzing C/C++ code for memory safety vulnerabilities Testing Rust code with unsafe blocks Debugging crashes related to memory corruption Running unit tests where memory errors are suspected

Quick Reference

Task · Command/Pattern Enable ASan (Clang/GCC) · -fsanitize=address Enable verbosity · ASAN_OPTIONS=verbosity=1 Disable leak detection · ASAN_OPTIONS=detect_leaks=0 Force abort on error · ASAN_OPTIONS=abort_on_error=1

Step 1: Compile with ASan

Compile and link your code with the -fsanitize=address flag: The -g flag is recommended to get better stack traces when ASan detects errors.

Fluxly profile Runtime and permissions are inferred by Fluxly static checks, not author declarations or runtime test results.
Domain
Other
Author-declared agents
No explicit declaration found; this is not inferred or tested compatibility
Static check
88 / 100 · heuristic scan, not runtime safety proof
Runtime evidence
Not run; no isolated runtime test evidence is currently recorded
Author / version / license
@trailofbits · no license declared
Token usage
Lean
Setup complexity
Guided setup
External API key
Not required
Operating systems
macOS · Linux · Windows
Runtime requirements
No explicit requirements detected
Detected file/system behavior
  • Read-only
  • Write / modify
  • Shell exec
  • Env read
Network behavior
Local-only
Install commands
None (reference only)

Heads up: Tool permissions are not declared; actual access depends on the runtime.

01
Step 1: Compile with ASan

Compile and link your code with the `-fsanitize=address` flag: The `-g` flag is recommended to get better stack traces when ASan detects errors.

02
Step 2: Configure ASan Options

Set the `ASAN_OPTIONS` environment variable to configure ASan behavior:

03
Step 3: Run Your Program

Execute the ASan-instrumented binary. When memory errors are detected, ASan will print detailed reports:

04
Step 4: Adjust Fuzzer Memory Limits

ASan requires approximately 20TB of virtual memory. Disable fuzzer memory restrictions: libFuzzer: `-rss_limit_mb=0` AFL++: `-m none`

Discussion

Powered by GitHub Discussions. Sign in with GitHub to comment, react, or subscribe.