Skip to content

Phantom Speculation

CPU'yu, hiç branch içermeyen bir program konumunda bir branch'i (indirect bir JMP/CALL) speculative olarak çalıştırmaya zorlamak; böylece attacker-controlled bir transient pencere açılır.

Mechanism

Note

Bazı AMD Zen çekirdeklerindeki branch predictor'lar, geçerli adresteki instruction daha decode bile edilmeden front end'i yönlendirmeye karar verebilir — predictor, bir fetch adresini predicted branch target ile tamamen history'den yola çıkarak ilişkilendirir; o adreste gerçekte hangi byte'lar olduğundan bağımsız olarak. Phantom speculation bunu suistimal eder: attacker, branch predictor'ı öyle eğitir ki zararsız, non-branch bir instruction (paper'ın örneği: düz bir XOR ya da bir RET) attacker'ın seçtiği bir target'a giden indirect bir JMP/CALL gibi muamele görür. Source'ta architectural hiçbir branch olmamasına rağmen transient execution o target'ta başlar — bir "phantom" branch.

Phantom speculation (Wikner & Razavi, "Phantom: Exploiting Decoder-detectable Mispredictions", MICRO 2023) önemlidir çünkü hijack için gerçek bir branch gadget'ına ihtiyaç duymaz — speculation'ı herhangi bir yerde imal eder. Aynı predictor-aliasing primitive'i AMD tarafında Branch Type Confusion (CVE-2022-23825, AMD-SB-1037, Jul 2022) olarak ayrıca disclose edilmiştir; bu CVE Phantom paper'ının kendisine ait ayrı bir kimlik değil, ilişkili ama distinct bir AMD advisory'sidir. Inception'ın (CVE-2023-20569) altındaki primitive budur; orada bir phantom branch öyle yönlendirilir ki CPU bir XOR'u recursive bir CALL zanneder, Return Stack Buffer'ı attacker-controlled bir return target ile overflow eder ve tüm AMD Zen CPU'larda kernel memory'sini (örn. /etc/shadow) sızdırır.

Walkthrough

Teknik (kavramsal): predictor'ı aliasing yapan bir source adresine karşı mistrain et, sonra branch olmayan bir victim instruction'da speculation'ı tetikle.

1. Pick a source virtual address S that aliases (in the BTB/predictor index)
   with a victim instruction the CPU will fetch.
2. Train: repeatedly execute a real indirect branch at S whose target is a
   chosen disclosure/recursion gadget, teaching the predictor target T.
3. Trigger: cause the victim to fetch the non-branch instruction. The predictor
   fires a "phantom" JMP/CALL to T before decode contradicts it.
4. Transient code at T runs and leaks via a cache covert channel; on Inception,
   T re-injects into the RSB to sustain unbounded speculation.

Inception'ın recursion hilesi, gösterimle:

Architecturally:  xor eax, eax     ; harmless
Phantom belief :  call <attacker T>; pushes a poisoned return onto the RSB,
                  recursively overflowing it so subsequent RETs speculate to T
Result         :  attacker-controlled transient execution -> kernel memory leak

Detection

Temiz bir architectural iz yok; leak transient'tır. Savunmacılar microcode/firmware mitigation durumunu bilmeye ve yoğun cache-channel probing'i tespit etmeye dayanır.

Mitigation

  • AMD microcode update'leri ve yazılım (Linux mitigation'ları Inception/SRSO ailesi için /sys/devices/system/cpu/vulnerabilities/spec_rstack_overflow altında rapor verir). Etkilenen Zen parçalarında bir IBPB-on-context-switch / SRSO mitigation'ı uygulanır.
  • Privilege sınırları boyunca branch-predictor durumunu flush'lamak cross-domain training'i azaltır.

References