The mitigation techniques employed by modern compilers and operating systems make it more difficult to exploit vulnerabilities lying in a program. However, they can be usually bypassed by simply leaking an address or some specific value stored in memory (e.g., a stack canary). A very frequent method used to get a leak is exploiting an uninitialized read vulnerability lying in the program. Indeed, stack and heap memory are often allocated and deallocated according to the program's needs and therefore the same memory location can be re-used multiple times during program's execution. This generates unintended overlaps in memory that, thanks to an uninitialized read, can be leveraged to obtain a leak. A manual analysis to discover uninitialized reads in a binary and understand if and how they can be exploited to obtain a leak is quite difficult and certainly requires a large amount of time. So, we designed MemTrace, a dynamic instrumentation tool that keeps track of the memory accesses performed by the executable and reports all the detected memory overlaps. To keep track of the state of bytes in memory, MemTrace uses a shadow memory that reflects the state (either initialized or uninitialized) of all the bytes of the stack and the heap; while in order to keep track of transfers of uninitialized bytes and to be able to detect the usage of uninitialized bytes, MemTrace implements a taint analysis, that marks as "tainted" a byte which is read while in the uninitialized state. By analyzing the report generated by MemTrace, the user can therefore detect potential leaking instructions together with the origin of the bytes it allows to read. To allow MemTrace to explore more paths of a program, we then paired it with a fuzzer in order to perform an automatic analysis of the binary. We tested MemTrace with 12 binaries containing a known uninitialized read vulnerability. When the binaries were executed with a crafted input triggering the vulnerability, MemTrace was always able to detect it; while when used in combination with the fuzzer, MemTrace was able to automatically detect the vulnerability for 8 of the tested binaries. In all the cases, MemTrace correctly reported the memory overlaps, thus proving that the used approach is effective.

Le tecniche di mitigazione impiegate dai moderni compilatori e sistemi operativi rendono più difficile sfruttare le vulnerabilità che si trovano in un programma. Tuttavia, di solito possono essere aggirati tramite il leak di un indirizzo o di un valore specifico salvato in memoria (ad esempio uno stack canary). Un metodo molto frequente utilizzato per ottenere un leak è sfruttare una lettura non inizializzata che si trova nel programma. Infatti, stack e heap vengono spesso allocati e deallocati in base alle esigenze del programma e quindi la stessa area di memoria può essere riutilizzata più volte durante l'esecuzione. Ciò genera degli overlap di memoria che, grazie a una lettura non inizializzata, possono essere sfruttati per ottenere un leak. Un'analisi manuale per scoprire le letture non inizializzate in un binario e capire se e come possano essere sfruttate è difficile e richiede una grande quantità di tempo. Dunque, abbiamo sviluppato MemTrace, un tool di strumentazione dinamica che tiene traccia degli accessi alla memoria eseguiti dal programma e segnala tutti gli overlap di memoria rilevati. Per tenere traccia dello stato della memoria, MemTrace utilizza una shadow memory che riflette lo stato di tutti i byte dello stack e dello heap; mentre per tenere traccia dei trasferimenti di byte non inizializzati ed essere in grado di rilevare l'utilizzo di tali byte, MemTrace implementa una taint analysis, che contrassegna come "tainted" un byte che viene letto mentre si trova in uno stato non inizializzato. Analizzando il report generato da MemTrace, l'utente può quindi rilevare potenziali leak e verificare l'origine dei byte che quest'ultimo consente di leggere. Per permettere al tool di esplorare più percorsi di un programma, lo abbiamo combinato ad un fuzzer. Abbiamo testato MemTrace con 12 binari contenenti una lettura non inizializzata nota. Quando i binari sono stati eseguiti con degli input in grado di triggerare la vulnerabilità, MemTrace è sempre stato in grado di identificarla; mentre quando è stato usato in combinazione con il fuzzer, MemTrace è riuscito ad identificare la vulnerabilità per 8 dei binari testati. In tutti i casi, il tool ha riportato correttamente gli overlap di memoria, dimostrando che l'approccio utilizzato è efficace.

MemTrace : a dynamic memory overlaps tracing tool

Pellizzi, Kristopher Francesco
2020/2021

Abstract

The mitigation techniques employed by modern compilers and operating systems make it more difficult to exploit vulnerabilities lying in a program. However, they can be usually bypassed by simply leaking an address or some specific value stored in memory (e.g., a stack canary). A very frequent method used to get a leak is exploiting an uninitialized read vulnerability lying in the program. Indeed, stack and heap memory are often allocated and deallocated according to the program's needs and therefore the same memory location can be re-used multiple times during program's execution. This generates unintended overlaps in memory that, thanks to an uninitialized read, can be leveraged to obtain a leak. A manual analysis to discover uninitialized reads in a binary and understand if and how they can be exploited to obtain a leak is quite difficult and certainly requires a large amount of time. So, we designed MemTrace, a dynamic instrumentation tool that keeps track of the memory accesses performed by the executable and reports all the detected memory overlaps. To keep track of the state of bytes in memory, MemTrace uses a shadow memory that reflects the state (either initialized or uninitialized) of all the bytes of the stack and the heap; while in order to keep track of transfers of uninitialized bytes and to be able to detect the usage of uninitialized bytes, MemTrace implements a taint analysis, that marks as "tainted" a byte which is read while in the uninitialized state. By analyzing the report generated by MemTrace, the user can therefore detect potential leaking instructions together with the origin of the bytes it allows to read. To allow MemTrace to explore more paths of a program, we then paired it with a fuzzer in order to perform an automatic analysis of the binary. We tested MemTrace with 12 binaries containing a known uninitialized read vulnerability. When the binaries were executed with a crafted input triggering the vulnerability, MemTrace was always able to detect it; while when used in combination with the fuzzer, MemTrace was able to automatically detect the vulnerability for 8 of the tested binaries. In all the cases, MemTrace correctly reported the memory overlaps, thus proving that the used approach is effective.
CARMINATI, MICHELE
ZANERO, STEFANO
ING - Scuola di Ingegneria Industriale e dell'Informazione
28-apr-2022
2020/2021
Le tecniche di mitigazione impiegate dai moderni compilatori e sistemi operativi rendono più difficile sfruttare le vulnerabilità che si trovano in un programma. Tuttavia, di solito possono essere aggirati tramite il leak di un indirizzo o di un valore specifico salvato in memoria (ad esempio uno stack canary). Un metodo molto frequente utilizzato per ottenere un leak è sfruttare una lettura non inizializzata che si trova nel programma. Infatti, stack e heap vengono spesso allocati e deallocati in base alle esigenze del programma e quindi la stessa area di memoria può essere riutilizzata più volte durante l'esecuzione. Ciò genera degli overlap di memoria che, grazie a una lettura non inizializzata, possono essere sfruttati per ottenere un leak. Un'analisi manuale per scoprire le letture non inizializzate in un binario e capire se e come possano essere sfruttate è difficile e richiede una grande quantità di tempo. Dunque, abbiamo sviluppato MemTrace, un tool di strumentazione dinamica che tiene traccia degli accessi alla memoria eseguiti dal programma e segnala tutti gli overlap di memoria rilevati. Per tenere traccia dello stato della memoria, MemTrace utilizza una shadow memory che riflette lo stato di tutti i byte dello stack e dello heap; mentre per tenere traccia dei trasferimenti di byte non inizializzati ed essere in grado di rilevare l'utilizzo di tali byte, MemTrace implementa una taint analysis, che contrassegna come "tainted" un byte che viene letto mentre si trova in uno stato non inizializzato. Analizzando il report generato da MemTrace, l'utente può quindi rilevare potenziali leak e verificare l'origine dei byte che quest'ultimo consente di leggere. Per permettere al tool di esplorare più percorsi di un programma, lo abbiamo combinato ad un fuzzer. Abbiamo testato MemTrace con 12 binari contenenti una lettura non inizializzata nota. Quando i binari sono stati eseguiti con degli input in grado di triggerare la vulnerabilità, MemTrace è sempre stato in grado di identificarla; mentre quando è stato usato in combinazione con il fuzzer, MemTrace è riuscito ad identificare la vulnerabilità per 8 dei binari testati. In tutti i casi, il tool ha riportato correttamente gli overlap di memoria, dimostrando che l'approccio utilizzato è efficace.
File allegati
File Dimensione Formato  
Executive Summary.pdf

Open Access dal 08/04/2023

Descrizione: Executive summary
Dimensione 398.23 kB
Formato Adobe PDF
398.23 kB Adobe PDF Visualizza/Apri
MemTrace - a dynamic memory overlaps tracing tool.pdf

Open Access dal 08/04/2023

Descrizione: Thesis
Dimensione 1.44 MB
Formato Adobe PDF
1.44 MB Adobe PDF Visualizza/Apri

I documenti in POLITesi sono protetti da copyright e tutti i diritti sono riservati, salvo diversa indicazione.

Utilizza questo identificativo per citare o creare un link a questo documento: https://hdl.handle.net/10589/187236