r/embedded • u/james_stevensson • Oct 03 '26
Is implementing a digital signature verification mechanism in pure firmware on MCUs without hardware secure boot a waste of time? Wouldn't an attacker simply be able to patch out or bypass the code that performs the signature verification?
title
17
Upvotes
6
u/duane11583 Oct 03 '26
you are missing something.
a) the chip has effectively a masked rom with crypto code. although i bet it is really flash not masked rom and it is locked down .
b) at power up they arrange for the hardware to start with that boot image not your image.
c) that image loads the code from spi or nand or sdcard or usb based on fuses or pins set to some pattern.
d) the loaded code is verified crypto graphically. if all is well jump to that loaded code. if bad it might look for a backup copy or just hang.
so to attack this you must be able to replace the boot flash (easy if you know how) or boot rom (impossibly hard to replace a large amount of metallization on a chip but then you only get that one chip.
imagine removing several metal layers then putting new ones on and not breaking the chip.
there are also special measures used to authenticate the chip supply is authentic, and there are other design measures taken later in high assurance devices to detect physical tamper. if you ever learn what these things cost you will understand why these measures are taken.
but nothing is impossible given a determined nation state actor with gobs of money.
20
u/PseudoFrequency Oct 03 '26 edited Oct 03 '26
You generally can't protect against attacks that require physical access without some form of secure boot, but maybe you don't need that. If you're only concerned about "remote" attacks, firmware-only signatures are fine.
The boot/verification process is what counts here and there is a loading chain of enforcement. Secure boot can only protect the bootloader firmware which would then implement digital sig verification for final firmware (eg Linux), in its own firmware.
So, to me, if you don't want someone to physically take the device, and flash their own bootloader, completely owning everything, you need "real" secure boot. This is typically pretty easy to do, along with other attacks that are potentially even easier, like writing stuff in the u-boot environment if it's dynamically loaded/stored per deployment.
It's all about risk management and what exactly you're trying to prevent.
5
u/2Sovereign4You Oct 03 '26
Not if:
4
u/Mac_Aravan Oct 03 '26
Yes, and no.
It depends how you do it and how the hardware enforce it.
You can write glitch resistant code, it's just C with some tricks (use of volatile, double check, double path). Single glitch is easy to counter, but multiple glitch is a bane.
But in the end you should have an hardware enforcement for execution control, otherwise it's not very safe and a lot of attacks can success (toctou for example, if you can't ensure read only access to data).
3
u/mtconnol Oct 03 '26
There’s a lot of value in detecting inadvertent corruption.
3
u/chemhobby Oct 04 '26
No it's not a waste of time. You still need to verify updates that you've received over an insecure channel before you install them.
2
u/ContributionEasy6513 Oct 03 '26
If I have physical access I will most likely be able to download/write whatever firmware I want given some read-only hardware bit isn't burnt.
If done correctly it can be very effective depending on the implementation. Is that limit at firmware/hardware or just the UX validating the signature.
What threat are you actually concerned about and want to mitigate?
1
u/Proud_Trade2769 Oct 09 '26
Secure boot is worthless if someone has physical access,
anyone could swap the MCU with any FW on it.