PhoneAPI: gate local admin on the connection, not the wire from (#11033)

* PhoneAPI: gate local admin on the connection, not the wire from

The lockdown admin check in handleToRadioPacket only ran when p.from == 0. from is
a client-supplied wire field, and MeshService::handleToRadio rewrites it to 0 before
AdminModule sees the packet. A client could therefore set from != 0 to skip the
!getAdminAuthorized() drop, then have the packet normalized back to a local-admin
identity and executed - unauthorized admin from an unauthorized connection.

Every packet in handleToRadioPacket already comes from the local connection, so
locality is a property of the connection, not of from. Move the decision into
classifyLocalAdminPacket(), which ignores from and keys only on the admin variant and
the connection's authorization: lockdown_auth is delivered inline, any other admin
from an unauthorized connection is dropped, authorized admin passes through.

The classifier is compiled unconditionally and unit-tested; the guarded caller (built
only in the nRF52 lockdown config) calls it. Test: an unauthorized connection's
ADMIN_APP packet with from != 0 is classified DropUnauthorized.

* PhoneAPI: wipe the encoded lockdown passphrase, shorten comments

---------

Co-authored-by: Ben Meadors <benmmeadors@gmail.com>
This commit is contained in:
Thomas Göttgens
2026-07-17 05:21:32 -05:00
committed by GitHub
co-authored by Ben Meadors
parent ed3afdbc61
commit a7fde715c6
3 changed files with 121 additions and 18 deletions
+14
View File
@@ -319,4 +319,18 @@ class PhoneAPI
/// If the mesh service tells us fromNum has changed, tell the phone
virtual int onNotify(uint32_t newValue) override;
public:
/// How the lockdown admin gate should treat a phone->radio packet.
enum class LocalAdminGate {
NotAdmin, ///< Not a decodable ADMIN_APP payload; normal handling.
LockdownAuth, ///< A lockdown_auth payload; authenticate the connection inline.
DropUnauthorized, ///< Admin payload from a connection that has not authenticated; drop.
AuthorizedPassThrough, ///< Admin payload from an authorized connection; normal handling.
};
/// Classify a phone->radio packet for the lockdown admin gate, ignoring the wire `from` (which a
/// client can forge) and deciding on the connection's authorization. Fills outAdmin for lockdown.
static LocalAdminGate classifyLocalAdminPacket(const meshtastic_MeshPacket &p, bool adminAuthorized,
meshtastic_AdminMessage &outAdmin);
};