Heap-based memory vulnerabilities are significant contributors to software security and reliability. The presence of these vulnerabilities is influenced by factors such as code coverage, the frequency of heap operations, and the specific execution order. Current fuzzing solutions aim to efficiently detect these vulnerabilities by utilizing static analysis or incorporating feedback on the sequence of heap operations. However, these solutions have limited practical applicability and do not comprehensively address the temporal and spatial aspects of heap operations. In this paper, we propose a dedicated fuzzing technique called CtxFuzz to efficiently discover heap-based temporal and spatial memory vulnerabilities without requiring any domain knowledge. CtxFuzz utilizes context heap operation sequences (the sequences of heap operations such as allocation, deallocation, read, and write that are associated with corresponding heap memory addresses) as a new feedback mechanism to guide the fuzzing process. By doing so, CtxFuzz can explore more heap states and trigger more heap-based memory vulnerabilities, both temporal and spatial. We evaluate CtxFuzz on 9 real-world open-source programs and compare their performance with 5 state-of-the-art fuzzers (AFL, AFL++, HTFuzz, Memlock, TortoiseFuzz). The results demonstrate that CtxFuzz outperforms most fuzzers in terms of discovering heap-based memory vulnerabilities. Moreover, Our experiments led to the identification of 10 zero-day vulnerabilities (10 CVEs).
The workflow of CtxFuzz is illustrated in the following Figure. CtxFuzz follows the general workflow of grey-box fuzzers but introduces improvements in three areas, namely instrumentation, feedback mechanism, and seed selection. Specifically, CtxFuzz leverages the new context heap operation sequence (CHOS) feedback by recording a set of recently accessed heap memory addresses and their corresponding latest heap operation sequences (with a new sequence bitmap) at the entry of each basic block. It preserves test cases that actively contribute to either code coverage or context heap operation sequence coverage. Additionally, the seed selection strategy is refined to prioritize seeds based on the quantity of context heap operation sequences produced after their execution, thus enhancing the diversity of context heap operation sequences and the likelihood of uncovering potential vulnerabilities.