changeset 14104:a1fb05cbd44e 13.0

mod_s2s: Fully validate stream addressing NAMEPREP is not enough to validate an XMPP hostpart, missing IDNA and the IP literal special cases.
author Kim Alvefur <zash@zash.se>
date Sat, 14 Mar 2026 01:19:27 +0100
parents 27e97e5b2c16
children 4ed802e45af6
files plugins/mod_s2s.lua
diffstat 1 files changed, 7 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/mod_s2s.lua	Sat Mar 14 01:16:14 2026 +0100
+++ b/plugins/mod_s2s.lua	Sat Mar 14 01:19:27 2026 +0100
@@ -19,7 +19,7 @@
 local stop_timer = require "prosody.util.timer".stop;
 local st = require "prosody.util.stanza";
 local initialize_filters = require "prosody.util.filters".initialize;
-local nameprep = require "prosody.util.encodings".stringprep.nameprep;
+local prepped_split = require "prosody.util.jid".prepped_split;
 local new_xmpp_stream = require "prosody.util.xmppstream".new;
 local s2s_new_incoming = require "prosody.core.s2smanager".new_incoming;
 local s2s_new_outgoing = require "prosody.core.s2smanager".new_outgoing;
@@ -490,8 +490,12 @@
 
 		-- Validate to/from
 		local to, from = attr.to, attr.from;
-		if to then to = nameprep(attr.to); end
-		if from then from = nameprep(attr.from); end
+		local function hostprep(s)
+			local node, host, res = prepped_split(s);
+			if not (node or res) then return host; end
+		end
+		if to then to = hostprep(attr.to); end
+		if from then from = hostprep(attr.from); end
 		if not to and attr.to then -- COMPAT: Some servers do not reliably set 'to' (especially on stream restarts)
 			session:close({ condition = "improper-addressing", text = "Invalid 'to' address" });
 			return;