The main attack vector besides compromising the server itself is (of course) the CA system. If you're in control of a CA key, you can create whatever certificate you need. There are currently about 1500 "trusted" CAs, any of them can possibly be used to produce fake certificates right now. even (or especially?) the large ones.

While I am aware of the concerns, they do seem to be overblown. The entire infrastructure of the SSL Internet relies on these CAs and the trust arrangement. Every HTTPS website uses this, and all your usernames+passwords are protected by it every time you login to a website. Not to mention every on-line bank. If this trusted CA arrangement is broken, to an extend it could threaten us, I think the Internet as a whole would have much bigger problems.

Anyway, in our case we need to explicitly load the trusted CAs into our SSL context at connection time, and that is likely to be 1 or 2 trusted CAs, not 1,500. We are going to need to embed these trusted CAs either in the config or in the firmware itself. Much as I dislike it, we are going to end up with something like a pinned CA anyway.

Yes, I would check the firmware signature after download/upload and invalidate the file/partition if it doesn't match.

Happy to try. I see that Espressif have some tools and standard ways of doing this (although they go much further with secure boot loaders). I’d rather not mess with the image format to much though - probably easiest to just use Espressif’s tools and implement our own validation at ota flash time.

Regards, Mark.

On 7 Apr 2018, at 4:39 PM, Michael Balzer <dexter@expeedo.de> wrote:


Am 07.04.2018 um 09:34 schrieb Mark Webb-Johnson:
support for HTTPS will help but not be a 100% protection against MITM attacks.

Why not? I think it should protect MITM ok - but certainly doesn’t address issues at the server end. Using SSL certificate verification, the client can verify the server certificate, and the encrypted SSL link should be sufficient to protect against tampering. But, no idea how good the ESP32 SSL library is for server certificate verification.

The main attack vector besides compromising the server itself is (of course) the CA system. If you're in control of a CA key, you can create whatever certificate you need. There are currently about 1500 "trusted" CAs, any of them can possibly be used to produce fake certificates right now. even (or especially?) the large ones.

https://blog.qualys.com/ssllabs/2017/09/26/google-and-mozilla-deprecating-existing-symantec-certificates

https://security.stackexchange.com/questions/42406/how-to-detect-the-nsa-mitm-attack-on-ssl


So we could store the public key in the firmware instead and use that to verify all downloads & uploads. That way, anyone can create his/her own key pair to use for personal builds.
Installing a firmware with another key would still be possible by flashing via USB or SD.

Can you elaborate how you suggest this would be done? During OTA download, I guess (as otherwise this would require boot loader work)?

Yes, I would check the firmware signature after download/upload and invalidate the file/partition if it doesn't match.

Regards,
Michael



Regards, Mark.

On 7 Apr 2018, at 3:21 PM, Michael Balzer <dexter@expeedo.de> wrote:

Mark,

support for HTTPS will help but not be a 100% protection against MITM attacks.

Regarding code signing, I think we don't need the ESP32 chip level protection, the primary concern is malicious downloads / uploads.

So we could store the public key in the firmware instead and use that to verify all downloads & uploads. That way, anyone can create his/her own key pair to use for personal builds.

Installing a firmware with another key would still be possible by flashing via USB or SD.

Regards,
Michael


Am 07.04.2018 um 08:03 schrieb Mark Webb-Johnson:
Not at the moment.

From my understanding, there are two ways to do this (not mutually exclusive):

  1. Signed firmware

    This is the most comprehensive way. It involved a public key stored on the OVMS module itself (burned into e-fuses), and a private key used to sign binaries. The boot loader will then refuse to load any App who’s signature doesn’t match. Works with flash encryption as well.

    The problem with this is it conflicts with the nature of open source. Once an ESP32 chip is put in that mode, it will only execute code signed with that private key. We can’t make that public (without destroying the entire security).

  2. HTTPS

    This at least provides some protection. We can validate the SSL certificate of the server (api.openvehicles.com) and protect somewhat from man-in-the-middle attacks.

    It doesn’t protect against other side-load attacks (such as SD CARD firmware load) - but those require physical access which is pretty much game over anyway, right?

I would like to do #2, and made allowance for that with ‘ota flash http’ leaving room for ‘ota flash https’. Just our http client library is pretty crappy at the moment, and it will take some effort to make it support https.

Regards, Mark.

On 6 Apr 2018, at 10:57 PM, Tom Saxton <tom@idleloop.com> wrote:

I don’t have the full context for this discussion, but I’m wondering: is the OTA update mechanism protected against a man-in-the-middle attack?
 
     Tom
 
From: OvmsDev <ovmsdev-bounces@lists.openvehicles.com> on behalf of Mark Webb-Johnson <mark@webb-johnson.net>
Reply-To: OVMS Developers <ovmsdev@lists.openvehicles.com>
Date: Wednesday, April 4, 2018 at 11:51 PM
To: OVMS Developers <ovmsdev@lists.openvehicles.com>
Subject: Re: [Ovmsdev] OTA status check timeout / SSL problem?
 
I think it was a fault on the api.openvehicles.com config - that shouldn’t be redirecting to https.
 
I fixed it, and it should be ok now.
 
Regards, Mark.
 
On 5 Apr 2018, at 12:44 AM, Michael Balzer <dexter@expeedo.de> wrote:
 
Mark,

the server check for an OTA update now fails every time, times out after 10 seconds.

I think that's because the new server currently does a redirect from http to https also on the 
api.openvehicles.com host. Not sure why the module doesn't fail
directly on that, maybe it tries to validate the certificate which also does not match.

As the openvehicles server has frequent connectivity issues from here I've added a "nocheck" option to the ota status command and use that for the standard web
status page. The OTA page still checks for the update.

Regards,
Michael

-- 
Michael Balzer * Helkenberger Weg 9 * D-58256 Ennepetal
Fon 02333 / 833 5735 * Handy 0176 / 206 989 26

_______________________________________________
OvmsDev mailing list
OvmsDev@lists.openvehicles.com
http://lists.openvehicles.com/mailman/listinfo/ovmsdev
 
_______________________________________________ OvmsDev mailing list OvmsDev@lists.openvehicles.com http://lists.openvehicles.com/mailman/listinfo/ovmsdev
_______________________________________________
OvmsDev mailing list
OvmsDev@lists.openvehicles.com
http://lists.openvehicles.com/mailman/listinfo/ovmsdev



_______________________________________________
OvmsDev mailing list
OvmsDev@lists.openvehicles.com
http://lists.openvehicles.com/mailman/listinfo/ovmsdev

-- 
Michael Balzer * Helkenberger Weg 9 * D-58256 Ennepetal
Fon 02333 / 833 5735 * Handy 0176 / 206 989 26
_______________________________________________
OvmsDev mailing list
OvmsDev@lists.openvehicles.com
http://lists.openvehicles.com/mailman/listinfo/ovmsdev



_______________________________________________
OvmsDev mailing list
OvmsDev@lists.openvehicles.com
http://lists.openvehicles.com/mailman/listinfo/ovmsdev

-- 
Michael Balzer * Helkenberger Weg 9 * D-58256 Ennepetal
Fon 02333 / 833 5735 * Handy 0176 / 206 989 26
_______________________________________________
OvmsDev mailing list
OvmsDev@lists.openvehicles.com
http://lists.openvehicles.com/mailman/listinfo/ovmsdev