Software /
code /
prosody
Changeset
4275:5305a665bdd4
util.xmppstream: Reject XML comments, processing instructions and (if supported by LuaExpat) DTDs. If not supported, log a warning.
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Wed, 01 Jun 2011 23:02:10 +0100 |
parents | 4260:403aba5e49d5 |
children | 4278:67ce42aa7419 |
files | util/xmppstream.lua |
diffstat | 1 files changed, 21 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/util/xmppstream.lua Wed May 04 23:12:53 2011 +0100 +++ b/util/xmppstream.lua Wed Jun 01 23:02:10 2011 +0100 @@ -16,6 +16,16 @@ local default_log = require "util.logger".init("xmppstream"); +-- 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 "xmppstream" @@ -150,6 +160,17 @@ 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; + local function reset() stanza, chardata = nil, {}; end