diff plugins/mod_c2s.lua @ 14132:1e005ba71f0d 13.0

mod_c2s, mod_s2s: Add configurable limit for stanza max child elements
author Matthew Wild <mwild1@gmail.com>
date Thu, 16 Apr 2026 18:53:34 +0100
parents 863da67a4b51
children 836a70deb3c9
line wrap: on
line diff
--- a/plugins/mod_c2s.lua	Thu Apr 16 18:52:58 2026 +0100
+++ b/plugins/mod_c2s.lua	Thu Apr 16 18:53:34 2026 +0100
@@ -30,6 +30,7 @@
 local opt_keepalives = module:get_option_boolean("c2s_tcp_keepalives", module:get_option_boolean("tcp_keepalives", true));
 local unauthed_stanza_size_limit = module:get_option_integer("c2s_unauthed_stanza_size_limit", 10000,1000);
 local authed_stanza_size_limit = module:get_option_integer("c2s_stanza_size_limit", 1024*256,10000);
+local max_child_elements = module:get_option_integer("c2s_max_child_elements", 25000, 0);
 
 local advertised_idle_timeout = 14*60; -- default in all net.server implementations
 local network_settings = module:get_option("network_settings");
@@ -355,7 +356,9 @@
 
 	session.stanza_size_limit = unauthed_stanza_size_limit;
 
-	local stream = new_xmpp_stream(session, stream_callbacks, session.stanza_size_limit);
+	local stream = new_xmpp_stream(session, stream_callbacks, session.stanza_size_limit, {
+		max_elements = max_child_elements;
+	});
 	session.stream = stream;
 	session.notopen = true;