如果在悬空指针指向的位置分配了一个新对象,AddressSanitizer 是否仍会报告释放后使用

Will AddressSanitizer still report use-after-free if there is a new object allocated at where the dangling pointer points to

我正在研究使用 Address Sanitizer 构建的 Firefox 中的释放后使用漏洞。假设在利用释放后使用漏洞时,我们设法在释放对象 A 所在的位置分配一个新对象 B,因此悬挂指针指向新对象 B 内部的某个位置,我有两个问题:

(1) 当我们取消引用悬挂指针时,ASAN 是否仍会检测并报告与悬挂指针和已释放对象相关的释放后使用?

(2) 如果悬挂指针的取消引用现在由于它指向不同的对象 (B) 而导致崩溃,那么 ASAN 是在崩溃之前还是在崩溃之后检测到 UAF?

Suppose in an exploitation of a use-after-free vulnerability, we manage to allocate a new object B at where the freed object A was placed

A​​ddressSanitizer 以及大多数其他调试堆实现都有一个隔离缓冲区。释放的存储空间在很长一段时间内都不会被重复使用,因此任何对悬空指针的使用都可能被捕获。

(1) when we dereference the dangling pointer, will ASAN still detect and report use-after-free related to the dangling pointer and the freed object?

没有。如果您等待足够长的时间(或隔离缓冲区耗尽)以重新使用存储,那么 ASAN 将不知道有什么问题。

(2) ...does ASAN detect UAF before the crash or after the crash?

都没有。一旦存储被重用,ASAN 就不知道有什么问题了。如果程序崩溃,ASAN 只会告诉你 "your program has crashed",但不会帮助说明崩溃的原因。