# Branch Shadowing

### Introduction

Another unique class of side-channel attacks in the SGX settings is branch-prediction-based attacks. By exploiting the branch predictor, the attacks infer the states (taken or non-taken) of branches executed by an enclave. This section demonstrates the attack.

### Branch Shadowing

This video shows how the branch shadowing attack can extract RSA private key bits

* Target code: Sliding window exponentiation of **mbedTLS**
* Attack code: We modified Linux SGX SDK to run our shadow code
* Kernel log: Our attack code prints the output of LBR via `dmesg`

{% embed url="<https://youtu.be/R_C0rfbg3p8>" %}

###


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://sgx101.gitbook.io/sgx101/sgx-security/branch-shadowing.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
