Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/run-unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
run: python3 -B -m unittest discover -s scripts/tests -p 'test_*.py' -v

- name: Run Unit Tests
run: pio test -e native -e native_kiss_modem -e native_region_gating -e native_jwt_helper -vv
run: pio test -e native -e native_kiss_modem -e native_region_gating -e native_jwt_helper -e native_ota_channel -vv

- name: Upload Test Results
# Upload test results even if the test step failed.
Expand Down
5 changes: 5 additions & 0 deletions examples/simple_room_server/MyMesh.h
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,11 @@ class MyMesh : public mesh::Mesh, public CommonCLICallbacks
int getAGCResetInterval() const override {
return ((int)_prefs.agc_reset_interval) * 4000; // milliseconds
}
#ifdef WITH_MQTT_BRIDGE
uint32_t getRadioWatchdogMillis() const override {
return ((uint32_t)_cli.getObserverPrefs()->radio_watchdog_minutes) * 60000UL;
}
#endif
uint8_t getExtraAckTransmitCount() const override {
return _prefs.multi_acks;
}
Expand Down
8 changes: 8 additions & 0 deletions src/helpers/ESP32ManifestOTA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include <esp_image_format.h>
#include "OtaChannel.h"
#include "OtaCheckPolicy.h"
#include "OtaManifest.h"
#include <atomic>

static portMUX_TYPE ota_check_mux = portMUX_INITIALIZER_UNLOCKED;
Expand Down Expand Up @@ -363,6 +364,13 @@ bool ESP32Board::otaFromManifestImpl(const char* manifest_base, const char* curr
strcpy(reply, "ERR: manifest missing file");
return false;
}
// Only flash an image from this channel's firmware path on the same server,
// over TLS (".../mqtt/v" -> ".../mqtt/fw/", ".../mqtt/dev/v" -> ".../mqtt/dev/fw/"),
// so a tampered or mistaken manifest cannot point the device at another host.
if (!ota_url_is_https(file_url) || !ota_firmware_url_allowed(file_url, manifest_base)) {
strcpy(reply, "ERR: manifest file URL not allowed");
return false;
}

// Partition compatibility: prefer the precise per-build signature — compare the
// target build's partition layout (manifest partSig) to what's actually flashed
Expand Down
17 changes: 17 additions & 0 deletions test/test_ota_manifest/test_ota_manifest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,23 @@ TEST(OtaUrl, FirmwareElsewhereIsRefused) {
EXPECT_FALSE(ota_firmware_url_allowed(nullptr, BASE));
}

// The observer pull-OTA applies the same rule to its own channels. These are the
// layouts the live stable and dev manifests use (checked 2026-12-01).
TEST(OtaUrl, ObserverChannelsAllowOnlyTheirOwnFwPath) {
const char* stable = "https://ota.dutchmeshcore.nl/mqtt/v";
const char* dev = "https://ota.dutchmeshcore.nl/mqtt/dev/v";
const char* stable_fw =
"https://ota.dutchmeshcore.nl/mqtt/fw/dmc-repeater-mqtt-v1.18.0.1/heltec_v4_repeater_observer_mqtt-v1.18.0.1-f314fba.bin";
const char* dev_fw =
"https://ota.dutchmeshcore.nl/mqtt/dev/fw/observer-mqtt-dev/heltec_v4_repeater_observer_mqtt-v1.18.0.1-f314fba.bin";
EXPECT_TRUE(ota_firmware_url_allowed(stable_fw, stable));
EXPECT_TRUE(ota_firmware_url_allowed(dev_fw, dev));
// a channel's manifest cannot hand out the other channel's images, or another product's
EXPECT_FALSE(ota_firmware_url_allowed(stable_fw, dev));
EXPECT_FALSE(ota_firmware_url_allowed(dev_fw, stable));
EXPECT_FALSE(ota_firmware_url_allowed("https://ota.dutchmeshcore.nl/meshcomod/fw/a/b.bin", stable));
}

TEST(OtaUrl, BaseWithoutTrailingVAllowsNothing) {
EXPECT_FALSE(ota_firmware_url_allowed("https://ota.dutchmeshcore.nl/meshcomod/fw/a.bin",
"https://ota.dutchmeshcore.nl/meshcomod"));
Expand Down
Loading