From c53ac6d59c3dccf673a2836315c6c988ab9cd93b Mon Sep 17 00:00:00 2001 From: HeavenVR Date: Sat, 5 Dec 2026 02:20:12 +0100 Subject: [PATCH] fix(core): skip null entries in shocker command lists The FlatBuffers verifier accepts a zero offset in a vector of tables, so a ShockerCommandList can pass verification with a null entry. The handler dereferenced every entry, letting a local WebSocket client crash the hub. Skip and log null entries instead. Resolves code scanning alert #11 (CWE-476). --- .changes/skip-null-shocker-command.md | 11 +++++++++++ .../core/src/message_handlers/ShockerCommandList.cpp | 6 ++++++ 2 files changed, 17 insertions(+) create mode 100644 .changes/skip-null-shocker-command.md diff --git a/.changes/skip-null-shocker-command.md b/.changes/skip-null-shocker-command.md new file mode 100644 index 000000000..d9c22de2c --- /dev/null +++ b/.changes/skip-null-shocker-command.md @@ -0,0 +1,11 @@ +--- +kind: security +--- +Skip null entries in a shocker command list instead of crashing + +## Release Note +Malformed shocker commands no longer crash the hub + +A command list with an empty entry, sent over the setup portal or the gateway connection, is now skipped instead of crashing the hub. + +- The FlatBuffers verifier accepts a zero offset in a vector of tables, so each entry is now checked before it is read diff --git a/components/core/src/message_handlers/ShockerCommandList.cpp b/components/core/src/message_handlers/ShockerCommandList.cpp index 646f38ef1..7d47ce855 100644 --- a/components/core/src/message_handlers/ShockerCommandList.cpp +++ b/components/core/src/message_handlers/ShockerCommandList.cpp @@ -57,6 +57,12 @@ void OpenShock::MessageHandlers::HandleShockerCommandList(const OpenShock::Seria OS_LOGV(TAG, "Received command list (%u commands)", static_cast(commands->size())); for (auto command : *commands) { + // The verifier accepts a zero offset in a vector of tables, so an entry can be null + if (command == nullptr) { + OS_LOGE(TAG, "Received null command in command list"); + continue; + } + uint16_t id = command->id(); uint8_t intensity = command->intensity(); uint16_t durationMs = command->duration();