diff options
author | Matthew Wild <mwild1@gmail.com> | 2011-06-01 23:20:54 +0100 |
---|---|---|
committer | Matthew Wild <mwild1@gmail.com> | 2011-06-01 23:20:54 +0100 |
commit | eca112c21aec5a646a18d1b6f6150b63535b4347 (patch) | |
tree | 5516591b31f3c4ce17909b5ec3baa39ac907af69 | |
parent | 5df3474dd218fd4f6a65b196cf206a1a720c51a8 (diff) | |
download | prosody-eca112c21aec5a646a18d1b6f6150b63535b4347.tar.gz prosody-eca112c21aec5a646a18d1b6f6150b63535b4347.zip |
xmlhandlers: Reject XML comments, processing instructions and (if supported by LuaExpat) DTDs. If not supported, log a warning. [Backport of 7cc426988bcc in trunk]
-rw-r--r-- | core/xmlhandlers.lua | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/core/xmlhandlers.lua b/core/xmlhandlers.lua index c6684305..6a5cac85 100644 --- a/core/xmlhandlers.lua +++ b/core/xmlhandlers.lua @@ -19,6 +19,16 @@ local t_concat = table.concat; local default_log = require "util.logger".init("xmlhandlers"); +-- COMPAT: w/LuaExpat 1.1.0 +local lxp_supports_doctype = pcall(lxp.new, { StartDoctypeDecl = false }); + +if not lxp_supports_doctype then + default_log("warn", "The version of LuaExpat on your system leaves Prosody " + .."vulnerable to denial-of-service attacks. You should upgrade to " + .."LuaExpat 1.1.1 or higher as soon as possible. See " + .."http://prosody.im/doc/depends#luaexpat for more information."); +end + local error = error; module "xmlhandlers" @@ -134,6 +144,18 @@ function init_xmlhandlers(session, stream_callbacks) stanza:up(); end end + + local function restricted_handler() + cb_error(session, "parse-error", "restricted-xml", "Restricted XML, see RFC 6120 section 11.1."); + end + + if lxp_supports_doctype then + xml_handlers.StartDoctypeDecl = restricted_handler; + end + xml_handlers.Comment = restricted_handler; + xml_handlers.StartCdataSection = restricted_handler; + xml_handlers.ProcessingInstruction = restricted_handler; + return xml_handlers; end |