Skip to content

Validate reply-path length in repeater anonymous request handlers - #3842

Open
dahuib wants to merge 1 commit into
meshcore-dev:devfrom
dahuib:fix-anon-reply-path-bounds
Open

dahuib wants to merge 1 commit into
meshcore-dev:devfrom
dahuib:fix-anon-reply-path-bounds

Conversation

@dahuib

@dahuib dahuib commented Nov 14, 2026

Copy link
Copy Markdown

Validate reply-path length in repeater anonymous request handlers
MyMesh::onAnonDataRecv() passed &data[5] into handleAnonRegionsReq(), handleAnonOwnerReq() and handleAnonClockReq() without the remaining payload length. Those handlers checked reply_path_len against the 64-byte protocol maximum with Packet::isValidPathLen(), but not against the bytes actually received, before copying the path with Packet::writePath() and using it as the route for the reply.

This is reachable without authentication: any node in radio range can send a direct ANON_REQ using its own keypair. A single-block request claiming a 64-byte reply path makes the repeater copy up to 53 stale stack bytes into the reply path, which is sent unencrypted in the packet header. That stack region is shared with other packet handling and can hold recent data, for example the text of a remote admin CLI command such as a password change. I can share more details privately if useful.

This change adds a defensive len < 5 check in onAnonDataRecv(), passes len - 5 to the three handlers, and has a small extractReplyPath() helper verify that the claimed path bytes are present before updating reply_path_len and copying the path.

Found during an AI-assisted bounds review and checked by hand against the ANON_REQ layout. Tested with an AddressSanitizer harness covering valid, boundary and truncated reply paths, the native unit tests (pio test), and RAK_4631_repeater and Heltec_v3_repeater firmware builds. Not tested on hardware.

This branch has not been deployed

No deployments
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