Changing security modes¶
A device's security mode is set by the firmware it runs. SimpleOTA never looks inside a binary, so it learns about a new mode only when a device boots firmware configured for that mode and checks in. Every move between modes therefore works the same way. You upload a hop build in the mode the devices are in now, and that build's firmware is configured for the mode you are moving to. Once a device runs the hop build, it reports the new mode, and from its next check-in the server offers it builds for that mode only.
This page covers each move between basic, signed and strict mode, in
both directions. Two moves already have a full walkthrough:
basic to signed
and signed to strict. The
security modes page explains what each mode
protects against.
stateDiagram-v2
direction LR
basic --> signed: basic upload, firmware SIGNED + key
signed --> strict: strict-ready upload, firmware STRICT + project_id
basic --> strict: basic upload, firmware STRICT + key + project_id
strict --> signed: strict-ready upload, firmware SIGNED
signed --> basic: signed upload, firmware BASIC
strict --> basic: strict-ready upload, firmware BASIC
Which devices a build reaches¶
The server offers a build to a device only when the build's
security_mode matches the mode the device reports, or when either side is
blank (how modes are matched).
A device in strict mode reports signed and also sends
"require_manifest": true, and it is offered only signed builds that are
strict-ready.
| Device reports | basic build |
signed build, not strict-ready |
signed build, strict-ready |
|---|---|---|---|
| (nothing) | offered | offered | offered |
basic |
offered | not offered | not offered |
signed |
not offered | offered | offered |
signed, strict mode |
not offered | not offered | offered |
For a move between basic and signed or strict mode, in either
direction, a build uploaded in the target mode is not offered to devices
still in the old mode. They get a normal no_compatible_build response and
keep running what they have. Between signed and strict mode it is
different: a strict-ready build is offered to devices in both modes, and a
build that is not strict-ready only to signed devices. Devices that report
no mode are offered builds of every mode.
In each of the six moves the upload's mode only decides which devices are
offered the hop build. What moves a device is the setting in the firmware it
then runs. So the hop build has to be one the device is offered in its
current mode, and it has to pass that mode's checks on the device: a device
in signed or strict mode refuses an unsigned update on its own.
In the firmware, the mode is cfg.security_mode:
| Mode | cfg.security_mode |
Also needs | Reports on check-in |
|---|---|---|---|
| basic | SIMPLEOTA_SECURITY_BASIC |
basic |
|
| signed | SIMPLEOTA_SECURITY_SIGNED |
at least one key in cfg.signing_keys |
signed |
| strict | SIMPLEOTA_SECURITY_STRICT |
a key, and cfg.project_id |
signed and "require_manifest": true |
simpleota_init() returns an error when SIGNED or STRICT has no signing
key, when STRICT has no project id, when a project id is set that is not a
lowercase hyphenated UUID, or when a pinned key's PEM does not parse. The client then does not run, so the device never checks in and never
confirms the trial of that build. What happens next depends on rollback:
- On Arduino with bootloader rollback (the default), the trial watchdog
started before
setup()resets the chip once the default confirm time (300 s) and its margin have passed, and the previous image boots. - On ESP-IDF with
CONFIG_BOOTLOADER_APP_ROLLBACK_ENABLE, the build keeps running until the device next resets, and then the previous image boots. - Software rollback (
CONFIG_SIMPLEOTA_SOFTWARE_ROLLBACK, or an Arduino build with-DSIMPLEOTA_DISABLE_BOOTLOADER_ROLLBACK) is supervised fromsimpleota_init(), so it cannot act when init fails. Such a device stays on the build without OTA until it is reflashed over USB.
Run a hop build on a bench device before you upload it.
The moves¶
| From | To | Upload the hop build as | Configure its firmware with |
|---|---|---|---|
| basic | signed | basic |
SIGNED, pinned key |
| signed | strict | signed, strict-ready |
STRICT, pinned key, project_id |
| basic | strict | basic |
STRICT, pinned key, project_id |
| strict | signed | signed, strict-ready |
SIGNED, pinned key |
| signed | basic | signed |
BASIC |
| strict | basic | signed, strict-ready |
BASIC |
A strict-ready build comes from the
SimpleOTA CLI or the
GitHub Actions with a signing key, or from
simpleota build make-strict run on an earlier signed build. The dashboard
upload form and raw API calls (including the GitLab CI job) produce signed
builds that are not strict-ready; see
which release paths are strict-ready.
Basic to signed¶
Follow Migrating a fleet from basic to signed.
The hop is a basic upload whose firmware pins the public key and sets
SIMPLEOTA_SECURITY_SIGNED. A wrong or lost key in that firmware leaves
devices refusing every signed update, so check the key before the hop and
keep a backup key.
Signed to strict¶
Follow Turn on strict mode: release
with the CLI or the GitHub Actions, then ship one strict-ready build whose
firmware sets cfg.project_id and SIMPLEOTA_SECURITY_STRICT.
Once the fleet has installed a signed build after the basic to
signed hop, its pinned key is proven: each device
verified that build with it before booting it. Devices that have only taken
the hop build have checked the key against nothing, so ship and confirm one
signed build first. The project id is unproven either way. If the strict hop
sets a wrong cfg.project_id, no strict signature verifies on those
devices, and they refuse every later offer, exactly as after a direct hop
from basic with a wrong project id. Only a USB
reflash brings them back.
A rehearsal proves the project id first, and it is what makes this route
safer. A device in signed mode with cfg.project_id set checks the strict
signature whenever an offer carries one and refuses one that does not
verify, with reason signature_invalid. So:
- Ship a signed release whose firmware sets
cfg.project_idand keepsSIMPLEOTA_SECURITY_SIGNED. - Release a strict-ready build to those devices and check that they
install it. A wrong project id shows up here as refused offers. The
devices can still take a signed build that is not strict-ready, because
in
signedmode an offer without a strict signature is taken on its image signature. Upload the fix that way: from the dashboard upload form, or with a raw API call, since the CLI and the GitHub Actions normally make every signed build strict-ready. - Ship the strict hop with the same project id.
Outside strict mode a server can leave the strict signature out, so the rehearsal checks your configuration but does not give strict mode's protection.
Basic straight to strict¶
This works in one hop: a basic upload whose firmware pins the key and sets
cfg.project_id and SIMPLEOTA_SECURITY_STRICT. Neither the key nor the
project id has been checked against a real offer before the devices depend
on both. If either is wrong, the devices keep running the hop build but
refuse every later offer, because none of them carries a strict signature
that verifies against what they hold. A strict device takes nothing else, so
the only way back is to reflash each device over USB.
Going through signed with the rehearsal is the safer
route: it proves the key, then the project id, while a mistake can still be
fixed over the air. If you take the direct hop, run it as a canary and,
before you widen it, release one strict-ready build to the canary devices
and confirm they install it.
Strict to signed¶
Upload a strict-ready build whose firmware sets SIMPLEOTA_SECURITY_SIGNED
and keeps the pinned keys. On its next check-in the device stops sending
require_manifest, and from then on it is offered every signed build,
strict-ready or not. It still verifies the image signature. If the firmware
keeps cfg.project_id, it still checks a strict signature when an offer has
one, but it takes an offer without one, so a server that has
been taken over could offer an old signed image as a newer build.
Signed or strict to basic¶
Upload a signed build (strict-ready, if any devices are in strict mode)
whose firmware sets SIMPLEOTA_SECURITY_BASIC. The device verifies that
build in its current mode, boots firmware that reports basic, and from
then on is offered basic builds only. Keep uploading basic builds for
those devices.
In basic mode the pinned keys do not bind. The device still checks each
download's SHA-256 against the offer, over HTTPS, and does not check who
built the image. Someone who gets hold of your SimpleOTA account or an
upload token could ship firmware those devices would install. That can be a
reasonable trade, for example on a development fleet, but it gives up the
protection that signed mode exists to give.
A device that reports no mode¶
Firmware that leaves cfg.security_mode at SIMPLEOTA_SECURITY_NONE sends
no security_mode on check-ins. A device that has never reported a mode is
offered builds of any mode. A device that reported one before keeps it: the
server records a mode only when a check-in sends one, so switching firmware
to NONE does not move a device out of basic or signed. It does end
strict mode, because a device that does not send "require_manifest": true
on a check-in is treated as not strict from that check-in on.
Run the hop as a canary¶
A hop build is an ordinary deployment, so stage it the same way as any release (Promoting deployments): start at a low rollout percentage, watch what the devices report, then widen the same deployment.
Devices that take the hop are in the new mode from then on, so while the
fleet is split, a release reaches only the devices whose mode it matches
(and devices that report no mode). To get a feature release to the whole
fleet in that time, upload it in both modes. When the split is between
basic and strict mode, the signed copy has to be strict-ready. A fleet
split between signed and strict mode is the exception: one strict-ready
build reaches both.
To test a hop end to end, put a few devices in a device group, deploy the hop build to that group, then deploy a build in the new mode to the same group and check that those devices install it. For a hop to strict mode that second build must be strict-ready.
If the hop build rolls back¶
The hop build boots on trial like any update
(Trial install and rollback). If it crashes, hangs or is not
confirmed inside the confirm window, the previous image boots and the device
reports rolled_back with a reason. That previous image is configured for
the old mode, so the device reports the old mode on its next check-in and
is offered old-mode builds as before. Fix the hop build and upload it again
as a new build.
Confirming means the hop build passed the trial, not that its new settings are right. In managed mode with the default confirm, the trial is confirmed on the first successful check-in, whether or not the device can take what it is offered. A wrong key or project id therefore shows up later, as refused offers, which is why the canary should take one build in the new mode before you widen it.
Before you stop publishing the hop build¶
Devices that were offline, or outside the deployment's targets, are still on
an old build and still report the old mode. They get no_compatible_build
for new-mode builds and stay where they are. Before you retire the hop
deployment, look for devices whose build number in the project device list
is below the hop build. A device's page shows the mode it reports, or
"strict signing" for a device in strict mode, and
GET /projects/{id}/devices/
returns security_mode and require_manifest for every device.