future-proof-iot / RIOT-rs

RIOT-rs is an operating system for secure, memory-safe, low-power Internet of Things, written in Rust
Apache License 2.0
43 stars 12 forks source link

Provisioning roadmap #446

Open chrysn opened 4 days ago

chrysn commented 4 days ago

Description

Around the flashing step we should have an option to customize what is on the device.

Whether that is part of the built source code (eg. through environment variables), linked in, flashed to a dedicated memory address, flashed through some code placed in RAM and executed there or done by the starting application while it communicates with the debugger is an implementation aspect that will need to be figured out, but may not be the same across all platforms.

Motivation

To make the usability aspects of CoAP (road map on https://github.com/future-proof-iot/RIOT-rs/issues/226) fly, we need some better provisioning.

Requirements

Concrete requirements are that

  1. Devices get unique keys (or key properties such as usage counters / sender IDs).
  2. When a device gets a key, its previous keys are revoked.
  3. Optionally, devices when re-flashed get the same keys again.

Item 1 is just security essentials[^1], item 2 is for practical reasons: If we want to express "All my devices may access this resource" without checking signatures, the public keys of all those devices need to be in some list, ideally distributed to other devices – which is practical for the 20-or-so distinct boards a typical developer ever flashes, but not for the 20k different boards those appear as if every flashing creates a new participant without revoking the old key. Item 3 is convenient if you don't want to limit "All my devices" to "All my devices so far", but update a device without revoking its permissions. (Using this is a trade-off, and I think that by that time one would rather use signed identities, but 1+2 enable it to the point where it is cheap enough).

[^1]: Protocols nowadays sometimes have mitigation in place, so eg. in EDHOC (unlike in similar protocols like earlier versions of Tox) when someone else has your key they can't impersonate anyone else to the owner that key, but that is supposed to be an extra layer of security and not relied on.

Open questions

Are you planning to do it yourself in a pull request?

Yes

chrysn commented 3 days ago

Some updates from a recent voice chat with @kaspar030:

chrysn commented 3 days ago

Concrete sketch of a plan:

This does not need any support from the programmers in that all binaries we flash are safe to flash onto any device, and then the key-management part will "just" overwrite the keys we had for the device (OK, revoke, we don't delete data just so -- but in this case, we just accidentally erased the device, so it's OK that its keys are revoked too :-) ).

I think that that kind of provisioning should be run once at programming time. Next stage provisioning can then run from those keys unless it's the simplest case where only a public key is reported publicly.