home / skills / plurigrid / asi / address-sanitizer

address-sanitizer skill

/skills/address-sanitizer

This skill helps you detect memory safety bugs in C/C++ by using AddressSanitizer to identify use-after-free, overflow, and leaks.

npx playbooks add skill plurigrid/asi --skill address-sanitizer

Review the files below or copy the command above to add this skill to your agents.

Files (1)
SKILL.md
1.4 KB
---
name: address-sanitizer
description: Use AddressSanitizer to detect memory safety bugs in C/C++ programs. Identifies use-after-free, buffer overflow, memory leaks, and other memory errors.
category: testing-handbook-skills
author: Trail of Bits
source: trailofbits/skills
license: AGPL-3.0
trit: -1
trit_label: MINUS
verified: true
featured: false
---

# Address Sanitizer Skill

**Trit**: -1 (MINUS)
**Category**: testing-handbook-skills
**Author**: Trail of Bits
**Source**: trailofbits/skills
**License**: AGPL-3.0

## Description

Use AddressSanitizer to detect memory safety bugs in C/C++ programs. Identifies use-after-free, buffer overflow, memory leaks, and other memory errors.

## When to Use

This is a Trail of Bits security skill. Refer to the original repository for detailed usage guidelines and examples.

See: https://github.com/trailofbits/skills

## Related Skills

- audit-context-building
- codeql
- semgrep
- variant-analysis


## SDF Interleaving

This skill connects to **Software Design for Flexibility** (Hanson & Sussman, 2021):

### Primary Chapter: 5. Evaluation

**Concepts**: eval, apply, interpreter, environment

### GF(3) Balanced Triad

```
address-sanitizer (○) + SDF.Ch5 (−) + [balancer] (+) = 0
```

**Skill Trit**: 0 (ERGODIC - coordination)


### Connection Pattern

Evaluation interprets expressions. This skill processes or generates evaluable forms.

Overview

This skill integrates AddressSanitizer to detect memory-safety bugs in C and C++ programs. It helps find use-after-free, heap and stack buffer overflows, uninitialized memory reads, and memory leaks during testing. The skill is intended for developers and testers aiming to harden native code with fast, compiler-assisted instrumentation.

How this skill works

The skill compiles programs or test harnesses with AddressSanitizer-enabled compiler flags (e.g., -fsanitize=address) and runs the instrumented binaries under typical test inputs or fuzzers. At runtime, the sanitizer intercepts memory accesses and allocation calls to detect violations and emits detailed diagnostics and stack traces. Outputs include error reports, source locations, and suggested fix points to speed triage and remediation.

When to use it

  • During unit and integration testing for C/C++ projects to catch memory bugs early.
  • Before release to validate native libraries, plugins, or performance-sensitive components.
  • When investigating crashes or intermittent memory-corruption symptoms in production reproductions.
  • Alongside fuzzing to turn crashes into actionable sanitizer reports.

Best practices

  • Build with debug symbols and disabled optimizations for clearer stack traces (e.g., -g -O1).
  • Run with representative inputs and test suites to exercise diverse code paths.
  • Combine AddressSanitizer with LeakSanitizer and UndefinedBehaviorSanitizer for broader coverage.
  • Limit long-running services; AddressSanitizer increases memory and CPU use—run in CI or targeted test jobs.
  • Suppress known benign reports with sanitizer suppression files to reduce noise during triage.

Example use cases

  • Run unit tests under AddressSanitizer to reveal out-of-bounds array accesses introduced by recent PRs.
  • Instrument a native addon to find a use-after-free causing sporadic crashes in production.
  • Integrate into CI for nightly runs so new memory errors are caught before merging.
  • Combine with a fuzzer to convert crash inputs into precise sanitizer diagnostics for faster fixes.

FAQ

Will AddressSanitizer work on all platforms?

AddressSanitizer supports major platforms and compilers (Clang, GCC) but has platform-specific limitations; check your toolchain docs for full compatibility.

Does using AddressSanitizer change program behavior?

Yes. Instrumentation alters memory layout and increases resource usage, so reproduce bugs under sanitizer builds rather than assuming identical behavior to production.