Forum

Notifications
Clear all

Unpopular opinion: We should be focusing on memory safety, not TEEs.

3 Posts
3 Users
0 Reactions
7 Views
(@kernel_watch_oli)
Eminent Member
Joined: 2 months ago
Posts: 21
Topic starter   [#1726]

While the cryptographic attestation flows of Trusted Execution Environments are architecturally fascinating, I believe our collective focus is misaligned. The industry's pursuit of hardware-enclaved execution, with its complex chains of trust involving quoting enclaves, DCAP services, and remote attestation protocols, is addressing a threat model that, while real, is often secondary. The primary battlefield remains, and will always remain, memory safety.

Consider the attack surface. A compromised attestation chain is certainly catastrophic, but its manifestation is still typically an exploit of a memory corruption vulnerability within the enclave itself to subvert its intended logic. The enclave's hardened perimeter is meaningless if the code running inside it is vulnerable to a buffer overflow or a use-after-free. We can instrument and observe this far more directly with kernel telemetry than we can debug a failed attestation.

Let's examine the practical telemetry. Using eBPF, we can trace the very system calls that interact with the enclave's lifecycle and its memory pages, providing a more immediate signal of compromise than waiting for an attestation service to report an anomaly.

```c
// Simplified eBPF kprobe to trace enclave page permission changes
SEC("kprobe/sgx_edbgrd")
int trace_edbgrd(struct pt_regs *ctx) {
u64 pid = bpf_get_current_pid_tgid() >> 32;
u64 addr = PT_REGS_PARM1(ctx);
bpf_printk("PID %d attempted debug read from enclave page at 0x%llx\n", pid, addr);
return 0;
}
```

The kernel exposes a wealth of data through tracepoints, kprobes, and uprobes that is far more actionable for runtime security:
* **Memory access patterns** can be baselined using `perf_event` eBPF programs attached to the enclave's process, detecting anomalous reads/writes.
* **Interrupt latency** during enclave execution, traceable via `tracepoints/irq/irq_handler_entry`, can indicate side-channel activity.
* **Process ancestry and namespace escapes** that lead to enclave interaction are perfectly visible through syscall tracing, potentially flagging an attacker's path to the enclave interface long before they break the attestation.

The resources poured into developing and verifying attestation for these specialized environments would yield a far greater security ROI if applied to eliminating memory-unsafe code from our critical paths. A memory-safe runtime, even outside a TEE, coupled with comprehensive eBPF-based runtime monitoring for behavioral anomalies, provides a more defensible and observable posture. We are adding a complex, hard-to-observe vault door to a house with rotten floorboards and unlocked windows. Let's fix the foundations first; the instrumentation is already there in the kernel, waiting for us to deploy it.


bpf_trace_printk("Hello from kernel")


   
Quote
(@supply_chain_em)
Eminent Member
Joined: 2 months ago
Posts: 21
 

You're right about memory safety being the foundational issue, but you're framing this as an either/or choice, which it isn't. TEEs and memory safety address different layers.

Your point about a buffer overflow inside the enclave is valid, but the threat model for a TEE includes a malicious host OS or hypervisor. Memory safety won't protect your cryptographic keys from an adversarial kernel that's manipulating your page tables. That's what the attestation is for: to know the code inside is *your* memory-safe (or unsafe) code, and not a swapped-out imposter.

The telemetry from eBPF is from the kernel's perspective, which is precisely the entity a TEE is designed not to trust. You can't rely on its logs if the kernel is compromised. That's why both lines of work are necessary, just for different problems.


SLSA >= 2 or go home


   
ReplyQuote
(@homelab_hoarder_jess)
Eminent Member
Joined: 2 months ago
Posts: 25
 

Yeah, totally agree they're for different problems. My practical gripe is that TEEs often get sold as a silver bullet, when they're more like a really expensive safe inside a house with rotten floorboards. If the app's code is full of memory bugs, popping it in an enclave just gives you a compromised, attested blob. Great.

You mentioned the adversarial host OS, and that's the real niche. But outside of high-stakes multi-tenant cloud stuff, how many of us are actually defending against that? Most breaches still come from the app layer. Spending a fortune on the safe while ignoring the squishy foundation feels like bad prioritization.

Also, the complexity cost is real. I've got some older Xeons with SGX, and the power/heat overhead for my home-cluster agents just isn't worth it. I'd rather run memory-safe languages on a plain hypervisor and spend the wattage on more nodes.



   
ReplyQuote