I mean, you can make it difficult to extract but fundamentally the key
must be present on the device during the update...even if it's just in
RAM it can still be extracted, someone just needs to find an infoleak
or RCE exploit to read out the key during extraction. If you don't find
something there then someone who knows what they are doing could
likely find a hardware side channel/glitching attack or something(these
are often used for extracting keys from heavily locked down devices
like game consoles) to grab the key.
I've pulled gpg update decryption keys from some pretty heavily locked
down ISP routers in the past using RCE vulnerabilities. Once you have
one decryption key you can pretty much indefinitely decrypt future updates
without too much effort.
>
> > and use it to encrypt a new image, the same is not possible
> > with asymmetric encryption used for verified images).
> >
> >>
> >>> As a newbie to SWUpdate my initial thoughts are that perhaps we could
> >>> split the large rootfs image into sub-images (e.g., 1 MiB in size) and
> >>> install them in sequence to a ramdisk (e.g., 1MiB in size),
> >>
> >> Then you need a ramdisk equal or bigger as your image.
> >>
> >>> verify
> >>> them, then install the data from the ram disk to the proper storage
> >>> location.
> >>
> >> Very convoluted way and IMHO not needed at all. SWUpdate already
> >> verifies signed images. And if you encrypt the rootfs, you get the same
> >> result without splitting.
> >
> > Signing is different from encryption as you never have to distribute the
> > private key.
>
> This is clear - but he want to avoid to write into the flash, even if it
> does not add further security if it is ensured that the new software
> cannot be started (and for that, there are different mechanism).
>
> > Best I can tell the symmetric encryption is just for obfuscation
> > and provides little security benefit. Or am I missing something here?
>
> If we are talking about security, avoiding to write into the flash adds
> no security at all. He could also invalidate the flash after a failing
> update if he wants.
I don't think this is the case, blocking extraction by verifying can
significantly reduce attack surface, parsers/extraction software in
general tends to be a very large source of security issues, by
validating payloads before extraction an attacker would have to
find a vulnerability in something that happens before validation.
For example if there's a RCE vulnerability in say libmtd that can
be exploited by passing it a malicious image file your system could
get attacked unless the validator halts the update before passing
the image to libmtd to be written.
I've actually found exploitable vulnerabilities like this in a number of
devices using different update systems, for example a system that
extracted a tar file before validating the update signature could be
exploited due to a path vulnerability in busybox tar that one could use
to effectively write arbitrary files anywhere in the filesystem, but this
was only exploitable since signature validation happened after tar
extraction. If it happened before then it wouldn't reach the vulnerable
busybox tar codepaths.