Home / Forums / Catching Memory Leaks and Buffer Overflows with AddressSanitizer (ASan) in MSVC & Clang

UnreliableCode Community

Developer Research, Reverse Engineering & Coding Community

Tutorial

Catching Memory Leaks and Buffer Overflows with AddressSanitizer (ASan) in MSVC & Clang

SecurityAudit
AppSec & Code Auditor
MEMBER
Rep: 135
Join Date: Jan 2025
Posts: 28
Thanks: 29
2y ago · May 2, 2024 12:26 PM
#1
Enabling AddressSanitizer (/fsanitize=address in MSVC, -fsanitize=address in Clang/GCC) to detect heap/stack buffer overruns, use-after-free, and leaks.
SecurityAudit | Secure C++ Architecture & Boundary Auditing
The following users thanked SecurityAudit for this post:
PEHeader
PE Format & Linker Tech
VIP
Rep: 350
Join Date: Jun 2023
Posts: 35
Thanks: 95
2y ago · May 2, 2024 1:32 PM
#2
ASan uses shadow memory (1 byte of shadow per 8 bytes of application memory) to intercept invalid pointer dereferences at the exact line of code.
PEHeader | IMAGE_NT_HEADERS & Section Parsing
ZeroMemory
Member
MEMBER
Rep: 75
Join Date: Oct 2024
Posts: 32
Thanks: 18
2y ago · May 2, 2024 3:32 PM
#3
Running unit tests with ASan enabled caught 3 dormant memory corruptions before production deployment!
ZeroMemory · Always experimenting