Allowlist pubkey prefixes only; ignore public and hashtag channels

- is_allowed matches pubkey_prefix only; sender names are never trusted
  (channel senders must be known contacts of the companion for the
  MeshCore integration to include their pubkey_prefix)
- channel messages on channel index 0 (public) and hashtag channels
  ('#name') are ignored unconditionally, before the allowlist check
- config flow validates allowlist entries as 6-64 hex characters
  (invalid_allowlist error) and UI strings/README updated
This commit is contained in:
Dejvino
2026-12-01 19:45:36 +01:00
parent 8eba7fa24c
commit 5d60a91964
8 changed files with 165 additions and 26 deletions
+16 -8
View File
@@ -22,9 +22,10 @@ it listens for `meshcore_message` events and replies via the
2. Install **MeshCore Agent**.
3. Restart Home Assistant.
4. Settings → Devices & services → *Add Integration* → **MeshCore Agent**.
5. Fill in the allowlist of senders who may command the agent (public key
prefixes or contact names, comma separated). Leave "Allow all senders"
unchecked; anyone on the mesh could otherwise command your todo list.
5. Fill in the allowlist of senders who may command the agent — **public key
prefixes only** (comma separated; the same format the MeshCore integration
uses). Leave "Allow all senders" unchecked; anyone on the mesh could
otherwise command your todo list.
## Mesh commands
@@ -46,6 +47,9 @@ channel's senders are allowlisted):
(`todo done buy m`). Messages may optionally start with a wake word:
`agent todo`, `bot done 2`.
Commands are accepted over DMs and on private named channels. The public
channel (index 0) and hashtag channels (`#name`) are ignored completely.
### Reminder times
| Syntax | Example | Meaning |
@@ -64,8 +68,9 @@ item's due date on the Home Assistant side.
- Direct messages are answered as direct messages to the sender's
`pubkey_prefix`.
- Channel messages are answered back into the same channel; reminders set from
a channel are delivered back into that channel.
- Private channel messages (from allowlisted, known contacts) are answered
back into the same channel; reminders set from a channel are delivered back
into that channel.
- Replies are truncated to the configured maximum length (default 200 chars).
## Home Assistant side
@@ -77,9 +82,12 @@ same items can also be added, completed and deleted from the Home Assistant UI
## Security notes
- Only allowlisted senders' commands are executed; everything else is ignored.
- The allowlist matches direct-message senders on their 12-hex `pubkey_prefix`
and channel senders on their advertised name. Names on channels are
self-reported — prefer key prefixes when allowlisting channel users.
- The allowlist matches **public key prefixes only** — names are never
trusted. A channel message carries a `pubkey_prefix` only when the sender
is a known contact of the companion, so channel users must be saved as
contacts on the companion to command the agent.
- The public channel (index 0) and all hashtag channels are ignored
unconditionally, regardless of the allowlist.
## Architecture