Transient Execution Attacks (TEAs) such as Spectre and Meltdown exploit speculative and out-of-order execution to transiently access sensitive values and leak them through microarchitectural side channels. Although these transient instructions are eventually squashed and leave no architectural traces, they can still influence microarchitectural state, enabling attackers to recover secrets through timing measurements. Practical defenses must thus reduce exploitable transient behavior while keeping performance overhead and deployment complexity acceptable, especially on already-deployed processors. This thesis presents a software-only, compile-time mitigation framework based on assembly-to-assembly rewriting of x86-64 compiler-emitted code. The framework detects candidate transient “windows” for three TEA classes—Spectre V1 (bounds-check bypass), Spectre V4 (speculative store bypass), and Meltdown-like patterns—and rewrites only the affected regions. For each window, it generates multiple semantically equivalent hardened variants by composing local transformations (speculation-stopping fences, data sanitization/masking, dependency injection, and structural perturbations), and injects a lightweight runtime selector to diversify execution and reduce gadget repeatability. Because this configuration space is large, the framework includes a genetic optimizer that, using a dataset-driven surrogate evaluation loop, searches for a single global configuration that maximizes protection under an overhead budget, or minimizes overhead under a protection target. An experimental campaign on three TEA proofs of concept (PoCs) shows that diversification alone tends to reduce leakage as variant multiplicity increases; for instance, in Spectre V1 the duplication-only baseline reduces leakage from 97.8% at N=1 to 86.8% at N=75, with a 32.69% cycle overhead. However, stronger suppression typically requires combining at least one direct mitigation mechanism with lighter perturbations. Accordingly, maximizing protection under a 24% overhead budget yields a configuration that guarantees at least 95.74% worst-case protection across all three targeted attacks.
Gli attacchi a esecuzione transiente (Transient Execution Attacks, TEAs) come Spectre e Meltdown sfruttano l’esecuzione speculativa e out-of-order per accedere in modo transiente a valori sensibili e farli trapelare tramite canali laterali microarchitetturali. Sebbene queste istruzioni transienti vengano annullate e non lascino tracce architetturali, possono comunque influenzare lo stato microarchitetturale, consentendo agli attaccanti di recuperare i segreti tramite misure di timing. Le difese pratiche devono quindi ridurre il comportamento transiente sfruttabile mantenendo al contempo accettabili l’overhead prestazionale e la complessità di distribuzione, soprattutto su processori già in uso. Questa tesi presenta un framework di mitigazione esclusivamente software, applicato a tempo di compilazione, basato sulla riscrittura assembly-to-assembly di codice x86-64 emesso dal compilatore. Lo strumento rileva “finestre” transienti candidate per tre classi di TEA—Spectre V1 (bounds-check bypass), Spectre V4 (speculative store bypass) e pattern di tipo Meltdown—e riscrive solo le regioni interessate. Per ciascuna finestra genera molteplici varianti semanticamente equivalenti componendo trasformazioni locali (fence che arrestano la speculazione, sanitizzazione/mascheramento dei dati, iniezione di dipendenze e perturbazioni strutturali) e inserisce un selettore runtime per diversificare l’esecuzione e ridurre la ripetibilità dei gadget. Poiché questo spazio di configurazione è ampio, il framework include un ottimizzatore genetico che, tramite un ciclo di valutazione surrogato basato su un dataset sperimentale, ricerca una singola configurazione globale che massimizzi la protezione sotto un vincolo di overhead oppure che minimizzi l’overhead sotto un obiettivo di protezione. Una campagna sperimentale su tre proof of concept (PoC) di TEA mostra che la sola diversificazione tende a ridurre la fuga d'informazione all’aumentare della molteplicità delle varianti; ad esempio, in Spectre V1 la baseline basata esclusivamente sulla duplicazione riduce la fuga d'informazione dal 97.8% a N=1 all’86.8% a N=75, con un overhead in cicli pari al 32.69%. Tuttavia, una soppressione più efficace richiede in genere di combinare almeno un meccanismo di mitigazione diretto con perturbazioni più leggere. Di conseguenza, massimizzare la protezione sotto un vincolo di overhead del 24% produce una configurazione che garantisce almeno il 95.74% di protezione nel caso peggiore su tutti e tre gli attacchi considerati.
Automated assembly-level mitigation of transient Execution Attacks using diversified code variants and genetic search
GIORDANELLI, GABRIELE
2025/2026
Abstract
Transient Execution Attacks (TEAs) such as Spectre and Meltdown exploit speculative and out-of-order execution to transiently access sensitive values and leak them through microarchitectural side channels. Although these transient instructions are eventually squashed and leave no architectural traces, they can still influence microarchitectural state, enabling attackers to recover secrets through timing measurements. Practical defenses must thus reduce exploitable transient behavior while keeping performance overhead and deployment complexity acceptable, especially on already-deployed processors. This thesis presents a software-only, compile-time mitigation framework based on assembly-to-assembly rewriting of x86-64 compiler-emitted code. The framework detects candidate transient “windows” for three TEA classes—Spectre V1 (bounds-check bypass), Spectre V4 (speculative store bypass), and Meltdown-like patterns—and rewrites only the affected regions. For each window, it generates multiple semantically equivalent hardened variants by composing local transformations (speculation-stopping fences, data sanitization/masking, dependency injection, and structural perturbations), and injects a lightweight runtime selector to diversify execution and reduce gadget repeatability. Because this configuration space is large, the framework includes a genetic optimizer that, using a dataset-driven surrogate evaluation loop, searches for a single global configuration that maximizes protection under an overhead budget, or minimizes overhead under a protection target. An experimental campaign on three TEA proofs of concept (PoCs) shows that diversification alone tends to reduce leakage as variant multiplicity increases; for instance, in Spectre V1 the duplication-only baseline reduces leakage from 97.8% at N=1 to 86.8% at N=75, with a 32.69% cycle overhead. However, stronger suppression typically requires combining at least one direct mitigation mechanism with lighter perturbations. Accordingly, maximizing protection under a 24% overhead budget yields a configuration that guarantees at least 95.74% worst-case protection across all three targeted attacks.| File | Dimensione | Formato | |
|---|---|---|---|
|
MasterThesisFinal.pdf
accessibile in internet per tutti
Dimensione
813.91 kB
Formato
Adobe PDF
|
813.91 kB | Adobe PDF | Visualizza/Apri |
|
ExecutiveSummaryFinal.pdf
accessibile in internet per tutti
Dimensione
407.6 kB
Formato
Adobe PDF
|
407.6 kB | Adobe PDF | Visualizza/Apri |
I documenti in POLITesi sono protetti da copyright e tutti i diritti sono riservati, salvo diversa indicazione.
https://hdl.handle.net/10589/252863