Skip to content

fix(filter): five repeater filter bugs - #61

Merged
Elektr0Vodka merged 1 commit into
dmc-devfrom
fix/dmc-dev-filter-bugs-1201
Dec 1, 2026
Merged

Elektr0Vodka merged 1 commit into
dmc-devfrom
fix/dmc-dev-filter-bugs-1201

Conversation

@Elektr0Vodka

Copy link
Copy Markdown

Five repeater filter bugs found in the October architecture review. The fix was written then but never pushed. All five are still present on dmc-dev: the original tests fail against current code.

Fixes

  • Private channels dropped by the malformed scan. A group text the Public key cannot open (a private channel whose hash byte is also 0x11) decrypted to length 0 and was dropped as too short, about 1 in 256 private channels. Content is now judged only when the decrypt succeeds, as the companion filter already does.
  • filter malformed <other> wrote no reply. Over the mesh the reply buffer was then uninitialised. It now returns a syntax error.
  • Rate limit order. The group-text limit ran before the channel block list and the content rules, so dropped traffic used up the budget legitimate channels share. Group text is now rate-limited last.
  • Wrapped numbers. filter hops, filter rate and filter hash parsed into 8/16-bit types (filter hops 3 300 stored 44). Values are range-checked before narrowing.
  • Channel names over 31 characters. filter channel add cut them off. Since fix(filter): match blocked channels by key, keep hash-only as an option #50, load() derives the key from the stored name, so after a reboot the cut-off name no longer blocked the channel. Such names are now refused, also for add hash.

struct ChannelDetails in Filter.h also redefined the one in src/helpers/ChannelDetails.h. It is renamed to FilterChannel with the same layout, so existing /filter_prefs files load unchanged.

Behaviour changes

  • Public-hash packets that fail to decrypt (including corrupt ones) now pass the malformed scan instead of being dropped.
  • Group text reaches the channel and content checks before the rate limit, so a flood of it costs some extra MAC/decrypt work when those features are in use.
  • A name over 31 characters that older firmware already stored stays stored cut off. Remove it and add the right name.

Tests

  • New test/test_filter_behaviour, including key and hash-only block entries, negative and out-of-range numbers, and the 31/32 character boundary.
  • pio test -e native -e native_region_gating: all pass.
  • native_kiss_modem does not start on my Windows PC, on unmodified dmc-dev either (DLL entry-point error). CI covers it.
  • pio run succeeded for Heltec_v3_repeater, RAK_4631_repeater, PicoW_repeater and wio-e5-mini_repeater (97.7% flash).

Not tested on hardware or over the air. Needs propagating to dmc-observer-dev and dmc-dev-packetlog, which have the same filter code.

- Malformed scan: a group text the Public key cannot open (a private channel
  whose hash byte collides with Public's 0x11) decrypted to len 0 and was
  dropped as MALFORMED_SHORT, so about 1 in 256 private channels was blocked.
  Content is now judged only when the decrypt succeeds, as the companion
  filter already does.
- `filter malformed <other>` wrote no reply; over the mesh that left the reply
  buffer uninitialised. It now returns a syntax error.
- The group-text rate limit ran before the channel block list and the content
  rules, so traffic those drop used up the budget legitimate channels share.
  GRP_TXT is now rate-limited last.
- `filter hops`, `filter rate` and `filter hash` parsed into uint8_t /
  uint16_t, so out-of-range input wrapped (`filter hops 3 300` stored 44).
  Values are range-checked as long before narrowing.
- `filter channel add [hash]` accepted names that do not fit the 32-byte slot.
  load() derives the key from the stored name, so after a reboot the cut-off
  name no longer blocked the channel. Such names are refused.

Filter.h also redefined `struct ChannelDetails` from
src/helpers/ChannelDetails.h. Renamed to FilterChannel; same layout, so
existing /filter_prefs files load unchanged.

Tests: new test_filter_behaviour drives Filter through its interface.
@Elektr0Vodka
Elektr0Vodka merged commit ff92ab3 into dmc-dev Dec 1, 2026
1 check passed
Elektr0Vodka added a commit that referenced this pull request Dec 1, 2026
…nc-1201-pr61

chore: merge dmc-dev into dmc-dev-packetlog (2026-12-01, #61)
Elektr0Vodka added a commit that referenced this pull request Dec 1, 2026
…c-1201-pr61

chore: merge dmc-dev into dmc-observer-dev (2026-12-01, #61)
@Elektr0Vodka
Elektr0Vodka deleted the fix/dmc-dev-filter-bugs-1201 branch December 1, 2026 21:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant