Clamp direct position packets to channel precision (fixes #8640)#10383
Clamp direct position packets to channel precision (fixes #8640)#10383Jord-JD wants to merge 9 commits intomeshtastic:developfrom
Conversation
|
Still working on local testing for this, but thought I'd get it in sooner rather than later given the privacy implications of the related issue, and to allow others to test if they wish. |
|
Tested on Heltec V4. Seems to work fine. I used 'Exchange Position' from the Android app to another local node, and saw that the node position received was imprecise in a way that was consistent with the V4 node's channel position precision settings. |
There was a problem hiding this comment.
Pull request overview
This PR fixes a privacy/behavior gap where “direct” POSITION_APP packets (still channel-encrypted and readable by any node on that channel) could bypass per-channel position precision truncation. It centralizes position-precision enforcement and applies it in Router::send() once the final channel index is known, ensuring consistent truncation for broadcasts, replies, and direct exchanges.
Changes:
- Add a shared
PositionPrecisionhelper to compute per-channel precision and clamp/scrub outgoingmeshtastic_Positionpayloads. - Apply position precision in
Router::send()prior to encryption/MQTT handling, closing the “direct send” bypass. - Update
PositionModuleto use the shared helper and add a dedicated unit test suite for precision behavior.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| test/test_position_precision/test_main.cpp | Adds unit tests covering truncation, full precision, scrubbing, and packet re-encode behavior. |
| src/modules/PositionModule.cpp | Replaces inline truncation logic with shared helper calls for consistent precision handling. |
| src/mesh/Router.cpp | Enforces position precision in the final send path after channel selection, before encode/encrypt/MQTT. |
| src/mesh/PositionPrecision.h | Declares shared helper APIs for channel precision and packet/position filtering. |
| src/mesh/PositionPrecision.cpp | Implements shared precision selection + truncation/scrub logic and packet re-encode. |
Co-authored-by: Copilot Autofix powered by AI <[email protected]>
|
@thebentern Review comments addressed. Give me a shout if you need anything else changing. |
|
I'll take a look at these check/test errors. |
|
I think the check/test errors should now be fixed. |
This MR fixes #8640, where using Exchange Positions from the node list can send a full-precision position over a channel configured with reduced position precision.
The issue appears to be that direct position packets are still channel-encrypted packets with a
tofield, so all nodes on that channel can decode them. The existing precision truncation was happening in module processing, but direct sends do not reliably pass through that path before being transmitted.This PR moves the position precision handling into a shared helper (
src/mesh/PositionPrecision.cpp) and applies it fromRouter::send()after the final channel index is known and before encryption/MQTT handling.This means any outgoing
POSITION_APPpacket sent on a channel is filtered according to that channel'smodule_settings.position_precision, including direct position exchanges and position replies.PositionModulealso uses the same helper now, so the existing broadcast/reply behaviour stays consistent.🤝 Attestations