by reitzensteinm · 6y ago · 0 comments
If the attacker controls the instruction stream it's game over (since they can disable the mask), but if they're just writing wasm that generates malicious speculative in process loads, it would prevent that.
Then an attack would have to trick library calls in to doing the same job, which is certainly possible, but much harder.
Of course this would negate many of the benefits of staying in the same process, so I'm not necessarily saying it's a good idea.
In which case: yes! That's Speculative Load Hardening (https://llvm.org/docs/SpeculativeLoadHardening.html). SLH tries to squash side-channels by preventing any speculatively-loaded data from being forwarded to dependent instructions until proving that branch prediction followed the right path.
But this undoes a lot of the performance that microarchitectures have added through branch prediction, since dependent memory loads (think linked list entries, or C++ vtables) are stalled behind full resolution of the branch condition.
If you're doing nontrivial compute, you can end up ahead performance-wise by splitting the computation into a separate process and invoking it via IPC. Now you don't need SLH because the untrusted process doesn't have long-lived secrets in its address space.
In your JIT, you enter and leave this mode before and after running user code to ensure it can't escape its region.
This would be a lot of work to pull off and would require custom hardware and software, but (at least as far as I can tell) it should work.
But in some cases, you probably could make it absolutely bulletproof. The closer to data->data transforms you get, the better.
For example, if you wanted a router that could run WASM blobs that make routing decisions. You pass in a header byte array and receive back route information.
Designed correctly, it's not a given that there is any surface area for an attacker to read data from a neighbour's address space.
I don't believe this. Not on modern hardware. I worked on Spectre for almost two years while at Google. We wrote this:
But my intuition is that the instructions themselves executed under such a masking system are no more able to perform timing attacks on the rest of the process than arbitrary code from one process can perform timing attacks on another.
If there's something specific I'm missing there I'd love to know what it is so I can update my mental model.