Building a safer FIDO2 key with privilege separation and WebAssembly
benkettle.xyz
benkettle.xyz
I noticed that the reference manual[0] of the MCU used also mentions a "firewall", which can be used to essentially create a "user mode" and "kernel mode" separation in both code and memory, with a well-defined "syscall" entry point. It would be neat to compare the impact of software vs hardware privilege separation.
[0]: https://www.st.com/resource/en/reference_manual/rm0394-stm32...
Another approach adds hardware specifically for this kind of sandboxing: a paper from earlier this year [1] implements an extension to x86 that adds hardware support for Wasm-style SFI. It could be interesting to see how this can apply to the embedded context where resources are more limited.
One nice thing about embedded stuff like this, though, is that we are dealing with human time scales and fairly simple operations—-there was a lot of room for slowdown without becoming unreasonable.
I recently finished up my Master’s thesis and thought the topic might be of interest to some HN readers. Happy to answer any questions!
Did you put thought into e.g. firmware updates of these, or even the ability to put additional sandboxed applications on a key with isolated views of state/storage?
No specific thought about firmware updates. In the brainstorming phase we were thinking about a multi-application model indeed---something like the Ledger Nano but using Wasm for isolation between applications instead of their OS. For this project we decided to try out the privilege separation angle, but I think the multi-application idea would be interesting to explore too.
This saved a lot of trouble, but in intro work on this I was using another chip (nRF52840) that worked the way you describe. To safely handle DMA in that case, without an IOMMU, we had to add somewhat complex reasoning that looked at each memory read and write to see if it was modifying a DMA control register and reject the write if it could lead to unsafe behavior. More info is on pages 52-55 of the thesis PDF.
This was pretty messy, so it was fortunate that the chip we used had a different plan. Let me know if I’m misunderstanding you!
[1]: https://pdos.csail.mit.edu/papers/bkettle-meng.pdf#page48
Tagged architecture / Memory tagging: https://en.wikipedia.org/wiki/Tagged_architecture & type unions
Harvard architecture > memory details > Contrast with modified Harvard architecture: https://en.wikipedia.org/wiki/Harvard_architecture#Contrast_...
IIUC Ideally there should be an NX bit on pages, registers, names, and/or variables; and the programming language supports it.
(IIRC, with CPython the NX bit doesn't work when any imported C extension has nested functions / trampolines?)
> But an attacker who compromises a host PC still gets significant power to interact with a connected authenticator by sending arbitrary messages over USB
The attacker can already extract all sensitive user data from the browser and even run a keylogger and take screenshots. The attacker can wait until the user logs into the desire website or service.
At this point everything of value is lost.
With FIDO2 this is not the case—since FIDO2 uses public key signatures with a secret key stored on the authenticator, a keylogger would not lead to the long-term account compromise that it would with just password-based authentication. An attacker with control of a user’s PC may be able to learn a session cookie, but once that cookie expires the attacker will no longer be able to log in.
Excellent work by the way. This stuff is super intriguing.
Authentication by secure hardware-backed cryptography is great, but you need to make sure the user agent and execution environment don't allow for exfiltration of sessions. You might want to use time-of-flight calculations on geopositioned IP address information to make sure they aren't exfiltrated as well, but...
You have to make sure you don't focus on exfiltration too much, since the attacker could use code injection to misuse resources local to the user. That will obviously break a lot of your anomaly detection.
So you probably want to work on securing the user agent to prevent code injection, such as requiring a particular browser and configuring it to only allow a list of vetted web extensions, using CSP and sub resource integrity for web pages, having a policy of installing OS and browser updates nearly immediately, and so on.
...but again, you probably don't want to spend that much time strengthening all the walls without planning what to do when attackers manage to figure out a way in, such as using an unknown zero-day. Reducing the damage an attacker can do is possibly a better investment, but that touches on the entire business process.
To your question, requiring the highest levels of strong authentication is an inefficient focus if the recovery process is an email into a third-party system. You can register multiple authenticators to reduce the need to go through recovery, (but then you have to worry about attackers registering new ones during a compromise, or the end-user having processes to keep them all safe). For recovery, you may use an equivalently strong mechanism like strong in-person identity verification (e.g. you have to walk to the IT desk and prove who you are to register a new security key fob onto your account).