Navigation

    • Register
    • Login
    • OpenHardware.io
    • Categories
    • Recent
    • Tags
    • Popular
    1. Home
    2. Eurbaix
    3. Posts
    • Profile
    • Following
    • Followers
    • Topics
    • Posts
    • Best
    • Groups

    Posts made by Eurbaix

    • RE: Motivation to use MySensors for your project?
      1. It's flexible so I can build the sensor I need (or I want to play with), not just use the sensors most people need.
      2. It's very cheap, like 10 times less than any commercial IoT, so I can build sensors I don't really need, just for fun.
      3. It's open source so there is less chance it will drop support of legacy HW (planned obsolescence has become the norm in closed software).
      4. It's flexible, so I can have cheap, less powerful sensors if I don't need more, but also more powerful (edge-computing) sensors if I want to.
      5. I try to keep sensitive data behind my firewall, not critical for my sensors but it's a plus.

      Security, so far, is really not a strength of MySensors. Signing has been a nice addition but I don't want people to know the inside of my house is at 15C (so I'm probably away for a while, good time to rob the place). IMHO, this is the main limitation of MySensors right now and the reason I used a commercial solution for my thermostats. It's also why I proposed a better security solution for MySensors for 3.0 (who knows, may be sooner).

      posted in General Discussion
      Eurbaix
      Eurbaix
    • RE: Better security without the need of a cryptoprocessor: out-of-band authentication

      @Koresh I am sorry to disagree but, yes, NRF5, which is now reasonably close (less than 2x) to the price of Arduino Mini + NRF24L01, is a big step forward (although I think we shouldn't drop legacy atmega support). As an example, I'm thinking about a project for MySensors bird song detection, using FFT and band detection on edge-computing to limit the required bandwidth and it would easily fit on a typical 32 bit MCU like NRF5 but there is no way to have 10bit ADC plus FFT plus frequency band detection running at a decent frequency on an Arduino. Plus, having the radio and MCU in one unit really simplify the assembly and limit the risk of a connection going wrong.

      Not saying the arduino should be dropped, but there is really a point in also developing support for a platform like NRF5 (or any other 32 bit MCU with integrated radio, but the advantage of NRF5 is its radio compatibility with legacy NRF24L sensors).

      posted in Feature Requests
      Eurbaix
      Eurbaix
    • RE: Better security without the need of a cryptoprocessor: out-of-band authentication

      @Anticimex Agreed for the payload. The problem is you have to send this 256 AES key (the token) and there will be no room left in a 32 bytes packet for the hash that provides integrity check for the token. 256 keys could be used in SensorKeys in my proposal, as it is only send OTA once during the initialization, and we can decide for this reason to let go of the integrity check for the SensorKey. On the other hand, a token is sent everytime a sensor initiate a communication, or even for every packet if the TTL of the token is only one packet, so I think we should keep integrity check for tokens, therefore leave enough room for a hash in the 32 bytes packet. The options would be 192 AES with 64 bits hash, although I'm not sure there's may HW that support 192 AES, or 128 AES key with 128 bits hash.

      P.S.: One attack that is frequently forgotten is sending "garbage", i.e. random payloads which, once decrypted will be considered as valid payload and be interpreted by a node, creating all kind of unpredictable side effects. That's why I want to make sure "garbage" can be detected in all exchanges, using a hash.

      posted in Feature Requests
      Eurbaix
      Eurbaix
    • RE: Better security without the need of a cryptoprocessor: out-of-band authentication

      @Sergio-Rius Yes, your description is exactly what I was thinking about (except in much less words than I used). One important step you missed is that the initial "hardcoded" key must be erased during the "pairing" process so it cannot be compromised if a sensor is stolen. That's why it has to be in EEPROM on an atmega (other platforms, like the NRF5, have no EEPROM but can erase a flash page, which would do the same thing).

      As for 128 keys, yes they are crackeable. You only need all the computers of the Cambridge university (or was it Oxford?) during the entire weekend to crack a single cypher block. After all, banks still use AES 128 and, last time I checked, there was still some money left on my bank account ;-). Sure, at one point, 128 encryption will be brakeable in minutes (or nanoseconds if the Chinese are not lying about their prototype Qubits computer) but we're not there yet.

      P.S.: I don't know about the charisma of the atmega, but when it comes to I/O per dollar, it's hard to beat. And since I started programming on a portable TRS-80 PC-3 (1.4KB of RAM!) I still think there's lot we can do with the "huge" memory of the atmega. As long as we're not trying to implement edge-computing in MySensors, the atmega still has a future as a very affordable IoT platform to play with.

      posted in Feature Requests
      Eurbaix
      Eurbaix
    • RE: Better security without the need of a cryptoprocessor: out-of-band authentication

      @Anticimex Totally agree. The initial idea of my proposal was a security scheme compatible with existing sensors where a compromised sensor without an atsha204a can be easily blacklisted, this preferably with a minimal impact on the firmware size compared to the purely software solution already implemented. Also, it would provide obfuscation in addition to authentication, since I am not really comfortable with someone knowing if my house is empty and/or locked.

      Since the existing software solution already have AES, and "out-of-band" with token generated from the GW doesn't require a random number generator on the sensors, I think the "out-of-band" security could be implemented without a significant increase in the firmware size. The only compromise would be a 16 bytes encrypted payload if we stay with AES 128. Personnaly, I would accept this compromise so people using more modern platform can take advantage of the HW AES and free up some memory for the more complex sensors. After all, MySensors don't normally send tons of data, so it would only mean sending 2-4 packets instead of 1-2. Also, since the firmware updates do not contain any key, they don't need to be encrypted and can use the full payload.

      posted in Feature Requests
      Eurbaix
      Eurbaix
    • RE: Better security without the need of a cryptoprocessor: out-of-band authentication

      @Sergio-Rius The reason for the initialization PSK is to be able to differentiate a sensor you flashed yourself from a sensor someone else flashed and try to register on your network.Of course, you could use the sensor name as the key, but it is a weak key and it would also require to store the new sensor name on the GW every time you want to initialize a new sensor. The initialization PSK being common to all nodes, you don't need to change anything on the GW when you build a new sensor.

      You can't use an initial key generated by the GW because it would then need to be sent OTA to the sensor. Since the sensor do not have a PSK yet, this generated key would have to be send in clear. A rogue sensor listening at this moment could read this key and register instead of your own sensor. Although limiting the time during which a GW would accept a new sensor is limited by the "WPS" button, you have to think about a rogue sensor constantly listening and trying to register on your network until the GW is in "WPS" mode. (Note that I only refer to the basic concept of "WPS", which is limiting the time when a new sensor can register by using a button to initiate a 5-10 seconds window where the GW would accept a new sensor. The idea is simply that, since the initialization is using a common PSK which is a security risk if it is stored in easily accessible EEPROM, you want to limit as much as possible when this initialization PSK can be used, so only once during the initialization then it is deleted, and only if a button has been pressed on the GW within the last 5-10 seconds).

      Also, when using several separate networks (i.e. different GW linked to the same controllers, but each GW talking to its own sensor network), by using a different initialization PSK on each gateway (and on the sensors that must register on a specific gateway), you make sure that a sensor can only register on the right gateway. Then, each GW has only the list of sensor PSK for his own network so there is no risk a sensor attempt to talk to a GW it is not supposed to (if that's a concern, like having a low security sensor network and a high security sensor network).

      Also, I assume that GW are always in a secure location (cannot be stolen and read). If a GW can be compromised, we're opening an entirely new can of worms.

      And regarding your last comment: I, also, think async encryption is a better solution on non-constrained network (i.e. when memory and computing power is not a big concern). But, in this context, if we want to keep legacy support, we better look for the most lightweight encryption algorithms. Also, anything using a 256 key cannot be used with the current protocol since a 256 key or token would take the entire packet, with no room left for the routing information. Since "out-of-band" needs to send new tokens regularly, we have to stay with 128 bits. Going with 256 keys would require to also modify the protocol and make the entire thing much more complex to implement

      posted in Feature Requests
      Eurbaix
      Eurbaix
    • RE: Better security without the need of a cryptoprocessor: out-of-band authentication

      @d00616 asymetric encryption has some advantages but ECC is more computing intensive and asymetric encryption needs double decryption compared to single decryption with a symetric algorithm. I went with symetric because it's usually lighter and faster. Also, you would still need an initializing PSK to be able to differentiate a rogue sensor trying to register on your network vs. one of your own sensors. I don't thing a LED flashing a hash is really practical.

      P.S.: I know that current cheap platforms, like NRF5, are much more powerful for not much more money, but we should also keep in mind that a lot of existing sensors have already been deployed. If we drop the Atmega328 support, anyone who want to benefit of the new security solution will have to throw away all its existing sensor and rebuild new ones. That's why I am a strong advocate of legacy support, I hate throwing away something that could still works just because there is something new and shinner available for the same price.

      posted in Feature Requests
      Eurbaix
      Eurbaix
    • RE: Better security without the need of a cryptoprocessor: out-of-band authentication

      @Anticimex Well, it seems I missed something important in the current signing implementation. I'll have a second look.

      posted in Feature Requests
      Eurbaix
      Eurbaix
    • RE: Better security without the need of a cryptoprocessor: out-of-band authentication

      @Anticimex You raise a good point regarding cyphertext size. I was thinking initially AES 128 would be a good choice but, if routing is in clear, the encrypted part of the packet is now reduced to 16 bytes. Something to look at... or may be 16 bytes is acceptable in the use case scenario of MySensors since not all information is necessarily sensitive.

      Also, what are you referring to when you say "security personalizer"? I don't remember something with this name in the current security in MySensors?

      P.S.: No rush for the document sharing. It will take a while anyway to come up with something that covers all the basics so a few days more or less won't make a real difference.

      I

      posted in Feature Requests
      Eurbaix
      Eurbaix
    • RE: Better security without the need of a cryptoprocessor: out-of-band authentication

      @Anticimex I believe the difficulty is not in making "out-of-band" secure, as it has been used and reviewed many times from a security point of view. My concern was more: can we keep it simple enough so it could be deployed on existing 8 bit platforms.

      As for OTA, the initialization I proposed never send a clear key OTA. The initialization PSK is written on the sensor when you flash it (so, wired comms) and not part of the firmware. I was thinking something along the line of:

      • Flash and run a small firmware (which has the initialization PSK hardcoded) that will just store the initialization PSK in the EEPROM.
      • Flash and run the full MySensor firmware (which doesn't have the PSK hardcoded), then run the initialization using the PSK in the EEPROM.
        This way, the full MySensor firmware, that will be updated OTA, never have to include a PSK so it can be sent in clear. Also, since comms are now encrypted, OTA updates could be encrypted although I don't see a need to encrypt firmware updates since they do not contain sensitive information.

      As for packet size limitation, that's one of the reason I went with short TTL tokens that also act as nounce. The tokens are sent in a separate packet from the gateway so there is no need to exchange nounce for the rest of the communication as long as the token TTL is short enough. I would guess 5 or 10 packets using the same token should not be enough for a brute force attack. This leaves the entire packet free for payload (minus routing information), the usable payload is in fact the same as in non-secured comms.

      Last: Yes, a shared document would be a good idea so we don't have go through all the posts to remember what we already discussed. I have Google Docs and One Drive accounts, but can also register on another collaboration platform.

      posted in Feature Requests
      Eurbaix
      Eurbaix
    • RE: Better security without the need of a cryptoprocessor: out-of-band authentication

      @Anticimex A few additional points to address the rest of the conversation:

      • Since we are in a mesh network, I believe encrypting the routing information is not really an option as it would mean decrypting and reencrypting at each hop. Beside, if not using a common PSK, managing key exchange would become a nightmare. So, the security would only be end-to-end, with the intermediate node seeing the routing information (sensor IDs) but not the payload (sensor type and data).
      • I agree that security should be handled entirely by the gateway and sensors, as it is the only nodes we fully control the firmware. Involving any external component like the controller would be this a nightmare to maintain since we do not have full control on the firmware evolution of anything outside the GW and sensors.
      • Although new sensors will probably not be based on 8bits Atmegas, there are plenty of existing sensors that use 8bits Atmegas so I believe we should aim to implement a fully software solution, light enough to run on an 8bit Atmega. In my proposal, the only modification required would be to add a button on the gateway so it can still be easily implemented in an existing network. HW support (encryption or key generation) would be optional but I would keep the option to simply generate a key from an floating analog input.
      • As for the encryption, I would simply choose one that is supported by most hardware platforms but light enough to be able to implement software encryption in existing 8bits sensors, although I'm not sure there is still enough flash available to add software encryption on legacy sensors.

      Also note that my proposal does not aim at absolute perfect security, simply something that would allow to easily revoke a node so we don't need a cryptoprocessor to store authentication/encryption keys.

      posted in Feature Requests
      Eurbaix
      Eurbaix
    • RE: Better security without the need of a cryptoprocessor: out-of-band authentication

      @Anticimex There are, in fact, three different keys in my proposal:

      • A initialization PSK which should be stored in EEPROM, not the firmware, so it can be erased after the sensor registration. This PSK is common to all new sensors but only used once.
      • A sensor PSK, which is sent over the air during the registration, encrypted with the initialization PSK.
      • The sensor PSK is used to encrypt the token request and answer so another sensor cannot "read" the token since it doesn't have the same sensor PSK.
      • The token is then used as an authentication and encryption key during the rest of the communication.

      So here's a few more details about how it would work:

      • When firmware is initially loaded on a new sensor, the initialization PSK is also loaded in the sensor EEPROM.
      • The GW needs a "WPS" button (as modern routers have)
      • Just before powering-up a sensor for the first time, press the GW's "WPS" button, the sensor will accept a connection with the initialization PSK for a few seconds (10-15s) and, along the normal sensor "registration", also send a new key to the sensor. The sensor will then erase the original PSK and replace it with this "sensor PSK", which is specific to this sensor. Since this original PSK is only used during the initial registration then deleted, it will only exist in the sensor memory while the sensor is in a secure location. In case this PSK is compromised, you only need to create a new key in the gateway, that will then be used when you load new sensors.
      • This sensor PSK is then used to encrypt the token request since the GW knows each sensor key. The token is sent encrypted with this sensor PSK so another sensor cannot "read" this token. If the token is requested for a sensor-to-sensor communication, the GW will also send the token to the second sensor, encrypted with the second sensor PSK.
      • For the rest of the communication (sensor to sensor, or sensor to GW), this token becomes the encryption key and authentication key.

      This way, a common PSK is only used during the initialization and can only be used for initialization. This PSK is not accepted for regular communication with the GW (or other sensors). Also, a rogue sensor who have this initialization PSK can only request a "sensor PSK" when the WPS button is pressed. The chance of a rogue sensor sending a initialization request just after the WPS button has been pressed is minimal (except if you routinely initialized dozens of sensors everyday). If fact, the chances are low enough that the initialization PSK is even optional, in my opinion. After all, router use WPS without initialization PSK and this approach is considered reasonnably secure.

      Last, if a "sensor PSK" is compromised, you only have to erase this entry in the sensor PSK table on the GW and the rest of your sensor network will be secure. If we are not using a cryptoprocessor to store the sensor PSK, the risk of the sensor PSK to be read in a stolen sensor exist, but the fact that sensor PSK are individuals make this risk easier to mitigate (as long as you notice that a sensor has been stolen of course).

      posted in Feature Requests
      Eurbaix
      Eurbaix
    • RE: Better security without the need of a cryptoprocessor: out-of-band authentication

      PKI is even better than out-of-band although a bit more complex to implement, I was aiming for KISS as out-of-band is really not more complicated to implement than regular PSK.

      Regarding your comment about supporting the legacy platform, it is certainly a constraint. For me, the most important constraint is to keep the cost as low as possible so we can keep experimenting with sensors we don't really need because who cares, it's only 5$.

      A good alternative, and I'm surprised its not more popular in MySensor, is STM32F103, basically the same price as an arduino mini pro, no hardware encryption or secure memory but plenty of CPU and memory for software encryption, which should be OK as long as blacklisting a sensor is easy.

      Also, what about assymetric encryption, which would perfect here?

      posted in Feature Requests
      Eurbaix
      Eurbaix
    • Better security without the need of a cryptoprocessor: out-of-band authentication

      Although I was really impressed by Anticimex contribution on MySensors security, especially how he explained in very simple words the how and why of its authentication approach, there is a serious weakness in his authentication approach: the common PSK used for your entire MySensors network. If one sensor's PSK is compromised, your entire MySensors network is compromised and you have to reflash everything with a new PSK. Hence the use of a cryptoprocessor to make sure noone can read the PSK even if he has stolen a sensor. Except this solution is not cheap since even a very basic cryptoprocessor as the one Anticimex chose cost more than a complete node (Arduino Mini plus NRF24L01.

      Out-of-Band authentication would allow any node to talk to any other node, even it knows only its own personal PSK, which is not shared with any other node.

      • The gateway, which is normally in your secure space, so should not be stolen, allocate separate, random PSK to every node and keep a list of all these PSK.
      • When a node wants to talk to another node (or even to the gateway), it requests a temporary token to the gateway, authentifying itself using its PSK that the gateway knows.
      • The gateway sends a random token (something that is both a nonce and a PSK) to the node who requested it, and also to the node the first node wants to talk to.
      • For a few seconds, the two nodes can talk to each other using this token.

      Since the token is temporary, it plays the same role as a nonce to avoid replay attack. Since the gateway knows everybody's PSK (even an ESP8266 has enough memory to store everybody's 128bit PSK for a fairly large network), the gateway can authentify the initial token request and make sure the request is only sent to the two sensors that want to talk to each other by using each sensor PSK to encrypt the token.

      So, at the end, since a compromised sensor will only reveal its own PSK but not the other sensor's PSK, and you can easily blacklist this sensor by erasing its PSK on the gateway (which is normally more easily accessible than most of your sensors), you can have a fairly safe network without using an relatively expensive cryptoprocessor.

      Let me know if I missed something.

      And, yes, I should not only talk about it but try to implement it myself. Except, since the last time I actually coded something myself, it was in Turbo Pascal (yes, before it was called Delphi), catching up with today's programming language then go through the entire MySensor firmware to make sure I implement this correctly will probably take me a couple of year. So I think it would be best to let someone more knowledgeable than me implement this.

      On the other hand, if someone is interested, I have a few idea on how to make this really easy to use, i.e. using automatic PSK generation and allocation with a more secure version of "WPS", a simple way to very securely blacklist a stolen node and so on.

      Also, I know a bit about out-of-band authentication but I am not a network security specialist so I may have missed a big security hole. Let me know if it's the case.

      posted in Feature Requests
      Eurbaix
      Eurbaix