Skip to content
Tutorials Center
My learning

Topics

Lesson 29 of 36 ยท Security and Privacy

Secure Updates, Privacy and Compliance

Ship safe firmware updates with signatures, rollback protection and A/B slots, and protect user privacy with data minimization, pseudonyms and retention rules.

Every device will have bugs. A secure product is one you can fix after it shipped, and one that collects no more personal data than it needs. This lesson covers both halves: the over-the-air (OTA) update process and privacy by design. It builds on identity and signing.

Secure OTA updates

An update channel is the most powerful door into a device: whoever can push firmware controls it completely. A safe design answers four questions.

  1. Is this update authentic? The image is signed by the vendor's private key (kept offline or in an HSM). The device holds only the public key and refuses unsigned or wrongly signed images. A hash alone is not enough: an attacker can replace both file and hash.
  2. Is it intact? The signature covers the whole image, so any bit flip is caught.
  3. Is it newer? Anti-rollback protection stops an attacker from installing an old, vulnerable version. The device keeps a monotonic version counter.
  4. Can we recover? An A/B (dual-slot) layout writes the new image to the inactive slot, boots it, and reverts automatically if it does not confirm itself as healthy.
flowchart TD
  A["Download image to slot B"] --> B{"Signature valid?"}
  B -- no --> X["Discard, stay on slot A"]
  B -- yes --> C{"Version > current?"}
  C -- no --> X
  C -- yes --> D["Mark slot B as pending, reboot"]
  D --> E{"Self-test passes?"}
  E -- yes --> F["Confirm slot B"]
  E -- no --> G["Roll back to slot A"]

A safe update process has several places to say no.

The program below models the device-side checks with real Ed25519 signatures.

Node.js Verify, version-check and roll back an update

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with node:readline or process.stdin), it gets the next line from this box.

Each update path was exercised: success, downgrade, tamper, failed boot and a final good release. Real bootloaders (MCUboot, Mender, RAUC, AWS IoT Jobs, Azure Device Update) implement the same checks in firmware.

More update practices

  • Staged rollout. Update 1% of devices first, watch health metrics, then widen. A bad release should never reach the whole fleet at once.
  • Delta updates send only changed bytes, which matters on cellular and LoRa links.
  • Secure boot verifies the signature of the bootloader and firmware on every start, anchoring trust in hardware.
  • Update during safe states only (not mid-operation of a pump or lock).
  • Support lifetime. Publish how long the device gets security updates. A device without updates is a liability.
  • SBOM (software bill of materials): know which libraries are in the firmware so you can react when one has a vulnerability.

Privacy by design

IoT sensors observe homes, bodies, cars and workplaces. Even a smart meter's readings reveal when people are home, asleep or away. Privacy laws such as the EU GDPR, California's CCPA/CPRA and sector rules (HIPAA for health in the US) apply, and the EU Cyber Resilience Act and similar regulations add security duties for connected products. This is not legal advice; check the rules for your market. The engineering principles are stable:

  1. Data minimization. Collect only what the feature needs. Reduce precision when possible (round GPS to a district, aggregate to hourly).
  2. Purpose limitation. Use data only for the stated purpose.
  3. Pseudonymization. Replace identifiers with keyed hashes so analysts cannot trivially link records to people.
  4. Retention limits. Delete data when it is no longer needed.
  5. Transparency and control. Tell users what is collected; let them export and delete it, and switch off sensors such as microphones physically if you can.
  6. Process locally. Do detection on the edge and send only events ("person detected"), not raw video.
Node.js Minimize, pseudonymize and expire data

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with node:readline or process.stdin), it gets the next line from this box.

Two records survive; the third (Bob, ts 100) was older than the retention limit and is gone. The identities are replaced with stable pseudonyms, still useful for per-household statistics, and the coordinates are blurred. Note that pseudonymized data is still personal data legally if someone can reverse or link it; keep the key apart from the data.

Physical and lifecycle aspects

  • Decommissioning. When a device is sold, lost or retired, there must be a factory reset that wipes credentials and personal data, and a way to revoke its identity in the cloud.
  • Secure storage. Encrypt sensitive data at rest on the device where hardware permits; disable debug ports in production.
  • Incident response. Have a contact address for vulnerability reports and a plan to push fixes and notify users.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. Why is a hash published next to the firmware not enough protection?

    Only a signature made with a private key the attacker lacks proves authenticity.
  2. 2. What does anti-rollback protection prevent?

    A monotonic version counter makes the device refuse older images, even if correctly signed.
  3. 3. What is the purpose of an A/B slot layout?

    The device keeps the known-good image until the new one proves healthy.
  4. 4. Which is an example of data minimization?

    Reducing precision and volume to what the feature needs limits harm if data leaks.

Summary

  • Secure updates need signatures, integrity, anti-rollback and a recovery path (A/B slots), plus staged rollouts and secure boot.
  • Support lifetime, SBOMs and a vulnerability contact are part of the product.
  • Privacy by design: minimize, limit purpose, pseudonymize, expire data, give users control and process at the edge.
  • Plan the whole lifecycle, including factory reset and revocation.

Next: Cloud IoT Platforms and Architecture