Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.
TypeScript debiandeep-videojitsijitsi-meetscalable-video-conferencessfuvideovideo-communicationvideo-conferencingwebrtc
fix(polls) improve message validation (#14991)
Saúl Ibarra Corretgéfa6dc292c1ff
diff --git a/resources/prosody-plugins/mod_polls.lua b/resources/prosody-plugins/mod_polls.luaindex 5494a6f95d..6ec30864e8 100644--- a/resources/prosody-plugins/mod_polls.lua+++ b/resources/prosody-plugins/mod_polls.lua@@ -11,6 +11,9 @@ local muc = module:depends("muc");local NS_NICK = 'http://jabber.org/protocol/nick';local is_healthcheck_room = util.is_healthcheck_room;+local POLLS_LIMIT = 128;+local POLL_PAYLOAD_LIMIT = 1024;+-- Checks if the given stanza contains a JSON message,-- and that the message type pertains to the polls feature.-- If yes, returns the parsed message. Otherwise, returns nil.@@ -22,6 +25,10 @@ local function get_poll_message(stanza)if json_data == nil thenreturn nil;end+ if string.len(json_data) >= POLL_PAYLOAD_LIMIT then+ module:log('error', 'Poll payload too large, discarding. Sender: %s to:%s', stanza.attr.from, stanza.attr.to);+ return nil;+ endlocal data, error = json.decode(json_data);if not data or (data.type ~= "new-poll" and data.type ~= "answer-poll") thenif error then@@ -72,6 +79,7 @@ module:hook("muc-room-created", function(event)room.polls = {by_id = {};order = {};+ count = 0;};end);@@ -100,6 +108,11 @@ module:hook("message/bare", function(event)returnend+ if room.polls.count >= POLLS_LIMIT then+ module:log("error", "Too many polls created in %s", room.jid)+ return+ end+local answers = {}local compact_answers = {}for i, name in ipairs(data.answers) do@@ -117,6 +130,7 @@ module:hook("message/bare", function(event)room.polls.by_id[data.pollId] = polltable.insert(room.polls.order, poll)+ room.polls.count = room.polls.count + 1;local pollData = {event = event,