Skip to content

Commit b29a008

Browse files
committed
firmware-update: Only allow HTTPS update URLs
To protect the download of the firmware list from manipulation.
1 parent 90d9212 commit b29a008

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

software/src/modules/firmware_update/firmware_update.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,17 @@ extern "C" esp_err_t esp_crt_bundle_attach(void *conf);
4343

4444
void FirmwareUpdate::pre_setup()
4545
{
46-
config = Config::Object({
46+
config = ConfigRoot{Config::Object({
4747
{"update_url", Config::Str("", 0, 128)},
4848
{"cert_id", Config::Int(-1, -1, MAX_CERT_ID)},
49-
}); // FIXME: add validator to only accept https:// update URLs
49+
}), [this](Config &update, ConfigSource source) -> String {
50+
String update_url = update.get("update_url")->asString();
51+
52+
if (update_url.length() > 0 && !update_url.startsWith("https://"))
53+
return "HTTPS required for update URL";
54+
55+
return "";
56+
}};
5057

5158
available_updates = Config::Object({
5259
{"timestamp", Config::Uint(0)},

0 commit comments

Comments
 (0)