# HG changeset patch # User Kim Alvefur # Date 1773447567 -3600 # Node ID a1fb05cbd44eac2faaf5ebbcc1c7bdbbcb772d1f # Parent 27e97e5b2c161f7e6ed017b6f83a9c64f6d1e96a mod_s2s: Fully validate stream addressing NAMEPREP is not enough to validate an XMPP hostpart, missing IDNA and the IP literal special cases. diff -r 27e97e5b2c16 -r a1fb05cbd44e plugins/mod_s2s.lua --- 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;