plugins/mod_server_contact_info.lua
author Jonas Schäfer <jonas@wielicki.name>
Mon, 10 Jan 2022 18:23:54 +0100
branch0.11
changeset 12185 783056b4e448
parent 9431 8e7feec95e8d
child 11014 6b27cb706b89
permissions -rw-r--r--
util.xml: Do not allow doctypes, comments or processing instructions Yes. This is as bad as it sounds. CVE pending. In Prosody itself, this only affects mod_websocket, which uses util.xml to parse the <open/> frame, thus allowing unauthenticated remote DoS using Billion Laughs. However, third-party modules using util.xml may also be affected by this. This commit installs handlers which disallow the use of doctype declarations and processing instructions without any escape hatch. It, by default, also introduces such a handler for comments, however, there is a way to enable comments nontheless. This is because util.xml is used to parse human-facing data, where comments are generally a desirable feature, and also because comments are generally harmless.

-- XEP-0157: Contact Addresses for XMPP Services for Prosody
--
-- Copyright (C) 2011-2018 Kim Alvefur
--
-- This project is MIT/X11 licensed. Please see the
-- COPYING file in the source package for more information.
--

local array = require "util.array";

-- Source: http://xmpp.org/registrar/formtypes.html#http:--jabber.org-network-serverinfo
local form_layout = require "util.dataforms".new({
	{ var = "FORM_TYPE"; type = "hidden"; value = "http://jabber.org/network/serverinfo"; };
	{ name = "abuse", var = "abuse-addresses", type = "list-multi" },
	{ name = "admin", var = "admin-addresses", type = "list-multi" },
	{ name = "feedback", var = "feedback-addresses", type = "list-multi" },
	{ name = "sales", var = "sales-addresses", type = "list-multi" },
	{ name = "security", var = "security-addresses", type = "list-multi" },
	{ name = "support", var = "support-addresses", type = "list-multi" },
});

-- JIDs of configured service admins are used as fallback
local admins = module:get_option_inherited_set("admins", {});

local contact_config = module:get_option("contact_info", {
	admin = array.collect( admins / function(admin) return "xmpp:" .. admin; end);
});

module:add_extension(form_layout:form(contact_config, "result"));