Token导航 LogoToken导航TokenDH.com
研究检索敏感数据github未标认证来源可访问clear审计通过

address-sanitizer地址消毒剂

Agent Skill

address-sanitizer 用于记录任务执行中的错误、用户纠正、经验和能力缺口,适合在 Codex、Claude、Cursor、Gemini CLI 中希望让 Agent 持续沉淀问题、修正和最佳实践时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

总安装

46,512

周安装

1,890

GitHub Stars

4,932

下载量

15,048
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

3

许可证

MIT

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:address-sanitizer(地址消毒剂)
来源仓库:https://github.com/trailofbits/skills
仓库路径:skills/address-sanitizer
安装命令:
npx skills add https://github.com/trailofbits/skills --skill address-sanitizer
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。不同来源提供的安装方式可能略有差异;本站展示可直接复制的安装命令,安装前请核对来源页面。

skills.shnpx skills
npx skills add https://github.com/trailofbits/skills --skill address-sanitizer

简介

通过编译时检测进行 C/C++ 模糊测试的内存错误检测。

  • 通过在编译时使用 -fsanitize=address 检测代码来检测缓冲区溢出、释放后使用、双重释放和内存泄漏
  • 旗帜
  • 需要大约20TB的虚拟内存;使用 -rss_limit_mb=0 禁用模糊器内存限制
  • (libFuzzer) 或 -m 无
  • (澳大利亚橄榄球联盟++)
  • 引入 2-4 倍的性能开销;最适合测试和模糊测试,而不是生产使用
  • 与 libFuzzer、AFL++、cargo-fuzz 和 honggfuzz 集成;通过 ASAN_OPTIONS 配置
  • 用于详细信息、泄漏检测和错误处理行为的环境变量

SKILL.md

AddressSanitizer (ASan)

AddressSanitizer (ASan) is a widely adopted memory error detection tool used extensively during software testing, particularly fuzzing. It helps detect memory corruption bugs that might otherwise go unnoticed, such as buffer overflows, use-after-free errors, and other memory safety violations.

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

ConceptDescription
InstrumentationASan adds runtime checks to memory operations during compilation
Shadow MemoryMaps 20TB of virtual memory to track allocation state
Performance CostApproximately 2-4x slowdown compared to non-instrumented code
Detection ScopeFinds 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

Skip this technique when:

  • Running production code (ASan can reduce security)
  • Platform is Windows or macOS (limited ASan support)
  • Performance overhead is unacceptable for your use case
  • Fuzzing pure safe languages without FFI (e.g., pure Go, pure Java)

Quick Reference

TaskCommand/Pattern
Enable ASan (Clang/GCC)-fsanitize=address
Enable verbosityASAN_OPTIONS=verbosity=1
Disable leak detectionASAN_OPTIONS=detect_leaks=0
Force abort on errorASAN_OPTIONS=abort_on_error=1
Multiple optionsASAN_OPTIONS=verbosity=1:abort_on_error=1

Step-by-Step

Step 1: Compile with ASan

Compile and link your code with the -fsanitize=address flag:

clang -fsanitize=address -g -o my_program my_program.c

The -g flag is recommended to get better stack traces when ASan detects errors.

Step 2: Configure ASan Options

Set the ASAN_OPTIONS environment variable to configure ASan behavior:

export ASAN_OPTIONS=verbosity=1:abort_on_error=1:detect_leaks=0

Step 3: Run Your Program

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

./my_program

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

Common Patterns

Pattern: Basic ASan Integration

Use Case: Standard fuzzing setup with ASan

Before:

clang -o fuzz_target fuzz_target.c
./fuzz_target

After:

clang -fsanitize=address -g -o fuzz_target fuzz_target.c
ASAN_OPTIONS=verbosity=1:abort_on_error=1 ./fuzz_target

Pattern: ASan with Unit Tests

Use Case: Enable ASan for unit test suite

Before:

gcc -o test_suite test_suite.c -lcheck
./test_suite

After:

gcc -fsanitize=address -g -o test_suite test_suite.c -lcheck
ASAN_OPTIONS=detect_leaks=1 ./test_suite

Advanced Usage

Tips and Tricks

TipWhy It Helps
Use -g flagProvides detailed stack traces for debugging
Set verbosity=1Confirms ASan is enabled before program starts
Disable leaks during fuzzingLeak detection doesn't cause immediate crashes, clutters output
Enable abort_on_error=1Some fuzzers require abort() instead of _exit()

Understanding ASan Reports

When ASan detects a memory error, it prints a detailed report including:

  • Error type: Buffer overflow, use-after-free, etc.
  • Stack trace: Where the error occurred
  • Allocation/deallocation traces: Where memory was allocated/freed
  • Memory map: Shadow memory state around the error

Example ASan report:

==12345==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x60300000eff4 at pc 0x00000048e6a3
READ of size 4 at 0x60300000eff4 thread T0
    #0 0x48e6a2 in main /path/to/file.c:42

Combining Sanitizers

ASan can be combined with other sanitizers for comprehensive detection:

clang -fsanitize=address,undefined -g -o fuzz_target fuzz_target.c

Platform-Specific Considerations

Linux: Full ASan support with best performance macOS: Limited support, some features may not work Windows: Experimental support, not recommended for production fuzzing

Anti-Patterns

Anti-PatternProblemCorrect Approach
Using ASan in productionCan make applications less secureUse ASan only for testing
Not disabling memory limitsFuzzer may kill process due to 20TB virtual memorySet -rss_limit_mb=0 or -m none
Ignoring leak reportsMemory leaks indicate resource management issuesReview leak reports at end of fuzzing campaign

Tool-Specific Guidance

libFuzzer

Compile with both fuzzer and address sanitizer:

clang++ -fsanitize=fuzzer,address -g harness.cc -o fuzz

Run with unlimited RSS:

./fuzz -rss_limit_mb=0

Integration tips:

  • Always combine -fsanitize=fuzzer with -fsanitize=address
  • Use -g for detailed stack traces in crash reports
  • Consider ASAN_OPTIONS=abort_on_error=1 for better crash handling

See: libFuzzer: AddressSanitizer

AFL++

Use the AFL_USE_ASAN environment variable:

AFL_USE_ASAN=1 afl-clang-fast++ -g harness.cc -o fuzz

Run with unlimited memory:

afl-fuzz -m none -i input_dir -o output_dir ./fuzz

Integration tips:

  • AFL_USE_ASAN=1 automatically adds proper compilation flags
  • Use -m none to disable AFL++'s memory limit
  • Consider AFL_MAP_SIZE for programs with large coverage maps

See: AFL++: AddressSanitizer

cargo-fuzz (Rust)

Use the --sanitizer=address flag:

cargo fuzz run fuzz_target --sanitizer=address

Or configure in fuzz/Cargo.toml:

[profile.release]
opt-level = 3
debug = true

Integration tips:

  • ASan is useful for fuzzing unsafe Rust code or FFI boundaries
  • Safe Rust code may not benefit as much (compiler already prevents many errors)
  • Focus on unsafe blocks, raw pointers, and C library bindings

See: cargo-fuzz: AddressSanitizer

honggfuzz

Compile with ASan and link with honggfuzz:

honggfuzz -i input_dir -o output_dir -- ./fuzz_target_asan

Compile the target:

hfuzz-clang -fsanitize=address -g target.c -o fuzz_target_asan

Integration tips:

  • honggfuzz works well with ASan out of the box
  • Use feedback-driven mode for better coverage with sanitizers
  • Monitor memory usage, as ASan increases memory footprint

Troubleshooting

IssueCauseSolution
Fuzzer kills process immediatelyMemory limit too low for ASan's 20TB virtual memoryUse -rss_limit_mb=0 (libFuzzer) or -m none (AFL++)
"ASan runtime not initialized"Wrong linking order or missing runtimeEnsure -fsanitize=address used in both compile and link
Leak reports clutter outputLeakSanitizer enabled by defaultSet ASAN_OPTIONS=detect_leaks=0
Poor performance (>4x slowdown)Debug mode or unoptimized buildCompile with -O2 or -O3 alongside -fsanitize=address
ASan not detecting obvious bugsBinary not instrumentedCheck with ASAN_OPTIONS=verbosity=1 that ASan prints startup info
False positivesInterceptor conflictsCheck ASan FAQ for known issues with specific libraries

Related Skills

Tools That Use This Technique

SkillHow It Applies
libfuzzerCompile with -fsanitize=fuzzer,address for integrated fuzzing with memory error detection
aflppUse AFL_USE_ASAN=1 environment variable during compilation
cargo-fuzzUse --sanitizer=address flag to enable ASan for Rust fuzz targets
honggfuzzCompile target with -fsanitize=address for ASan-instrumented fuzzing

Related Techniques

SkillRelationship
undefined-behavior-sanitizerOften used together with ASan for comprehensive bug detection (undefined behavior + memory errors)
fuzz-harness-writingHarnesses must be designed to handle ASan-detected crashes and avoid false positives
coverage-analysisCoverage-guided fuzzing helps trigger code paths where ASan can detect memory errors

Resources

Key External Resources

AddressSanitizer on Google Sanitizers Wiki

The official ASan documentation covers:

  • Algorithm and implementation details
  • Complete list of detected error types
  • Performance characteristics and overhead
  • Platform-specific behavior
  • Known limitations and incompatibilities

SanitizerCommonFlags

Common configuration flags shared across all sanitizers:

  • verbosity: Control diagnostic output level
  • log_path: Redirect sanitizer output to files
  • symbolize: Enable/disable symbol resolution in reports
  • external_symbolizer_path: Use custom symbolizer

AddressSanitizerFlags

ASan-specific configuration options:

  • detect_leaks: Control memory leak detection
  • abort_on_error: Call abort() vs _exit() on error
  • detect_stack_use_after_return: Detect stack use-after-return bugs
  • check_initialization_order: Find initialization order bugs

AddressSanitizer FAQ

Common pitfalls and solutions:

  • Linking order issues
  • Conflicts with other tools
  • Platform-specific problems
  • Performance tuning tips

Clang AddressSanitizer Documentation

Clang-specific guidance:

  • Compilation flags and options
  • Interaction with other Clang features
  • Supported platforms and architectures

GCC Instrumentation Options

GCC-specific ASan documentation:

  • GCC-specific flags and behavior
  • Differences from Clang implementation
  • Platform support in GCC

AddressSanitizer: A Fast Address Sanity Checker (USENIX Paper)

Original research paper with technical details:

  • Shadow memory algorithm
  • Virtual memory requirements (historically 16TB, now ~20TB)
  • Performance benchmarks
  • Design decisions and tradeoffs

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

04

需要参考平台分布和安装热度时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

补充不同宿主或平台的使用分布数据

能力 5

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Claude Code

29.83%
按下载量换算4,489

OpenCode

23.53%
按下载量换算3,541

Gemini CLI

15.52%
按下载量换算2,335

Antigravity

12.33%
按下载量换算1,855

Cursor

8.09%
按下载量换算1,217

Codex

3.44%
按下载量换算518

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

敏感数据

该 Skill 可能接触密钥、Token、环境变量或敏感配置,应进入高风险复核队列,默认不自动发布。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。

来源信息

继续浏览同类 Skills