Skip to content
Open
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
11 changes: 11 additions & 0 deletions .changes/ota-version-validation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
kind: security
---
Reject OTA update requests with an invalid version

## Release Note
Firmware updates reject malformed version numbers

An update request whose version is not a valid version number is now refused, so it can no longer change which file the hub downloads.

- The gateway OTA handler and OtaUpdateManager::TryStartFirmwareUpdate both call SemVer::isValid() before the version reaches the firmware repository URL
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ void _Private::HandleOtaUpdateRequest(OpenShock::GatewayClient&, const OpenShock
}

OpenShock::SemVer version(semver->major(), semver->minor(), semver->patch(), prerelease, build);
if (!version.isValid()) {
OS_LOGE(TAG, "OTA update requested with an invalid version");
return;
}

OS_LOGI(
TAG,
Expand Down
6 changes: 6 additions & 0 deletions components/ota/src/OtaUpdateManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -815,6 +815,12 @@ std::optional<OtaUpdateManager::FirmwareRelease> OtaUpdateManager::TryGetFirmwar

bool OtaUpdateManager::TryStartFirmwareUpdate(const OpenShock::SemVer& version)
{
// The version ends up in the firmware repository URL path: only the SemVer grammar may get there
if (!version.isValid()) {
OS_LOGE(TAG, "Rejecting firmware update to an invalid version");
return false;
}

OS_LOGD(TAG, "Requesting firmware version " SEMVER_FMT, SEMVER_ARG(version));

return otaum_try_queue_update_request(version);
Expand Down
Loading