Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request]: Better security for admin channel #2610

Closed
jp-bennett opened this issue Jul 14, 2023 · 13 comments
Closed

[Feature Request]: Better security for admin channel #2610

jp-bennett opened this issue Jul 14, 2023 · 13 comments
Labels
enhancement New feature or request

Comments

@jp-bennett
Copy link
Collaborator

Platform

NRF52, ESP32

Description

There's a potential issue with the way the admin channel is currently implemented, in that if a baddie gets physical access to a device, it exposes every device with that admin channel configured.

I can think of two ways to mitigate this risk, and there may be some benefit in combining the two. The first idea is to stop using the "admin" name as the admin channel, and instead store a setting on the device as to the admin channel name. So each device could have its own admin channel, like "admin_shortname" with a dedicated key. This has the added benefit that when you use your local radio to connect to the device, you're not vulnerable to rogue admin commands coming from a remote device.

The second way to approach this would be to add an admin_key as an optional device config setting. Incoming admin messages would be signed with that key, probably using HMAC. If an admin message comes in not containing a valid HMAC signature, it's just ignored. Again, this would be a unique key per device.

The ultimate goal is that you can put a repeater out in the wild, and not lose anything if it falls into evil hands. These are just early thoughts on how to possibly mitigate this risk, not fully thought out for every possible attack.

@jp-bennett jp-bennett added the enhancement New feature or request label Jul 14, 2023
@jp-bennett
Copy link
Collaborator Author

One note is that an HMAC authentication by itself would not prevent someone listening to admin commands sent to other nodes, assuming a single admin channel key that is compromised. This would leak any information sent in those commands, though not the admin_key itself.

@jp-bennett
Copy link
Collaborator Author

If good per-device DM encryption lands, the ultimate solution might be to move config and info messages to DMs, still authenticated by an admin key, as detailed above.

@tim292stro
Copy link

I'd consider doing it considering with a layer of abstraction - separate the Admin channel controls from the link security. If the actual admin has a key for each node the admin channel just becomes a transport, Anyone who gets on it would only be able to send messages to other nodes on the chanel, but without the specific unit admin key, changes couldn't be made. This concept would also compartmentalize the risk of a network takeover - as each node's key would be unique, so physicially taking over one node would result in an attacker gaining no insight to the key for other nodes. If this is a real concern on comodity hardware, the user/owner could add a secure enclave part on I2C to hold the key and enable some level of assurance for the cryptographic algorithms/security.

Actual administration would require some consideration for migrating from one configuration to another as a network-synchronized action, and there would have to be a mechanism to propagate settings changes to out-of-contact nodes (this could involve relays and temporarily altering hops rules, etc). The UI would need some signifiicant work to enable this propagation resilliently.

I don't like the idea of admin control data going over the air-plaintext, so a transient session key should be agreed on for a short term tunnel that fits in mesh packes. Concepts like "perfect forward secrecy" used in web traffic would be a good guide. Maybe a OTP setup local key exchange from the installing-owner to generate a single use limited validity PIN for a given node would be beneficial too... that might work better for unique key management with limited TTL, especially if the nodes are GPS equipped for time receiving - lower traffic if the communication doesn't need a key agreement conversation.

@g1gabyt3
Copy link

If there was an easy way to store and select from a dropdown different keys for the admin channel, you could just have different keys for each device with an admin channel. That way you quickly change the PSK used in the admin channel depending on which device you wanted to send admin messages to. That way if one device is stolen, all the other devices have a completely different PSK so they're not compromised. This would be the most efficient way to handle it. It would be an application change though, not a firmware change as the firmware would just know it's singular PSK for the admin channel.

@cyberorg
Copy link

May be public key/authorized_key like ssh can be implemented? Or even a pin before admin session is initiated would be better than what we have now.

At the moment it seems any node in the mesh can administer any other node with admin channel with the same key configured.

@thebentern
Copy link
Contributor

At the moment it seems any node in the mesh can administer any other node with admin channel with the same key configured.

Yes, channels are only secured by symmetric encryption. This is how all of the traffic in meshtastic is encrypted. If we make a special provision for admin channels, other private channels would still be "vulnerable".

@geeksville
Copy link
Member

This issue has been mentioned on Meshtastic. There might be relevant details there:

https://meshtastic.discourse.group/t/question-about-router-nodes/12169/4

@g1gabyt3
Copy link

g1gabyt3 commented Apr 24, 2024 via email

@jhollowe
Copy link
Contributor

jhollowe commented May 3, 2024

I know this wouldn't work for devices without GPS (or a network time source), but something like a per-node TOTP token (likely in addition to a nonce) would provide an easy-to-use method of different authentication per node and would use the authenticator apps people already use.

But ideally, we could just have public/private keys. The nodes have a (or list of) trusted keys which are allowed to edit admin settings. I do think separating the "physical" layer encryption of the channel and the encryption/authorization of the admin commands is a good idea.

@EternityForest
Copy link

EternityForest commented May 31, 2024

Allowing different "config presets" stored on the app, not the device, that you could select without rewriting and wearing out flash, could have a lot of other uses.

Admin channels really need authentication, but ideally a lot of other things would be authenticated as well.

Seems like it would be easy to add a variable length optional MAC field to the packets, to give 8/16/32/64 bit encryption depending on the security level required, and prevent replays with some basic time sync. I started a thread here:https://meshtastic.discourse.group/t/is-the-encryption-authenticated-and-replay-resistant-are-there-any-plans-to-make-it-so/9126 but it didn't get much interest.

The core idea is basically to keyed hash the message plus the current time(rounded to 5 minutes) to produce a MAC, and accept the current or the next closest MAC to handle the transitions.

To actually set the time, you mark certain channels as trusted time sources, and then just listen for sync messages, which must themselves be authenticated.

If you haven't got a time sync in a few days, you fall back to allowing unauthenticated messages to re-sync, or you just wait for someone to manually fix it.

If you need replay protection even within the 5-10 minutes window, you add a counter field. Once you get a message with a counter field, you don't listen to any more authenticated messages unless they have an incremented counter, until the next 5 minute MAC window.

The counter only needs to be 1 byte, and the MAC itself only needs to be 24 to 32 bits, especially if there's a timeout on invalid MACs.

If you stuff the counter and mac together in one uint32, you only need one extra protobuf field.

This would also give the possibility of authenticated chat and command messages, which I think is a super big deal for relay controls and the like.

@cyberorg
Copy link

cyberorg commented Jun 1, 2024

For now I am using this workaround:

  • Set different keys on each remote nodes
  • Maintain a file with those keys and node names(it would be convenient if this was builtin meshtastic app.)
  • Change the key needed on any node from which we need to administer them and revert when done.

@EternityForest
Copy link

EternityForest commented Jun 3, 2024

@cyberorg That seems like it would be a perfectly good long term solution if the UI supported it with a switcher menu in the app

@jp-bennett
Copy link
Collaborator Author

Fixed with the new PKI scheme!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Development

No branches or pull requests

8 participants