You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add malformed chat filtering and validation for public messages
- Introduced a new feature to validate and filter malformed chat messages in companion chat views.
- Implemented logic to drop malformed public chat messages at repeaters by default, ensuring binary datagrams remain unaffected.
- Enhanced text validation with UTF-8 checks and quality metrics to improve message display.
- Updated documentation to reflect changes in chat handling and configuration options for malformed message handling.
- Added new methods and structures to support the tracking and management of malformed message statistics.
Copy file name to clipboardExpand all lines: README-NL.md
+22Lines changed: 22 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,6 +4,8 @@ MeshCoreNG is een Next Gen variant van MeshCore.
4
4
5
5
Kort gezegd: MeshCore laat LoRa-apparaten berichten naar elkaar doorgeven zonder internet. MeshCoreNG bouwt daarop verder en probeert vooral repeaters slimmer te maken, zodat grotere en drukkere netwerken beter blijven werken.
6
6
7
+
Website en webflasher: https://michtronics.github.io/MeshCoreNG/
8
+
7
9
Het doel is niet om MeshCore opnieuw te bouwen. Het doel is om stap voor stap verbeteringen toe te voegen, zonder bestaande clients of het bestaande protocol kapot te maken.
8
10
9
11
## Waarom dit in Nederland belangrijk is
@@ -463,13 +465,30 @@ region tree
463
465
region save
464
466
```
465
467
468
+
**Malformed chat afhandeling:**
469
+
470
+
Companion radio firmware valideert menselijke chat voordat die naar apps of displays gaat. Ongeldige UTF-8, binary-achtige tekst, te veel control characters, replacement characters, onmogelijke timestamps en tekst met een heel lage confidence score worden bij de chat/UI-laag gefilterd. Binary datagrams, raw/custom packets, requests, responses en toekomstige packet types blijven binary-safe.
471
+
472
+
Standaard wordt malformed companion chat als compacte placeholder getoond, zodat rommeltekst niet in de Android/app kant gerenderd wordt. Payloads die niet geïnspecteerd kunnen worden, binary channel datagrams en onbekende/toekomstige packet types worden niet blind gedropt.
473
+
474
+
Repeater firmware kan ook ingesteld worden om malformed default-public-channel group text te droppen voordat het opnieuw wordt uitgezonden:
475
+
476
+
```text
477
+
get malformed.drop
478
+
set malformed.drop on
479
+
set malformed.drop off
480
+
```
481
+
482
+
Dit staat standaard aan op repeaters. Repeaters droppen alleen tekstpackets die ze kunnen inspecteren en als malformed kunnen classificeren. Encrypted/private group text die de repeater niet kan decrypten, binary datagrams en onbekende/toekomstige packet types blijven volgens de normale forwardingregels lopen.
483
+
466
484
Meer CLI-uitleg staat in [docs/cli_commands.md](./docs/cli_commands.md).
467
485
468
486
## Compatibiliteit
469
487
470
488
MeshCoreNG blijft compatible met het bestaande MeshCore ecosysteem.
471
489
472
490
- Geen packet format wijziging voor deze dense-mesh stappen.
491
+
- Chat-sanitatie geldt alleen voor menselijke chatweergave/forwarding policy; binary transport blijft ondersteund.
473
492
- Bestaande MeshCore clients blijven werken.
474
493
- Bestaande MeshCore firmware kan nog steeds met MeshCoreNG praten.
475
494
- De standaardinstellingen blijven veilig voor normale en sparse netwerken.
@@ -498,9 +517,12 @@ Voor developers:
498
517
MeshCoreNG heeft nu een GitHub Pages webflasher voor ESP32 repeater builds:
- MeshCoreNG website en docs: https://michtronics.github.io/MeshCoreNG/
501
521
502
522
De flasher gebruikt ESP Web Tools en werkt vanuit Chrome of Edge met Web Serial. Hij is bedoeld voor ESP32-family boards. nRF52, RP2040 en STM32 boards gebruiken nog steeds hun normale firmwarebestanden en flashing tools.
503
523
524
+
ESP32 repeater builds die je via deze site flasht hebben malformed public chat dropping standaard aan. Controleer of wijzig dit na het flashen met `get malformed.drop`, `set malformed.drop on` of `set malformed.drop off`.
525
+
504
526
De firmwarebestanden die de webflasher gebruikt komen uit GitHub Release assets. De release/CI workflow bouwt de ESP32 repeater-varianten, hangt de merged `.bin` bestanden aan de release, en de GitHub Pages workflow downloadt daarna die releasebestanden om de ESP Web Tools manifests onder `/flasher/` te maken.
505
527
506
528
Wil je later nog een ESP32-board toevoegen aan de webflasher, dan voeg je de PlatformIO environment name, display name, chip family en beschrijving toe aan `webflasher/boards.json`. De bijbehorende release asset moet een naam hebben zoals `<env>-*-merged.bin`.
Copy file name to clipboardExpand all lines: README.md
+22Lines changed: 22 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,6 +4,8 @@ MeshCoreNG is a Next Gen variant of MeshCore.
4
4
5
5
In simple terms: MeshCore lets LoRa devices pass messages to each other without the internet. MeshCoreNG builds on that and focuses on making repeaters smarter, so larger and busier networks can keep working better.
6
6
7
+
Website and web flasher: https://michtronics.github.io/MeshCoreNG/
8
+
7
9
The goal is not to rebuild MeshCore from scratch. The goal is to add improvements step by step, without breaking existing clients or the existing protocol.
8
10
9
11
## Why This Matters In The Netherlands
@@ -466,13 +468,30 @@ region tree
466
468
region save
467
469
```
468
470
471
+
**Malformed chat handling:**
472
+
473
+
Companion radio firmware validates human-readable chat before it is shown to apps or displays. Invalid UTF-8, binary-looking text, excessive control characters, replacement characters, impossible timestamps and very low-confidence text are filtered at the chat rendering boundary. Binary datagrams, raw/custom packets, requests, responses and future packet types remain binary-safe.
474
+
475
+
By default malformed companion chat is shown as a compact filtered placeholder, so garbage text is not rendered in the Android/app side. Payloads that cannot be inspected, binary channel datagrams and unknown/future packet types are not blindly dropped.
476
+
477
+
Repeater firmware can be configured to drop malformed default-public-channel group text before retransmission:
478
+
479
+
```text
480
+
get malformed.drop
481
+
set malformed.drop on
482
+
set malformed.drop off
483
+
```
484
+
485
+
This is enabled by default on repeaters. Repeaters only drop text packets they can inspect and classify as malformed. Encrypted/private group text that the repeater cannot decrypt, binary datagrams and unknown/future packet types are still relayed according to the normal forwarding rules.
486
+
469
487
More CLI details are in [docs/cli_commands.md](./docs/cli_commands.md).
470
488
471
489
## Compatibility
472
490
473
491
MeshCoreNG remains compatible with the existing MeshCore ecosystem.
474
492
475
493
- No packet format change for these dense-mesh steps.
494
+
- Chat sanitation is applied only to human-readable chat display/forwarding policy; binary transport stays supported.
476
495
- Existing MeshCore clients keep working.
477
496
- Existing MeshCore firmware can still talk to MeshCoreNG.
478
497
- The default settings remain safe for normal and sparse networks.
@@ -501,9 +520,12 @@ For developers:
501
520
MeshCoreNG now includes a GitHub Pages web flasher for ESP32-based repeater builds:
502
521
503
522
- MeshCoreNG web flasher: https://michtronics.github.io/MeshCoreNG/flasher/
523
+
- MeshCoreNG website and docs: https://michtronics.github.io/MeshCoreNG/
504
524
505
525
The flasher is built with ESP Web Tools and works from Chrome or Edge using Web Serial. It is meant for ESP32-family boards. nRF52, RP2040 and STM32 boards still use their normal flashing files and tools.
506
526
527
+
ESP32 repeater builds flashed from this site have malformed public chat dropping enabled by default. Check or change it after flashing with `get malformed.drop`, `set malformed.drop on`, or `set malformed.drop off`.
528
+
507
529
The firmware files used by the web flasher come from GitHub Release assets. The release/CI workflow builds the ESP32 repeater variants, attaches the merged `.bin` files to the release, and the GitHub Pages workflow downloads those release files to create the ESP Web Tools manifests under `/flasher/`.
508
530
509
531
To add another ESP32 board to the web flasher, add its PlatformIO environment name, display name, chip family, and description to `webflasher/boards.json`. The matching release asset must be named like `<env>-*-merged.bin`.
Copy file name to clipboardExpand all lines: docs/cli_commands.md
+14Lines changed: 14 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -474,6 +474,20 @@ On ESP32 boards with supported LoRa DIO1 wake wiring, sleep can wake by LoRa RX
474
474
475
475
---
476
476
477
+
#### View or change malformed repeater forwarding
478
+
**Usage:**
479
+
-`get malformed.drop`
480
+
-`set malformed.drop on`
481
+
-`set malformed.drop off`
482
+
483
+
**Parameters:**
484
+
-`on`: drop malformed decryptable default-public-channel group text before retransmission
485
+
-`off`: leave forwarding behavior unchanged
486
+
487
+
**Default:**`on`
488
+
489
+
**Note:** This only applies to human-readable default public group text that the repeater can decrypt and inspect. Binary channel datagrams, raw/custom payloads, requests, responses, private/encrypted packets that cannot be inspected and unknown/future packet types are still handled by the normal forwarding rules. Existing saved preferences are preserved; use `set malformed.drop off` to disable this behavior on a repeater.
490
+
477
491
#### View or change this node's advert path hash size
**Timestamp**: Unix timestamp in seconds (32-bit unsigned integer, little-endian)
274
274
275
+
**Text validity**: Channel text is expected to be valid human-readable UTF-8. Firmware validates received text before queuing it to the companion app. Malformed incoming text may be replaced with `[Malformed packet filtered]`. This does not affect channel data datagrams.
276
+
275
277
**Example** (send "Hello" to channel 1 at timestamp 1234567890):
276
278
```
277
279
03 00 01 D2 02 96 49 48 65 6C 6C 6F
@@ -329,6 +331,10 @@ Byte 0: 0x0A
329
331
330
332
**Note**: Poll this command periodically to retrieve queued messages. The device may also send `PACKET_MESSAGES_WAITING` (0x83) as a notification when messages are available.
331
333
334
+
**Malformed chat behavior**: Received contact and channel text is sanitized before it is queued. The firmware rejects malformed UTF-8, excessive control/replacement characters, binary-looking text and impossible timestamps. A malformed chat item may be queued as `[Malformed packet filtered]` instead of raw garbage text.
335
+
336
+
Binary channel data received through `CMD_SEND_CHANNEL_DATA` / channel data callbacks is not sanitized as text and remains binary-safe.
Copy file name to clipboardExpand all lines: docs/payloads.md
+4Lines changed: 4 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -174,6 +174,8 @@ txt_type
174
174
|`0x01`| CLI command | the command text of the message |
175
175
|`0x02`| signed plain text message | first four bytes is sender pubkey prefix, followed by plain text message |
176
176
177
+
Human-readable text payloads are validated before firmware UI/app callbacks render them. Implementations may reject or hide malformed UTF-8, excessive replacement/control characters, binary-looking high-entropy text and impossible timestamps. This validation is a display/forwarding policy for text payloads only; it does not change the packet format and does not apply to binary datagram, raw/custom, request, response or unknown/future payload types.
178
+
177
179
# Anonymous request
178
180
179
181
| Field | Size (bytes) | Description |
@@ -236,6 +238,8 @@ txt_type
236
238
237
239
The plaintext contained in the ciphertext matches the format described in [plain text message](#plain-text-message). Specifically, it consists of a four byte timestamp, a flags byte, and the message. The flags byte will generally be `0x00` because it is a "plain text message". The message will be of the form `<sender name>: <message body>` (eg., `user123: I'm on my way`).
238
240
241
+
Nodes that can decrypt a group text packet may apply the same human-readable text validation before displaying or forwarding it. Companion radio firmware sanitizes malformed decryptable group text before queuing it to the app and does not expose a separate malformed-drop command. Repeater firmware can be configured with `set malformed.drop on` to drop malformed decryptable default-public-channel group text before retransmission. Group datagrams remain binary payloads and are not subject to this text filter.
0 commit comments