Skip to content

Fix repeater login failure after companion reboot and enforce ACL login timestamp updates - #3631

Open
radek-sixi wants to merge 1 commit into
meshcore-dev:devfrom
radek-sixi:fix/repeater-login-after-companion-reboot
Open

radek-sixi wants to merge 1 commit into
meshcore-dev:devfrom
radek-sixi:fix/repeater-login-after-companion-reboot

Conversation

@radek-sixi

Copy link
Copy Markdown

Fixes #3482

Problem

Users reported in #3482 that rebooting a companion node (such as Heltec V4) after logging into a repeater prevents subsequent logins or post-login admin/status commands until the repeater itself is physically rebooted:

  1. Companion RTC stepped backwards on reboot (BaseChatMesh::bootstrapRTCfromContacts()):
    On ESP32 boards (ESP32RTCClock::begin(), which restores _rtc_backup_time from RTC_NOINIT_ATTR) or boards with an external I2C RTC (AutoDiscoverRTCClock::begin()), the RTC clock already holds the current time on boot. However, MyMesh::begin() then calls bootstrapRTCfromContacts(), which unconditionally calls getRTCClock()->setCurrentTime(latest + 1) without checking whether latest >= getRTCClock()->getCurrentTime(). Because logging into a repeater and sending admin/status requests does not modify persisted contacts on flash, latest + 1 is older than the timestamps already sent to the repeater before the reboot, stepping the companion's RTC backwards (and overwriting _rtc_backup_time).
  2. Inconsistent timestamp handling on blank-password (ACL) login (handleLoginReq / onAnonDataRecv):
    • When logging in with a password after the companion's clock stepped backwards, sender_timestamp <= client->last_timestamp rejects the login attempt (Failed to login).
    • When logging in with a blank password via ACL (data[0] == 0), client = acl.getClient(...) is non-NULL, which previously skipped the if (client == NULL) block entirely. As a result, handleLoginReq neither checked sender_timestamp <= client->last_timestamp nor updated client->last_timestamp and client->last_activity (and on Room Server also skipped updating sync_since, pending_ack, and push_failures). It returned RESP_SERVER_LOGIN_OK (so the UI reported being logged in as admin), while client->last_timestamp remained stuck at the pre-reboot value and caused onPeerDataRecv() to silently drop all subsequent status/clock-sync/CLI requests as replay attacks.

Fix

  • In BaseChatMesh::bootstrapRTCfromContacts(), only advance the RTC clock to latest + 1 when latest >= getRTCClock()->getCurrentTime().
  • In simple_repeater, simple_room_server, and simple_sensor, validate sender_timestamp > client->last_timestamp and update client->last_timestamp and client->last_activity (plus room sync state on simple_room_server) on both ACL (blank-password) and password login paths.

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