Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What prevents LoRaWAN nodes accepting the same JOIN ACCEPT message in OTAA

Tags:

iot

lora

lorawan

I surely must have missed something from my reading of the LoRaWAN specifications, because this seems too bad to be true. Please tell me I'm delirious :)

The following seems to happen in my testbed when I have many OTAA nodes and I can't figure out what would prevent it:

  1. multiple nodes in my network issues JOIN REQUEST at the same time (this can happen by chance or if they are powered on simultaneously)

  2. gateway receives (at least) one of them successfully and responds with a JOIN ACCEPT assigning a DevAddr, thinking one node did a join req

  3. all the nodes that did the JOIN REQUEST will receive the ACCEPT and think the JOIN ACCEPT was directed at them, and gladly sets the same received DevAddr

From here on, we have several nodes that all think they joined successfully and all think they are unique but have the same DevAddr. Needless to say, the system gets severely messed up.

Reading the LoRaWAN specification, the JOIN REQUEST has a node unique DevEUI, a network unique AppEUI, and a random DevNonce (to prevent replay attacks). The MIC is calculated from these and the secret network unique AppKey stored in the node.

The JOIN ACCEPT has, as far as I can see, no data in it which is derived from the JOIN REQUEST, and therefore it can't be directed to a specific node in the case that many nodes are currently listening to an ACCEPT.

It has: AppNonce NetID DevAddr DLSettings RxDelay CFList, and is encrypted with the AppKey which is network unique and not node unique. The MIC only involves these values and so doesn't help either.

I would have expected that the JOIN ACCEPT at the minimum includes the DevEUI requesting the join as a part of the MIC, and also that it would include the DevNonce. It seems it includes neither.

What gives? Is OTAA broken or not? :)

like image 660
BjornW Avatar asked Jan 03 '18 17:01

BjornW


People also ask

How does the LoRaWAN join-Accept message pass through the network?

In LoRaWAN versions earlier than 1.0.4 the Join-accept message is generated by the Application Server. In LoRaWAN 1.1 and 1.0.4+ the Join-accept message is generated by the Join Server. In both cases the message passes through the Network Server. Then the Network Server routes the Join-accept message to the correct end-device.

What is the OTAA message flow in LoRaWAN?

Figure: OTAA message flow in LoRaWAN 1.0 The join procedure is always initiated by the end device. The end device sends the Join-request message to the network that is going to be joined. The Join-request message consists of the following fields.

How do I join devices in LoRaWAN?

In LoRaWAN 1.0.x, the join procedure requires two MAC messages to be exchanged between the end device and the Network Server: Join-request - from end device to the Network Server Join-accept - from Network Server to the end device Before activation, the AppEUI, DevEUI, and AppKey should be stored in the end device.

What are the different types of LoRaWAN rejoin request messages?

There are three types of Rejoin-request messages: Type 0, 1, and 2. These message types are used to initialize the new session context for the end device. For the Rejoin-request message, the network replies with a Join-accept message. There are 4 data message types used in both LoRaWAN 1.0.x and 1.1.


2 Answers

The MIC will be different for each device because it's base on the secret (and supposedly unique) master key (AppKey) shared between the device and the network.

The first thing a device do is checking the MIC, if it's not what's expected it will drop the message.

So what you said below is not exactly right :

The JOIN ACCEPT has, as far as I can see, no data in it which is derived from the JOIN > REQUEST, and therefore it can't be directed to a specific node in the case that many > > nodes are currently listening to an ACCEPT.

It has: AppNonce NetID DevAddr DLSettings RxDelay CFList, and is encrypted with the AppKey which is network unique and not node unique. The MIC only involves these values and so doesn't help either

Of course if you set the same AppKey on every of your device, you will get what you described :)

like image 127
Pierre DUFOUR Avatar answered Oct 21 '22 20:10

Pierre DUFOUR


Apart from the different AppKey as mentioned in Pierre's answer (strongly recommended), the node also includes a DevNonce in its Join Request. This DevNonce is used to derive the NwkSKey and AppSKey session keys from the Join Accept response.

In LoRaWAN 1.0.x, this DevNonce should be random. So even when using the same AppKey for all devices, chances should be low that they would also have generated the same DevNonce. So even if the MIC somehow validated, then the derived keys will not match the keys known to the server, basically rendering the device useless without it knowing it.

In LoRaWAN 1.1 I think that the DevNonce is an increasing number, but in 1.1 OTAA has changed so I don't know how that affects the results.

See https://runkit.com/avbentem/deciphering-a-lorawan-otaa-join-accept.

The question also states:

this can happen by chance or if they are powered on simultaneously

As for switching on simultaneously, the 1.0.x specifications state:

The transmission slot scheduled by the end-device is based on its own communication needs with a small variation based on a random time basis

Still then, such small variation probably won't avoid nodes hearing each others Join Accept messages in this scenario, as the downlink receive window will need to be slightly lenient too.

like image 35
Arjan Avatar answered Oct 21 '22 21:10

Arjan