Skip to content

fix: distinguish undecryptable direct messages from channel failures - #11244

Open
RCGV1 wants to merge 1 commit into
meshtastic:developfrom
RCGV1:codex/dm-error-hardening
Open

fix: distinguish undecryptable direct messages from channel failures#11244
RCGV1 wants to merge 1 commit into
meshtastic:developfrom
RCGV1:codex/dm-error-hardening

Conversation

@RCGV1

@RCGV1 RCGV1 commented Jul 26, 2026

Copy link
Copy Markdown
Member

Summary

When an addressed PKI direct message cannot authenticate with a public key already stored for its sender, reply with PKI_DECRYPT_FAILED instead of NO_CHANNEL.

PKI_UNKNOWN_PUBKEY remains the response when the sender key is absent, and ordinary encrypted channel failures still return NO_CHANNEL.

Depends on meshtastic/protobufs#1022.

Validation

  • pio test -e native-macos -f test_packet_signing (60 passed)
  • pio test -e native-macos -f test_mesh_module (24 passed)
  • pio run -e tbeam-s3-core
  • pio run -e t-echo
  • Verified a fresh clone can initialize the protobuf submodule at the dependency commit.

Summary by CodeRabbit

  • Bug Fixes
    • Improved handling of encrypted direct messages that cannot be decrypted.
    • Devices now distinguish between messages from unknown senders and messages that fail decryption, providing more accurate error responses.
    • Preserved existing behavior for messages received without a stored public key.
    • Added coverage for related routing scenarios, including invalid channels and stale encryption keys.

@coderabbitai

coderabbitai Bot commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: ad291b14-15d0-44e5-8fae-725ce5869956

📥 Commits

Reviewing files that changed from the base of the PR and between 2c8a2a8 and 7394cdf.

⛔ Files ignored due to path filters (1)
  • src/mesh/generated/meshtastic/mesh.pb.h is excluded by !**/generated/**, !src/mesh/generated/**
📒 Files selected for processing (3)
  • protobufs
  • src/mesh/ReliableRouter.cpp
  • test/test_packet_signing/test_main.cpp

📝 Walkthrough

Walkthrough

PKI routing now distinguishes undecryptable encrypted packets from unknown public keys and reports a dedicated NAK. Tests cover the new routing errors and related channel/key cases. The protobufs subproject pin also advances to a newer revision.

Changes

PKI routing error handling

Layer / File(s) Summary
PKI routing error classification
src/mesh/ReliableRouter.cpp
ReliableRouter::sniffReceived() sends PKI_DECRYPT_FAILED for undecryptable encrypted channel-zero packets while retaining the unknown-public-key path.
Decrypt-failure routing tests
test/test_packet_signing/test_main.cpp
Test routing doubles record error codes, and Group C verifies decrypt-failure, unknown-key, and wrong-channel outcomes.

Protobuf revision update

Layer / File(s) Summary
Protobufs revision pin
protobufs
The protobufs subproject reference is updated to a different commit.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

Suggested labels: bugfix

Suggested reviewers: vidplace7, thebentern, jp-bennett

Sequence Diagram(s)

sequenceDiagram
  participant Test as C13 test
  participant Router as AuthPipelineRouter
  participant Reliable as ReliableRouter
  participant Routing as AuthPipelineRoutingModule
  Test->>Router: sniff(encrypted PKI packet)
  Router->>Reliable: sniffReceived(packet)
  Reliable->>Routing: sendAckNak(PKI_DECRYPT_FAILED)
  Routing-->>Test: record lastAckError
Loading
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and accurately summarizes the main change to direct-message error handling.
Description check ✅ Passed The PR includes a clear summary and validation section, but the template's attestation checklist is not filled out.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

⚡ Try this PR in the Web Flasher

Flash this PR in the Web Flasher

firmware commit boards expires

Warning

This is an automated, unreviewed CI test build. Back up your device configuration
before flashing, and only flash devices you are able to recover.

Supported boards built by this PR (31)
Device Board Platform
Crowpanel Adv 3.5 TFT elecrow-adv-35-tft esp32-s3
Heltec HT62 heltec-ht62-esp32c3-sx1262 esp32-c3
Heltec Mesh Node 096 heltec-mesh-node-t096 nrf52840
Heltec Mesh Node T1 heltec-mesh-node-t1 nrf52840
Heltec Mesh Node T114 heltec-mesh-node-t114 nrf52840
Heltec V3 heltec-v3 esp32-s3
Heltec V4 heltec-v4 esp32-s3
Meshnology W10 meshnology_w10 esp32-s3
Meshnology W12 meshnology_w12 esp32-s3
Raspberry Pi Pico pico rp2040
Raspberry Pi Pico W picow rp2040
RAK WisMesh Pocket V3 rak_wismesh_pocket nrf52840
RAK WisMesh Pod rak_wismesh_pod nrf52840
RAK WisMesh Repeater Mini V2 rak_wismesh_repeater_mini nrf52840
RAK WisMesh Tag rak_wismeshtag nrf52840
RAK WisBlock 11200 rak11200 esp32
RAK WisBlock 11310 rak11310 rp2040
RAK3312 rak3312 esp32-s3
RAK WisBlock 4631 rak4631 nrf52840
Seeed SenseCAP Mesh-Tracker-X1 seeed_mesh_tracker_X1 nrf52840
Seeed Wio Tracker L1 seeed_wio_tracker_L1 nrf52840
Seeed Xiao NRF52840 Kit seeed_xiao_nrf52840_kit nrf52840
Seeed Xiao ESP32-S3 seeed-xiao-s3 esp32-s3
Station G2 station-g2 esp32-s3
Station G3 station-g3 esp32-s3
LILYGO T-Deck t-deck-tft esp32-s3
LILYGO T-Echo t-echo nrf52840
LILYGO T-Echo Plus t-echo-plus nrf52840
LILYGO T-Impulse Plus t-impulse-plus nrf52840
LilyGo T3-C6 tlora-c6 esp32-c6
Seeed SenseCAP T1000-E tracker-t1000-e nrf52840

Build artifacts expire on 2026-08-25. Updated for 7394cdf.

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