I am trying to understand Lorawan security implementation using OTAA (Over the Air Activation). Correct me where I am wrong.
Network Server (NS) stores in database device unique ID - “DevEUI” and “routing routing_profile_id” as information to which Application Server (AS)/client redirect uplink/messages. It also has connectivity with JoinServer (JS).
When device with specific DevEUI sends join request message to NS, NS accept that join request message if specified DevEUI exist on its database. NS creates JoinRequest payload in json format and sends over https to JS.
JS holds secrect key associated with specified devEUI. It generates two session keys NwkSKey and AppSKey and encrypts JoinResponse payload which will be send back as answer to NS, NS back to device. Device can verify and decrypt payload with secrect key, then further on can use session keys to encrypt/decrypt uplink/dowlink messages. That fine.
NS will also get from JoinServer two session keys in plain text. NwkSKey - which will be saved into database and AppSKey will be redirected to AS. Plain AppSKey send over internet to Application Server? Event NS uses SSL transport, it seems it could be a security flaw?
Another scenario: evil Application client will generate many random devEUI, if one of those at some point in time will match real device devEUI, joinRequest will be redirected to wrong application? (Owner of device will not able to create device on NS with the same devEUI).