Version in base suite: 2.0.17-1 Base version: anope_2.0.17-1 Target version: anope_2.0.17-1+deb13u1 Base file: /srv/ftp-master.debian.org/ftp/pool/main/a/anope/anope_2.0.17-1.dsc Target file: /srv/ftp-master.debian.org/policy/pool/main/a/anope/anope_2.0.17-1+deb13u1.dsc changelog | 23 patches/0001-Sanitise-messages-before-writing-them-to-the-log.patch | 22 patches/0002-Reject-unsafe-characters-in-commands-run-from-the-we.patch | 70 + patches/0003-Don-t-copy-memos-when-cloning-a-channel.patch | 20 patches/0004-Fix-an-unsafe-substr-in-ns_alist.patch | 27 patches/0005-Avoid-repeatedly-checking-if-a-user-has-deep-access-.patch | 52 patches/0006-Fix-a-hang-caused-by-user-provided-massive-number-ra.patch | 64 + patches/0007-Fix-bypassing-unconfirmed-status-via-grouping-and-un.patch | 21 patches/0008-Fix-identifying-users-as-the-wrong-account-when-conf.patch | 33 patches/0009-Use-a-stricter-cookie-policy-in-the-httpd-module.patch | 21 patches/0010-Backport-the-random-number-generation-changes-from-2.patch | 186 +++ patches/0011-Add-origin-filtering-to-the-web-panel.patch | 200 +++ patches/0012-Properly-sanitise-get-post-data-in-the-webcpanel-mod.patch | 591 ++++++++++ patches/Add-EscapeDN-and-EscapeSF-to-the-LDAP-API.patch | 115 + patches/Escape-user-provided-values-in-ldap_authentication-and-ld.patch | 52 patches/Fix-an-escaped-value-that-wasn-t-escaped-enough-in-chanst.patch | 31 patches/Fix-resetpass-confirming-accounts-when-not-using-email-co.patch | 24 patches/Fix-sql_live-on-recent-MariaDB.patch | 25 patches/series | 17 19 files changed, 1594 insertions(+) dpkg-source: warning: cannot verify inline signature for /srv/release.debian.org/tmp/tmptpbea2ne/anope_2.0.17-1.dsc: no acceptable signature found dpkg-source: warning: cannot verify inline signature for /srv/release.debian.org/tmp/tmptpbea2ne/anope_2.0.17-1+deb13u1.dsc: no acceptable signature found diff -Nru anope-2.0.17/debian/changelog anope-2.0.17/debian/changelog --- anope-2.0.17/debian/changelog 2025-03-24 21:58:25.000000000 +0000 +++ anope-2.0.17/debian/changelog 2026-11-22 15:40:50.000000000 +0000 @@ -1,3 +1,26 @@ +anope (2.0.17-1+deb13u1) trixie-security; urgency=high + + * Fix multiple security issues cherry-picked from 2.0.21 including + - Nickname impersonation/takeover + - Raw command injection in webcpanel + - Memos could leak across channels + - Static seeds were used for password reset codes possibly + allowing account takeover + - Email confirmation bypass + - Other DoS issues (crash and CPU exhaustion) + - Security fixes in webcpanel (which is not shipped in Debian binary + packages) are also included: + - Raw command injection in webcpanel + - XSRF issues + * Closes: #1154835 + * Fix multiple security issues cherry-picked from 2.0.19 and 2.0.20 + - SQL injection in m_chanstats + - LDAP injection in ldap_authentication and ldap_oper + - RESETPASS bypasses admin approval + * Fix SQL backend on MariaDB (Closes: #1128799) + + -- Dominic Hargreaves Sun, 22 Nov 2026 15:40:50 +0000 + anope (2.0.17-1) unstable; urgency=medium * New upstream release (Closes: #1089533) diff -Nru anope-2.0.17/debian/patches/0001-Sanitise-messages-before-writing-them-to-the-log.patch anope-2.0.17/debian/patches/0001-Sanitise-messages-before-writing-them-to-the-log.patch --- anope-2.0.17/debian/patches/0001-Sanitise-messages-before-writing-them-to-the-log.patch 1970-01-01 00:00:00.000000000 +0000 +++ anope-2.0.17/debian/patches/0001-Sanitise-messages-before-writing-them-to-the-log.patch 2026-11-22 15:40:50.000000000 +0000 @@ -0,0 +1,22 @@ +From: Sadie Powell +Date: Fri, 20 Nov 2026 13:45:37 +0000 +Subject: Sanitise messages before writing them to the log. + +--- + src/logger.cpp | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/src/logger.cpp b/src/logger.cpp +index 0e54fb7..3707178 100644 +--- a/src/logger.cpp ++++ b/src/logger.cpp +@@ -349,7 +349,8 @@ void LogInfo::ProcessMessage(const Log *l) + return; + } + +- const Anope::string &buffer = l->BuildPrefix() + l->buf.str(); ++ Anope::string buffer = l->BuildPrefix() + l->buf.str(); ++ buffer = buffer.replace_all_cs('\0', ' ').replace_all_cs('\r', ' ').replace_all_cs('\n', ' '); + + FOREACH_MOD(OnLogMessage, (this, l, buffer)); + diff -Nru anope-2.0.17/debian/patches/0002-Reject-unsafe-characters-in-commands-run-from-the-we.patch anope-2.0.17/debian/patches/0002-Reject-unsafe-characters-in-commands-run-from-the-we.patch --- anope-2.0.17/debian/patches/0002-Reject-unsafe-characters-in-commands-run-from-the-we.patch 1970-01-01 00:00:00.000000000 +0000 +++ anope-2.0.17/debian/patches/0002-Reject-unsafe-characters-in-commands-run-from-the-we.patch 2026-11-22 15:40:50.000000000 +0000 @@ -0,0 +1,70 @@ +From: Sadie Powell +Date: Fri, 20 Nov 2026 13:45:37 +0000 +Subject: Reject unsafe characters in commands run from the web panel. + +--- + modules/webcpanel/webcpanel.cpp | 23 +++++++++++++++++++++++ + modules/webcpanel/webcpanel.h | 2 ++ + 2 files changed, 25 insertions(+) + +diff --git a/modules/webcpanel/webcpanel.cpp b/modules/webcpanel/webcpanel.cpp +index ec7d4bc..3b2526d 100644 +--- a/modules/webcpanel/webcpanel.cpp ++++ b/modules/webcpanel/webcpanel.cpp +@@ -240,6 +240,17 @@ class ModuleWebCPanel : public Module + + namespace WebPanel + { ++ bool CheckParams(const std::vector ¶ms) ++ { ++ static Anope::string invalid("\r\n\0", 3); ++ for (std::vector::const_iterator it = params.begin(); it != params.end(); ++it) ++ { ++ if (it->length() > 512 || it->find_first_of(invalid) != Anope::string::npos) ++ return false; ++ } ++ return true; ++ } ++ + void RunCommand(HTTPClient *client, const Anope::string &user, NickCore *nc, const Anope::string &service, const Anope::string &c, std::vector ¶ms, TemplateFileServer::Replacements &r, const Anope::string &key) + { + ServiceReference cmd("Command", c); +@@ -249,6 +260,12 @@ namespace WebPanel + return; + } + ++ if (!CheckParams(params)) ++ { ++ r[key] = "Unsafe characters found in input"; ++ return; ++ } ++ + if (params.size() < cmd->min_params) + return; + +@@ -292,6 +309,12 @@ namespace WebPanel + return; + } + ++ if (!CheckParams(params)) ++ { ++ r[key] = "Unsafe characters found in input"; ++ return; ++ } ++ + BotInfo *bi = Config->GetClient(service); + if (!bi) + return; +diff --git a/modules/webcpanel/webcpanel.h b/modules/webcpanel/webcpanel.h +index 72bd5ac..3dbdcf4 100644 +--- a/modules/webcpanel/webcpanel.h ++++ b/modules/webcpanel/webcpanel.h +@@ -155,6 +155,8 @@ namespace WebPanel + extern void RunCommand(HTTPClient *client, const Anope::string &user, NickCore *nc, const Anope::string &service, const Anope::string &c, std::vector ¶ms, TemplateFileServer::Replacements &r, const Anope::string &key = "MESSAGES"); + + extern void RunCommandWithName(HTTPClient *client, NickCore *nc, const Anope::string &service, const Anope::string &c, const Anope::string &cmdname, std::vector ¶ms, TemplateFileServer::Replacements &r, const Anope::string &key = "MESSAGES"); ++ ++ extern bool CheckParams(const std::vector ¶ms); + } + + #include "pages/index.h" diff -Nru anope-2.0.17/debian/patches/0003-Don-t-copy-memos-when-cloning-a-channel.patch anope-2.0.17/debian/patches/0003-Don-t-copy-memos-when-cloning-a-channel.patch --- anope-2.0.17/debian/patches/0003-Don-t-copy-memos-when-cloning-a-channel.patch 1970-01-01 00:00:00.000000000 +0000 +++ anope-2.0.17/debian/patches/0003-Don-t-copy-memos-when-cloning-a-channel.patch 2026-11-22 15:40:50.000000000 +0000 @@ -0,0 +1,20 @@ +From: Sadie Powell +Date: Fri, 20 Nov 2026 13:45:37 +0000 +Subject: Don't copy memos when cloning a channel. + +--- + src/regchannel.cpp | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/src/regchannel.cpp b/src/regchannel.cpp +index 5578735..5ed49a6 100644 +--- a/src/regchannel.cpp ++++ b/src/regchannel.cpp +@@ -134,6 +134,7 @@ ChannelInfo::ChannelInfo(const ChannelInfo &ci) : Serializable("ChannelInfo"), + + this->access->clear(); + this->akick->clear(); ++ this->memos = MemoInfo(); + + FOREACH_MOD(OnCreateChan, (this)); + } diff -Nru anope-2.0.17/debian/patches/0004-Fix-an-unsafe-substr-in-ns_alist.patch anope-2.0.17/debian/patches/0004-Fix-an-unsafe-substr-in-ns_alist.patch --- anope-2.0.17/debian/patches/0004-Fix-an-unsafe-substr-in-ns_alist.patch 1970-01-01 00:00:00.000000000 +0000 +++ anope-2.0.17/debian/patches/0004-Fix-an-unsafe-substr-in-ns_alist.patch 2026-11-22 15:40:50.000000000 +0000 @@ -0,0 +1,27 @@ +From: Sadie Powell +Date: Fri, 20 Nov 2026 13:45:37 +0000 +Subject: Fix an unsafe substr in ns_alist. + +--- + modules/commands/ns_alist.cpp | 7 +++++-- + 1 file changed, 5 insertions(+), 2 deletions(-) + +diff --git a/modules/commands/ns_alist.cpp b/modules/commands/ns_alist.cpp +index e34b3b2..99e5a61 100644 +--- a/modules/commands/ns_alist.cpp ++++ b/modules/commands/ns_alist.cpp +@@ -95,9 +95,12 @@ class CommandNSAList : public Command + continue; + + ChanAccess *a = p[0]; +- entry["Access"] = entry["Access"] + ", " + a->AccessSerialize(); ++ ++ Anope::string &accessmsg = entry["Access"]; ++ if (!accessmsg.empty()) ++ accessmsg += ", "; ++ accessmsg += a->AccessSerialize(); + } +- entry["Access"] = entry["Access"].substr(2); + entry["Description"] = ci->desc; + list.AddEntry(entry); + } diff -Nru anope-2.0.17/debian/patches/0005-Avoid-repeatedly-checking-if-a-user-has-deep-access-.patch anope-2.0.17/debian/patches/0005-Avoid-repeatedly-checking-if-a-user-has-deep-access-.patch --- anope-2.0.17/debian/patches/0005-Avoid-repeatedly-checking-if-a-user-has-deep-access-.patch 1970-01-01 00:00:00.000000000 +0000 +++ anope-2.0.17/debian/patches/0005-Avoid-repeatedly-checking-if-a-user-has-deep-access-.patch 2026-11-22 15:40:50.000000000 +0000 @@ -0,0 +1,52 @@ +From: Sadie Powell +Date: Fri, 20 Nov 2026 13:45:37 +0000 +Subject: Avoid repeatedly checking if a user has deep access on a channel. + +--- + src/regchannel.cpp | 11 +++++++---- + 1 file changed, 7 insertions(+), 4 deletions(-) + +diff --git a/src/regchannel.cpp b/src/regchannel.cpp +index 5ed49a6..44f647d 100644 +--- a/src/regchannel.cpp ++++ b/src/regchannel.cpp +@@ -384,11 +384,13 @@ ChanAccess *ChannelInfo::GetAccess(unsigned index) const + return acc; + } + +-static void FindMatchesRecurse(ChannelInfo *ci, const User *u, const NickCore *account, unsigned int depth, std::vector &paths, ChanAccess::Path &path) ++static void FindMatchesRecurse(ChannelInfo *ci, const User *u, const NickCore *account, unsigned int depth, ++ std::vector &paths, ChanAccess::Path &path, std::set &checked) + { + if (depth > ChanAccess::MAX_DEPTH) + return; + ++ checked.insert(ci); + for (unsigned int i = 0; i < ci->GetAccessCount(); ++i) + { + ChanAccess *a = ci->GetAccess(i); +@@ -401,20 +403,21 @@ static void FindMatchesRecurse(ChannelInfo *ci, const User *u, const NickCore *a + + paths.push_back(next_path); + } +- else if (next) ++ else if (next && !checked.count(next)) + { + ChanAccess::Path next_path = path; + next_path.push_back(a); + +- FindMatchesRecurse(next, u, account, depth + 1, paths, next_path); ++ FindMatchesRecurse(next, u, account, depth + 1, paths, next_path, checked); + } + } + } + + static void FindMatches(AccessGroup &group, ChannelInfo *ci, const User *u, const NickCore *account) + { ++ std::set checked; + ChanAccess::Path path; +- FindMatchesRecurse(ci, u, account, 0, group.paths, path); ++ FindMatchesRecurse(ci, u, account, 0, group.paths, path, checked); + } + + AccessGroup ChannelInfo::AccessFor(const User *u, bool updateLastUsed) diff -Nru anope-2.0.17/debian/patches/0006-Fix-a-hang-caused-by-user-provided-massive-number-ra.patch anope-2.0.17/debian/patches/0006-Fix-a-hang-caused-by-user-provided-massive-number-ra.patch --- anope-2.0.17/debian/patches/0006-Fix-a-hang-caused-by-user-provided-massive-number-ra.patch 1970-01-01 00:00:00.000000000 +0000 +++ anope-2.0.17/debian/patches/0006-Fix-a-hang-caused-by-user-provided-massive-number-ra.patch 2026-11-22 15:40:50.000000000 +0000 @@ -0,0 +1,64 @@ +From: Sadie Powell +Date: Fri, 20 Nov 2026 13:45:37 +0000 +Subject: Fix a hang caused by user-provided massive number ranges. + +--- + include/lists.h | 3 +++ + src/misc.cpp | 13 +++++++++++++ + 2 files changed, 16 insertions(+) + +diff --git a/include/lists.h b/include/lists.h +index 9cda9ad..065bbfe 100644 +--- a/include/lists.h ++++ b/include/lists.h +@@ -30,6 +30,9 @@ class CoreExport NumberList + std::set numbers; + + bool desc; ++ ++ static const unsigned int MAX_NUMBERS = 9999; ++ + public: + /** Processes a numbered list + * @param list The list +diff --git a/src/misc.cpp b/src/misc.cpp +index 9a3285c..8cc9cda 100644 +--- a/src/misc.cpp ++++ b/src/misc.cpp +@@ -27,6 +27,8 @@ + #include + #endif + ++#include ++ + NumberList::NumberList(const Anope::string &list, bool descending) : is_valid(true), desc(descending) + { + Anope::string error; +@@ -46,7 +48,11 @@ NumberList::NumberList(const Anope::string &list, bool descending) : is_valid(tr + { + unsigned num = convertTo(token, error, false); + if (error.empty()) ++ { + numbers.insert(num); ++ if (numbers.size() >= MAX_NUMBERS) ++ return; ++ } + } + catch (const ConvertException &) + { +@@ -70,8 +76,15 @@ NumberList::NumberList(const Anope::string &list, bool descending) : is_valid(tr + unsigned num1 = convertTo(token.substr(0, t), error, false); + unsigned num2 = convertTo(token.substr(t + 1), error2, false); + if (error.empty() && error2.empty()) ++ { ++ num2 = std::min(std::numeric_limits::max() - 1, num2); + for (unsigned i = num1; i <= num2; ++i) ++ { + numbers.insert(i); ++ if (numbers.size() >= MAX_NUMBERS) ++ return; ++ } ++ } + } + catch (const ConvertException &) + { diff -Nru anope-2.0.17/debian/patches/0007-Fix-bypassing-unconfirmed-status-via-grouping-and-un.patch anope-2.0.17/debian/patches/0007-Fix-bypassing-unconfirmed-status-via-grouping-and-un.patch --- anope-2.0.17/debian/patches/0007-Fix-bypassing-unconfirmed-status-via-grouping-and-un.patch 1970-01-01 00:00:00.000000000 +0000 +++ anope-2.0.17/debian/patches/0007-Fix-bypassing-unconfirmed-status-via-grouping-and-un.patch 2026-11-22 15:40:50.000000000 +0000 @@ -0,0 +1,21 @@ +From: Sadie Powell +Date: Fri, 20 Nov 2026 13:45:37 +0000 +Subject: Fix bypassing unconfirmed status via grouping and ungrouping. + +--- + modules/commands/ns_group.cpp | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/modules/commands/ns_group.cpp b/modules/commands/ns_group.cpp +index 0bc49da..539885b 100644 +--- a/modules/commands/ns_group.cpp ++++ b/modules/commands/ns_group.cpp +@@ -267,6 +267,8 @@ class CommandNSUngroup : public Command + if (!oldcore->email.empty()) + nc->email = oldcore->email; + nc->language = oldcore->language; ++ if (oldcore->HasExt("UNCONFIRMED")) ++ nc->Extend("UNCONFIRMED"); + + Log(LOG_COMMAND, source, this) << "to make " << na->nick << " leave group of " << oldcore->display << " (email: " << (!oldcore->email.empty() ? oldcore->email : "none") << ")"; + source.Reply(_("Nick %s has been ungrouped from %s."), na->nick.c_str(), oldcore->display.c_str()); diff -Nru anope-2.0.17/debian/patches/0008-Fix-identifying-users-as-the-wrong-account-when-conf.patch anope-2.0.17/debian/patches/0008-Fix-identifying-users-as-the-wrong-account-when-conf.patch --- anope-2.0.17/debian/patches/0008-Fix-identifying-users-as-the-wrong-account-when-conf.patch 1970-01-01 00:00:00.000000000 +0000 +++ anope-2.0.17/debian/patches/0008-Fix-identifying-users-as-the-wrong-account-when-conf.patch 2026-11-22 15:40:50.000000000 +0000 @@ -0,0 +1,33 @@ +From: Sadie Powell +Date: Fri, 20 Nov 2026 13:45:37 +0000 +Subject: Fix identifying users as the wrong account when confirming. + +--- + modules/commands/ns_register.cpp | 13 +++++-------- + 1 file changed, 5 insertions(+), 8 deletions(-) + +diff --git a/modules/commands/ns_register.cpp b/modules/commands/ns_register.cpp +index 8b15b00..3743478 100644 +--- a/modules/commands/ns_register.cpp ++++ b/modules/commands/ns_register.cpp +@@ -70,15 +70,12 @@ class CommandNSConfirm : public Command + nc->Shrink("UNCONFIRMED"); + FOREACH_MOD(OnNickConfirm, (source.GetUser(), nc)); + +- if (source.GetUser()) ++ NickAlias *na = NickAlias::Find(nc->display); ++ if (na && source.GetUser()) // na should always be available here. + { +- NickAlias *na = NickAlias::Find(source.GetNick()); +- if (na) +- { +- IRCD->SendLogin(source.GetUser(), na); +- if (!Config->GetModule("nickserv")->Get("nonicknameownership") && na->nc == source.GetAccount() && !na->nc->HasExt("UNCONFIRMED")) +- source.GetUser()->SetMode(source.service, "REGISTERED"); +- } ++ IRCD->SendLogin(source.GetUser(), na); ++ if (!Config->GetModule("nickserv")->Get("nonicknameownership") && na->nick.equals_ci(source.GetNick()) && !na->nc->HasExt("UNCONFIRMED")) ++ source.GetUser()->SetMode(source.service, "REGISTERED"); + } + } + else diff -Nru anope-2.0.17/debian/patches/0009-Use-a-stricter-cookie-policy-in-the-httpd-module.patch anope-2.0.17/debian/patches/0009-Use-a-stricter-cookie-policy-in-the-httpd-module.patch --- anope-2.0.17/debian/patches/0009-Use-a-stricter-cookie-policy-in-the-httpd-module.patch 1970-01-01 00:00:00.000000000 +0000 +++ anope-2.0.17/debian/patches/0009-Use-a-stricter-cookie-policy-in-the-httpd-module.patch 2026-11-22 15:40:50.000000000 +0000 @@ -0,0 +1,21 @@ +From: Sadie Powell +Date: Fri, 20 Nov 2026 13:45:37 +0000 +Subject: Use a stricter cookie policy in the httpd module. + +--- + modules/m_httpd.cpp | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/modules/m_httpd.cpp b/modules/m_httpd.cpp +index adb17c1..09577cd 100644 +--- a/modules/m_httpd.cpp ++++ b/modules/m_httpd.cpp +@@ -262,7 +262,7 @@ class MyHTTPClient : public HTTPClient + for (HTTPReply::cookie::iterator it = msg->cookies[i].begin(), it_end = msg->cookies[i].end(); it != it_end; ++it) + buf += " " + it->first + "=" + it->second + ";"; + +- buf.erase(buf.length() - 1); ++ buf += " HttpOnly; SameSite=Strict"; + + this->WriteClient(buf); + } diff -Nru anope-2.0.17/debian/patches/0010-Backport-the-random-number-generation-changes-from-2.patch anope-2.0.17/debian/patches/0010-Backport-the-random-number-generation-changes-from-2.patch --- anope-2.0.17/debian/patches/0010-Backport-the-random-number-generation-changes-from-2.patch 1970-01-01 00:00:00.000000000 +0000 +++ anope-2.0.17/debian/patches/0010-Backport-the-random-number-generation-changes-from-2.patch 2026-11-22 15:40:50.000000000 +0000 @@ -0,0 +1,186 @@ +From: Sadie Powell +Date: Fri, 20 Nov 2026 13:45:37 +0000 +Subject: Backport the random number generation changes from 2.1. + +--- + CMakeLists.txt | 2 ++ + include/anope.h | 3 +++ + include/sysconf.h.cmake | 2 ++ + modules/encryption/enc_bcrypt.cpp | 2 +- + modules/encryption/enc_sha256.cpp | 2 +- + modules/m_dns.cpp | 2 +- + modules/pseudoclients/nickserv.cpp | 2 +- + modules/webcpanel/pages/index.cpp | 2 +- + src/misc.cpp | 20 +++++++++++++++++++- + src/nickcore.cpp | 2 +- + src/xline.cpp | 2 +- + 11 files changed, 33 insertions(+), 8 deletions(-) + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 822f6f3..d364d06 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -364,6 +364,8 @@ check_include_file(stdint.h HAVE_STDINT_H) + check_include_file(strings.h HAVE_STRINGS_H) + + # Check for the existence of the following functions ++check_function_exists(arc4random_uniform HAVE_ARC4RANDOM_UNIFORM) ++check_function_exists(getentropy HAVE_GETENTROPY) + check_function_exists(strcasecmp HAVE_STRCASECMP) + check_function_exists(stricmp HAVE_STRICMP) + check_function_exists(umask HAVE_UMASK) +diff --git a/include/anope.h b/include/anope.h +index f746bb1..9f8ba60 100644 +--- a/include/anope.h ++++ b/include/anope.h +@@ -559,6 +559,9 @@ namespace Anope + * @param len The length of the string returned + */ + extern CoreExport Anope::string Random(size_t len); ++ ++ /** Generate a random number. */ ++ extern CoreExport int RandomNumber(); + } + + /** sepstream allows for splitting token separated lists. +diff --git a/include/sysconf.h.cmake b/include/sysconf.h.cmake +index 5f0e275..7faa7d2 100644 +--- a/include/sysconf.h.cmake ++++ b/include/sysconf.h.cmake +@@ -14,6 +14,8 @@ + #cmakedefine HAVE_EVENTFD 1 + #cmakedefine HAVE_EPOLL 1 + #cmakedefine HAVE_POLL 1 ++#cmakedefine HAVE_ARC4RANDOM_UNIFORM 1 ++#cmakedefine HAVE_GETENTROPY 1 + #cmakedefine GETTEXT_FOUND 1 + + #ifdef HAVE_CSTDINT +diff --git a/modules/encryption/enc_bcrypt.cpp b/modules/encryption/enc_bcrypt.cpp +index cbfc22f..49c1c29 100644 +--- a/modules/encryption/enc_bcrypt.cpp ++++ b/modules/encryption/enc_bcrypt.cpp +@@ -850,7 +850,7 @@ class EBCRYPT : public Module + { + char entropy[16]; + for (unsigned int i = 0; i < sizeof(entropy); i++) +- entropy[i] = static_cast(rand() % 0xFF); ++ entropy[i] = static_cast(Anope::RandomNumber() % 0xFF); + + char salt[32]; + if (!_crypt_gensalt_blowfish_rn("$2a$", rounds, entropy, sizeof(entropy), salt, sizeof(salt))) +diff --git a/modules/encryption/enc_sha256.cpp b/modules/encryption/enc_sha256.cpp +index 4848ec4..2a7e879 100644 +--- a/modules/encryption/enc_sha256.cpp ++++ b/modules/encryption/enc_sha256.cpp +@@ -246,7 +246,7 @@ class ESHA256 : public Module + void NewRandomIV() + { + for (int i = 0; i < 8; ++i) +- iv[i] = static_cast(rand()); ++ iv[i] = static_cast(Anope::RandomNumber()); + } + + /* returns the IV as base64-encrypted string */ +diff --git a/modules/m_dns.cpp b/modules/m_dns.cpp +index bbc8a83..a6315b2 100644 +--- a/modules/m_dns.cpp ++++ b/modules/m_dns.cpp +@@ -663,7 +663,7 @@ class MyManager : public Manager, public Timer + std::map requests; + + MyManager(Module *creator) : Manager(creator), Timer(300, Anope::CurTime, true), serial(Anope::CurTime), tcpsock(NULL), udpsock(NULL), +- listen(false), cur_id(rand()) ++ listen(false), cur_id(Anope::RandomNumber()) + { + } + +diff --git a/modules/pseudoclients/nickserv.cpp b/modules/pseudoclients/nickserv.cpp +index bb4b3d3..5166541 100644 +--- a/modules/pseudoclients/nickserv.cpp ++++ b/modules/pseudoclients/nickserv.cpp +@@ -241,7 +241,7 @@ class NickServCore : public Module, public NickServService + int i = 0; + do + { +- guestnick = guestprefix + stringify(static_cast(rand())); ++ guestnick = guestprefix + stringify(static_cast(Anope::RandomNumber())); + if (guestnick.length() > nicklen) + guestnick = guestnick.substr(0, nicklen); + } +diff --git a/modules/webcpanel/pages/index.cpp b/modules/webcpanel/pages/index.cpp +index 4db953b..971b91c 100644 +--- a/modules/webcpanel/pages/index.cpp ++++ b/modules/webcpanel/pages/index.cpp +@@ -49,7 +49,7 @@ class WebpanelRequest : public IdentifyRequest + { + char c; + do +- c = 48 + (rand() % 75); ++ c = 48 + (Anope::RandomNumber() % 75); + while (!isalnum(c)); + id += c; + } +diff --git a/src/misc.cpp b/src/misc.cpp +index 8cc9cda..e9a9ce2 100644 +--- a/src/misc.cpp ++++ b/src/misc.cpp +@@ -25,6 +25,9 @@ + #ifndef _WIN32 + #include + #include ++# ifdef __APPLE__ ++# include ++# endif + #endif + + #include +@@ -783,6 +786,21 @@ Anope::string Anope::Random(size_t len) + }; + Anope::string buf; + for (size_t i = 0; i < len; ++i) +- buf.append(chars[rand() % sizeof(chars)]); ++ buf.append(chars[Anope::RandomNumber() % sizeof(chars)]); + return buf; + } ++ ++int Anope::RandomNumber() ++{ ++#ifdef HAVE_GETENTROPY ++ int result; ++ if (getentropy(&result, sizeof(result)) == 0) ++ return result; ++#endif ++ ++#ifdef HAVE_ARC4RANDOM_UNIFORM ++ return (int)arc4random_uniform((uint32_t)RAND_MAX + 1U); ++#else ++ return rand(); ++#endif ++} +diff --git a/src/nickcore.cpp b/src/nickcore.cpp +index 1d70ad5..bf8fc7f 100644 +--- a/src/nickcore.cpp ++++ b/src/nickcore.cpp +@@ -301,7 +301,7 @@ uint64_t NickCore::GetId() + // Generate a random key for SipHash. + char key[16]; + for (size_t i = 0; i < sizeof(key); ++i) +- key[i] = rand() % CHAR_MAX; ++ key[i] = Anope::RandomNumber() % CHAR_MAX; + + uint64_t newid = Anope::SipHash24(secretid.c_str(), secretid.length(), key); + nickcoreid_map::const_iterator it = NickCoreIdList.find(newid); +diff --git a/src/xline.cpp b/src/xline.cpp +index e023e95..d0def20 100644 +--- a/src/xline.cpp ++++ b/src/xline.cpp +@@ -251,7 +251,7 @@ Anope::string XLineManager::GenerateUID() + { + char c; + do +- c = (rand() % 75) + 48; ++ c = (Anope::RandomNumber() % 75) + 48; + while (!isupper(c) && !isdigit(c)); + id += c; + } diff -Nru anope-2.0.17/debian/patches/0011-Add-origin-filtering-to-the-web-panel.patch anope-2.0.17/debian/patches/0011-Add-origin-filtering-to-the-web-panel.patch --- anope-2.0.17/debian/patches/0011-Add-origin-filtering-to-the-web-panel.patch 1970-01-01 00:00:00.000000000 +0000 +++ anope-2.0.17/debian/patches/0011-Add-origin-filtering-to-the-web-panel.patch 2026-11-22 15:40:50.000000000 +0000 @@ -0,0 +1,200 @@ +From: Sadie Powell +Date: Fri, 20 Nov 2026 13:45:37 +0000 +Subject: Add origin filtering to the web panel. + +--- + data/modules.example.conf | 7 ++++++ + modules/webcpanel/pages/confirm.cpp | 7 ++++++ + modules/webcpanel/pages/index.cpp | 6 +++++ + modules/webcpanel/pages/logout.cpp | 7 ++++++ + modules/webcpanel/webcpanel.cpp | 19 +++++++++++++++ + modules/webcpanel/webcpanel.h | 47 ++++++++++++++++++++++--------------- + 6 files changed, 74 insertions(+), 19 deletions(-) + +diff --git a/data/modules.example.conf b/data/modules.example.conf +index b8ae093..d32d817 100644 +--- a/data/modules.example.conf ++++ b/data/modules.example.conf +@@ -762,6 +762,13 @@ module { name = "m_sasl" } + + /* Page title. */ + title = "Anope IRC Services"; ++ ++ /* ++ * Space-delimited list of site globs that the web panel can be accessed ++ * from. This is used to prevent other sites from accessing the web panel ++ * via XHR or POST requests. ++ */ ++ #allowed_origins = "https://*.example.com" + } + + /* +diff --git a/modules/webcpanel/pages/confirm.cpp b/modules/webcpanel/pages/confirm.cpp +index 12c545e..056a42d 100644 +--- a/modules/webcpanel/pages/confirm.cpp ++++ b/modules/webcpanel/pages/confirm.cpp +@@ -14,6 +14,13 @@ bool WebCPanel::Confirm::OnRequest(HTTPProvider *server, const Anope::string &pa + + replacements["TITLE"] = page_title; + ++ if (!WebPanel::IsAllowedOrigin(message)) ++ { ++ reply.error = HTTP_BAD_REQUEST; ++ reply.Write("Invalid request origin."); ++ return true; ++ } ++ + if (!user.empty() && !pass.empty()) + { + std::vector params; +diff --git a/modules/webcpanel/pages/index.cpp b/modules/webcpanel/pages/index.cpp +index 971b91c..d52f13a 100644 +--- a/modules/webcpanel/pages/index.cpp ++++ b/modules/webcpanel/pages/index.cpp +@@ -97,6 +97,12 @@ bool WebCPanel::Index::OnRequest(HTTPProvider *server, const Anope::string &page + + replacements["TITLE"] = page_title; + ++ if (!WebPanel::IsAllowedOrigin(message)) ++ { ++ client->SendError(HTTP_BAD_REQUEST, "Invalid request origin."); ++ return true; ++ } ++ + if (!user.empty() && !pass.empty()) + { + // Rate limit check. +diff --git a/modules/webcpanel/pages/logout.cpp b/modules/webcpanel/pages/logout.cpp +index 25376da..bc6528c 100644 +--- a/modules/webcpanel/pages/logout.cpp ++++ b/modules/webcpanel/pages/logout.cpp +@@ -13,6 +13,13 @@ WebCPanel::Logout::Logout(const Anope::string &u) : WebPanelProtectedPage("", u) + + bool WebCPanel::Logout::OnRequest(HTTPProvider *server, const Anope::string &page_name, HTTPClient *client, HTTPMessage &message, HTTPReply &reply, NickAlias *na, TemplateFileServer::Replacements &replacements) + { ++ if (!WebPanel::IsAllowedOrigin(message)) ++ { ++ reply.error = HTTP_BAD_REQUEST; ++ reply.Write("Invalid request origin."); ++ return true; ++ } ++ + na->Shrink("webcpanel_id"); + na->Shrink("webcpanel_ip"); + +diff --git a/modules/webcpanel/webcpanel.cpp b/modules/webcpanel/webcpanel.cpp +index 3b2526d..ae2baec 100644 +--- a/modules/webcpanel/webcpanel.cpp ++++ b/modules/webcpanel/webcpanel.cpp +@@ -9,6 +9,7 @@ + + Module *me; + Anope::string provider_name, template_name, template_base, page_title; ++std::vector allowed_origins; + + class ModuleWebCPanel : public Module + { +@@ -63,6 +64,7 @@ class ModuleWebCPanel : public Module + template_name = block->Get("template", "default"); + template_base = Anope::DataDir + "/modules/webcpanel/templates/" + template_name; + page_title = block->Get("title", "Anope IRC Services"); ++ spacesepstream(block->Get("allowed_origins")).GetTokens(allowed_origins); + + provider = ServiceReference("HTTPProvider", provider_name); + if (!provider) +@@ -251,6 +253,23 @@ namespace WebPanel + return true; + } + ++ bool IsAllowedOrigin(const HTTPMessage &message) ++ { ++ if (allowed_origins.empty()) ++ return true; // No allowed origins specified. ++ ++ std::map::const_iterator it = message.headers.find("Origin"); ++ if (it == message.headers.end()) ++ return true; // Not a POST. ++ ++ for (std::vector::const_iterator allowed_origin = allowed_origins.begin(); allowed_origin != allowed_origins.end(); ++allowed_origin) ++ { ++ if (Anope::Match(it->second, *allowed_origin)) ++ return true; ++ } ++ return false; ++ } ++ + void RunCommand(HTTPClient *client, const Anope::string &user, NickCore *nc, const Anope::string &service, const Anope::string &c, std::vector ¶ms, TemplateFileServer::Replacements &r, const Anope::string &key) + { + ServiceReference cmd("Command", c); +diff --git a/modules/webcpanel/webcpanel.h b/modules/webcpanel/webcpanel.h +index 3dbdcf4..1260e63 100644 +--- a/modules/webcpanel/webcpanel.h ++++ b/modules/webcpanel/webcpanel.h +@@ -15,6 +15,27 @@ extern Module *me; + + extern Anope::string provider_name, template_name, template_base, page_title; + ++namespace WebPanel ++{ ++ /** Run a command ++ * @param client HTTP client command is being issued for ++ * @param User name to run command as, probably nc->display unless nc == NULL ++ * @param nc Nick core to run command from ++ * @param service Service for source.owner and source.service ++ * @param c Command to run (as a service name) ++ * @param params Command parameters ++ * @param r Replacements, reply from command goes back here into key ++ * @param key The key to put the replies into r ++ */ ++ extern void RunCommand(HTTPClient *client, const Anope::string &user, NickCore *nc, const Anope::string &service, const Anope::string &c, std::vector ¶ms, TemplateFileServer::Replacements &r, const Anope::string &key = "MESSAGES"); ++ ++ extern void RunCommandWithName(HTTPClient *client, NickCore *nc, const Anope::string &service, const Anope::string &c, const Anope::string &cmdname, std::vector ¶ms, TemplateFileServer::Replacements &r, const Anope::string &key = "MESSAGES"); ++ ++ extern bool CheckParams(const std::vector ¶ms); ++ ++ extern bool IsAllowedOrigin(const HTTPMessage &message); ++} ++ + struct SubSection + { + Anope::string name; +@@ -82,6 +103,13 @@ class WebPanelProtectedPage : public WebPanelPage + + bool OnRequest(HTTPProvider *provider, const Anope::string &page_name, HTTPClient *client, HTTPMessage &message, HTTPReply &reply) anope_override anope_final + { ++ if (!WebPanel::IsAllowedOrigin(message)) ++ { ++ reply.error = HTTP_BAD_REQUEST; ++ reply.Write("Invalid request origin."); ++ return true; ++ } ++ + ServiceReference panel("Panel", "webcpanel"); + NickAlias *na; + +@@ -140,25 +168,6 @@ class WebPanelProtectedPage : public WebPanelPage + virtual std::set GetData() { return std::set(); } + }; + +-namespace WebPanel +-{ +- /** Run a command +- * @param client HTTP client command is being issued for +- * @param User name to run command as, probably nc->display unless nc == NULL +- * @param nc Nick core to run command from +- * @param service Service for source.owner and source.service +- * @param c Command to run (as a service name) +- * @param params Command parameters +- * @param r Replacements, reply from command goes back here into key +- * @param key The key to put the replies into r +- */ +- extern void RunCommand(HTTPClient *client, const Anope::string &user, NickCore *nc, const Anope::string &service, const Anope::string &c, std::vector ¶ms, TemplateFileServer::Replacements &r, const Anope::string &key = "MESSAGES"); +- +- extern void RunCommandWithName(HTTPClient *client, NickCore *nc, const Anope::string &service, const Anope::string &c, const Anope::string &cmdname, std::vector ¶ms, TemplateFileServer::Replacements &r, const Anope::string &key = "MESSAGES"); +- +- extern bool CheckParams(const std::vector ¶ms); +-} +- + #include "pages/index.h" + #include "pages/logout.h" + #include "pages/register.h" diff -Nru anope-2.0.17/debian/patches/0012-Properly-sanitise-get-post-data-in-the-webcpanel-mod.patch anope-2.0.17/debian/patches/0012-Properly-sanitise-get-post-data-in-the-webcpanel-mod.patch --- anope-2.0.17/debian/patches/0012-Properly-sanitise-get-post-data-in-the-webcpanel-mod.patch 1970-01-01 00:00:00.000000000 +0000 +++ anope-2.0.17/debian/patches/0012-Properly-sanitise-get-post-data-in-the-webcpanel-mod.patch 2026-11-22 15:40:50.000000000 +0000 @@ -0,0 +1,591 @@ +From: Sadie Powell +Date: Fri, 20 Nov 2026 13:45:37 +0000 +Subject: Properly sanitise get/post data in the webcpanel module. + +--- + modules/webcpanel/pages/chanserv/access.cpp | 24 ++++++++++++++---------- + modules/webcpanel/pages/chanserv/akick.cpp | 18 +++++++++++------- + modules/webcpanel/pages/chanserv/drop.cpp | 13 ++++++------- + modules/webcpanel/pages/chanserv/info.cpp | 3 +-- + modules/webcpanel/pages/chanserv/modes.cpp | 14 ++++++++------ + modules/webcpanel/pages/chanserv/set.cpp | 2 +- + modules/webcpanel/pages/confirm.cpp | 5 +++-- + modules/webcpanel/pages/hostserv/request.cpp | 6 ++++-- + modules/webcpanel/pages/index.cpp | 4 ++-- + modules/webcpanel/pages/memoserv/memos.cpp | 22 ++++++++++++++-------- + modules/webcpanel/pages/nickserv/access.cpp | 10 ++++++---- + modules/webcpanel/pages/nickserv/cert.cpp | 10 ++++++---- + modules/webcpanel/pages/nickserv/confirm.cpp | 2 +- + modules/webcpanel/pages/nickserv/info.cpp | 15 ++++++++------- + modules/webcpanel/pages/operserv/akill.cpp | 18 ++++++++++++------ + modules/webcpanel/webcpanel.cpp | 12 ++++++++++++ + modules/webcpanel/webcpanel.h | 2 ++ + 17 files changed, 111 insertions(+), 69 deletions(-) + +diff --git a/modules/webcpanel/pages/chanserv/access.cpp b/modules/webcpanel/pages/chanserv/access.cpp +index 7b1caff..447c291 100644 +--- a/modules/webcpanel/pages/chanserv/access.cpp ++++ b/modules/webcpanel/pages/chanserv/access.cpp +@@ -15,10 +15,10 @@ WebCPanel::ChanServ::Access::Access(const Anope::string &cat, const Anope::strin + bool WebCPanel::ChanServ::Access::OnRequest(HTTPProvider *server, const Anope::string &page_name, HTTPClient *client, HTTPMessage &message, HTTPReply &reply, NickAlias *na, TemplateFileServer::Replacements &replacements) + { + TemplateFileServer Page("chanserv/access.html"); +- const Anope::string &chname = message.get_data["channel"]; + + BuildChanList(na, replacements); + ++ const Anope::string chname = WebPanel::GetRequestData(message.get_data, "channel"); + if (chname.empty()) + { + Page.Serve(server, page_name, client, message, reply, replacements); +@@ -46,18 +46,22 @@ bool WebCPanel::ChanServ::Access::OnRequest(HTTPProvider *server, const Anope::s + + replacements["ACCESS_LIST"] = "YES"; + ++ const Anope::string paccess = WebPanel::GetRequestData(message.post_data, "access"); ++ const Anope::string pmask = WebPanel::GetRequestData(message.post_data, "mask"); ++ + if (u_access.HasPriv("ACCESS_CHANGE") || has_priv) + { +- if (message.get_data["del"].empty() == false && message.get_data["mask"].empty() == false) ++ const Anope::string mask = WebPanel::GetRequestData(message.get_data, "mask"); ++ if (message.get_data.count("del") && !mask.empty()) + { + std::vector params; + params.push_back(ci->name); + params.push_back("DEL"); +- params.push_back(message.get_data["mask"]); ++ params.push_back(mask); + + WebPanel::RunCommand(client, na->nc->display, na->nc, "ChanServ", "chanserv/access", params, replacements); + } +- else if (message.post_data["mask"].empty() == false && message.post_data["access"].empty() == false && message.post_data["provider"].empty() == false) ++ else if (!pmask.empty() && !paccess.empty() && message.post_data.count("provider")) + { + const Anope::string &provider = message.post_data["provider"]; + +@@ -66,8 +70,8 @@ bool WebCPanel::ChanServ::Access::OnRequest(HTTPProvider *server, const Anope::s + std::vector params; + params.push_back(ci->name); + params.push_back("ADD"); +- params.push_back(message.post_data["mask"]); +- params.push_back(message.post_data["access"]); ++ params.push_back(pmask); ++ params.push_back(paccess); + + WebPanel::RunCommand(client, na->nc->display, na->nc, "ChanServ", "chanserv/access", params, replacements); + } +@@ -76,17 +80,17 @@ bool WebCPanel::ChanServ::Access::OnRequest(HTTPProvider *server, const Anope::s + std::vector params; + params.push_back(ci->name); + params.push_back("ADD"); +- params.push_back(message.post_data["mask"]); ++ params.push_back(pmask); + +- WebPanel::RunCommandWithName(client, na->nc, "ChanServ", "chanserv/xop", message.post_data["access"], params, replacements); ++ WebPanel::RunCommandWithName(client, na->nc, "ChanServ", "chanserv/xop", paccess, params, replacements); + } + else if (provider == "chanserv/flags") + { + std::vector params; + params.push_back(ci->name); + params.push_back("MODIFY"); +- params.push_back(message.post_data["mask"]); +- params.push_back(message.post_data["access"]); ++ params.push_back(pmask); ++ params.push_back(paccess); + + WebPanel::RunCommand(client, na->nc->display, na->nc, "ChanServ", "chanserv/flags", params, replacements); + } +diff --git a/modules/webcpanel/pages/chanserv/akick.cpp b/modules/webcpanel/pages/chanserv/akick.cpp +index e199a18..ce70fe8 100644 +--- a/modules/webcpanel/pages/chanserv/akick.cpp ++++ b/modules/webcpanel/pages/chanserv/akick.cpp +@@ -14,11 +14,11 @@ WebCPanel::ChanServ::Akick::Akick(const Anope::string &cat, const Anope::string + + bool WebCPanel::ChanServ::Akick::OnRequest(HTTPProvider *server, const Anope::string &page_name, HTTPClient *client, HTTPMessage &message, HTTPReply &reply, NickAlias *na, TemplateFileServer::Replacements &replacements) + { +- const Anope::string &chname = message.get_data["channel"]; + TemplateFileServer Page("chanserv/akick.html"); + + BuildChanList(na, replacements); + ++ const Anope::string chname = WebPanel::GetRequestData(message.get_data, "channel"); + if (chname.empty()) + { + Page.Serve(server, page_name, client, message, reply, replacements); +@@ -46,23 +46,27 @@ bool WebCPanel::ChanServ::Akick::OnRequest(HTTPProvider *server, const Anope::st + + replacements["AKICK"] = "YES"; + +- if (message.get_data["del"].empty() == false && message.get_data["mask"].empty() == false) ++ const Anope::string mask = WebPanel::GetRequestData(message.get_data, "mask"); ++ const Anope::string pmask = WebPanel::GetRequestData(message.post_data, "mask"); ++ if (message.get_data.count("del") && !mask.empty()) + { + std::vector params; + params.push_back(ci->name); + params.push_back("DEL"); +- params.push_back(message.get_data["mask"]); ++ params.push_back(mask); + + WebPanel::RunCommand(client, na->nc->display, na->nc, "ChanServ", "chanserv/akick", params, replacements); + } +- else if (message.post_data["mask"].empty() == false) ++ else if (!pmask.empty()) + { + std::vector params; + params.push_back(ci->name); + params.push_back("ADD"); +- params.push_back(message.post_data["mask"]); +- if (message.post_data["reason"].empty() == false) +- params.push_back(message.post_data["reason"]); ++ params.push_back(pmask); ++ ++ const Anope::string reason = WebPanel::GetRequestData(message.post_data, "reason"); ++ if (!reason.empty()) ++ params.push_back(reason); + + WebPanel::RunCommand(client, na->nc->display, na->nc, "ChanServ", "chanserv/akick", params, replacements); + } +diff --git a/modules/webcpanel/pages/chanserv/drop.cpp b/modules/webcpanel/pages/chanserv/drop.cpp +index c3d55d6..dfc15f0 100644 +--- a/modules/webcpanel/pages/chanserv/drop.cpp ++++ b/modules/webcpanel/pages/chanserv/drop.cpp +@@ -15,13 +15,13 @@ WebCPanel::ChanServ::Drop::Drop(const Anope::string &cat, const Anope::string &u + + bool WebCPanel::ChanServ::Drop::OnRequest(HTTPProvider *server, const Anope::string &page_name, HTTPClient *client, HTTPMessage &message, HTTPReply &reply, NickAlias *na, TemplateFileServer::Replacements &replacements) + { +- +- if (message.post_data.count("channel") > 0 && message.post_data.count("confChan") > 0) ++ const Anope::string channel = WebPanel::GetRequestData(message.post_data, "channel"); ++ const Anope::string confchan = WebPanel::GetRequestData(message.post_data, "confChan"); ++ if (!channel.empty() && !confchan.empty()) + { +- if (message.post_data["channel"] == message.post_data["confChan"]) ++ if (channel == confchan) + { + std::vector params; +- const Anope::string &channel = HTTPUtils::URLDecode(message.post_data["channel"]); + params.push_back(channel); + params.push_back(channel); + +@@ -43,10 +43,9 @@ bool WebCPanel::ChanServ::Drop::OnRequest(HTTPProvider *server, const Anope::str + } + } + +- if (message.get_data.count("channel") > 0) ++ const Anope::string chname = WebPanel::GetRequestData(message.get_data, "channel"); ++ if (!chname.empty()) + { +- const Anope::string &chname = message.get_data["channel"]; +- + replacements["CHANNEL_DROP"] = chname; + replacements["ESCAPED_CHANNEL"] = HTTPUtils::URLEncode(chname); + } +diff --git a/modules/webcpanel/pages/chanserv/info.cpp b/modules/webcpanel/pages/chanserv/info.cpp +index b0f70b2..87d374b 100644 +--- a/modules/webcpanel/pages/chanserv/info.cpp ++++ b/modules/webcpanel/pages/chanserv/info.cpp +@@ -14,8 +14,7 @@ WebCPanel::ChanServ::Info::Info(const Anope::string &cat, const Anope::string &u + + bool WebCPanel::ChanServ::Info::OnRequest(HTTPProvider *server, const Anope::string &page_name, HTTPClient *client, HTTPMessage &message, HTTPReply &reply, NickAlias *na, TemplateFileServer::Replacements &replacements) + { +- const Anope::string &chname = message.get_data["channel"]; +- ++ const Anope::string chname = WebPanel::GetRequestData(message.get_data, "channel"); + if (!chname.empty()) + replacements["ESCAPED_CHANNEL"] = HTTPUtils::URLEncode(chname); + +diff --git a/modules/webcpanel/pages/chanserv/modes.cpp b/modules/webcpanel/pages/chanserv/modes.cpp +index 2e30652..64ac19e 100644 +--- a/modules/webcpanel/pages/chanserv/modes.cpp ++++ b/modules/webcpanel/pages/chanserv/modes.cpp +@@ -14,12 +14,11 @@ WebCPanel::ChanServ::Modes::Modes(const Anope::string &cat, const Anope::string + + bool WebCPanel::ChanServ::Modes::OnRequest(HTTPProvider *server, const Anope::string &page_name, HTTPClient *client, HTTPMessage &message, HTTPReply &reply, NickAlias *na, TemplateFileServer::Replacements &replacements) + { +- const Anope::string &chname = message.get_data["channel"]; +- const Anope::string &mode = message.get_data["m"]; + TemplateFileServer Page("chanserv/modes.html"); + + BuildChanList(na, replacements); + ++ const Anope::string chname = WebPanel::GetRequestData(message.get_data, "channel"); + if (chname.empty()) + { + Page.Serve(server, page_name, client, message, reply, replacements); +@@ -65,6 +64,7 @@ bool WebCPanel::ChanServ::Modes::OnRequest(HTTPProvider *server, const Anope::st + replacements["LISTMODES"] = cm->mchar; + } + ++ const Anope::string mode = WebPanel::GetRequestData(message.get_data, "m"); + if (mode.empty()) + { + Page.Serve(server, page_name, client, message, reply, replacements); +@@ -75,22 +75,24 @@ bool WebCPanel::ChanServ::Modes::OnRequest(HTTPProvider *server, const Anope::st + ChannelMode *cm = ModeManager::FindChannelModeByChar(mode[0]); + if (cm) + { +- if (message.get_data["del"].empty() == false && message.get_data["mask"].empty() == false) ++ const Anope::string mask = WebPanel::GetRequestData(message.get_data, "mask"); ++ const Anope::string pmask = WebPanel::GetRequestData(message.post_data, "mask"); ++ if (message.get_data.count("del") && !mask.empty()) + { + std::vector params; + params.push_back(ci->name); + params.push_back("SET"); + params.push_back("-" + Anope::string(cm->mchar)); +- params.push_back(message.get_data["mask"]); ++ params.push_back(mask); + WebPanel::RunCommand(client, na->nc->display, na->nc, "ChanServ", "chanserv/mode", params, replacements); + } +- else if (message.post_data["mask"].empty() == false) ++ else if (!pmask.empty()) + { + std::vector params; + params.push_back(ci->name); + params.push_back("SET"); + params.push_back("+" + Anope::string(cm->mchar)); +- params.push_back(message.post_data["mask"]); ++ params.push_back(pmask); + WebPanel::RunCommand(client, na->nc->display, na->nc, "ChanServ", "chanserv/mode", params, replacements); + } + +diff --git a/modules/webcpanel/pages/chanserv/set.cpp b/modules/webcpanel/pages/chanserv/set.cpp +index 101d486..5244cc9 100644 +--- a/modules/webcpanel/pages/chanserv/set.cpp ++++ b/modules/webcpanel/pages/chanserv/set.cpp +@@ -14,12 +14,12 @@ WebCPanel::ChanServ::Set::Set(const Anope::string &cat, const Anope::string &u) + + bool WebCPanel::ChanServ::Set::OnRequest(HTTPProvider *server, const Anope::string &page_name, HTTPClient *client, HTTPMessage &message, HTTPReply &reply, NickAlias *na, TemplateFileServer::Replacements &replacements) + { +- const Anope::string &chname = message.get_data["channel"]; + bool can_set = false; + TemplateFileServer page("chanserv/set.html"); + + BuildChanList(na, replacements); + ++ const Anope::string chname = WebPanel::GetRequestData(message.get_data, "channel"); + if (chname.empty()) + { + page.Serve(server, page_name, client, message, reply, replacements); +diff --git a/modules/webcpanel/pages/confirm.cpp b/modules/webcpanel/pages/confirm.cpp +index 056a42d..489a4cd 100644 +--- a/modules/webcpanel/pages/confirm.cpp ++++ b/modules/webcpanel/pages/confirm.cpp +@@ -10,8 +10,6 @@ + bool WebCPanel::Confirm::OnRequest(HTTPProvider *server, const Anope::string &page_name, HTTPClient *client, HTTPMessage &message, HTTPReply &reply) + { + TemplateFileServer::Replacements replacements; +- const Anope::string &user = message.post_data["username"], &pass = message.post_data["password"], &email = message.post_data["email"]; +- + replacements["TITLE"] = page_title; + + if (!WebPanel::IsAllowedOrigin(message)) +@@ -21,10 +19,13 @@ bool WebCPanel::Confirm::OnRequest(HTTPProvider *server, const Anope::string &pa + return true; + } + ++ const Anope::string user = WebPanel::GetRequestData(message.post_data, "username"); ++ const Anope::string pass = WebPanel::GetRequestData(message.post_data, "password"); + if (!user.empty() && !pass.empty()) + { + std::vector params; + params.push_back(pass); ++ const Anope::string email = WebPanel::GetRequestData(message.post_data, "email"); + if (!email.empty()) + params.push_back(email); + +diff --git a/modules/webcpanel/pages/hostserv/request.cpp b/modules/webcpanel/pages/hostserv/request.cpp +index 030999d..d9e1b66 100644 +--- a/modules/webcpanel/pages/hostserv/request.cpp ++++ b/modules/webcpanel/pages/hostserv/request.cpp +@@ -13,10 +13,12 @@ WebCPanel::HostServ::Request::Request(const Anope::string &cat, const Anope::str + + bool WebCPanel::HostServ::Request::OnRequest(HTTPProvider *server, const Anope::string &page_name, HTTPClient *client, HTTPMessage &message, HTTPReply &reply, NickAlias *na, TemplateFileServer::Replacements &replacements) + { +- if (message.post_data.count("req") > 0) ++ ++ const Anope::string req = WebPanel::GetRequestData(message.post_data, "req"); ++ if (!req.empty()) + { + std::vector params; +- params.push_back(HTTPUtils::URLDecode(message.post_data["req"])); ++ params.push_back(req); + + WebPanel::RunCommand(client, na->nc->display, na->nc, "HostServ", "hostserv/request", params, replacements, "CMDR"); + } +diff --git a/modules/webcpanel/pages/index.cpp b/modules/webcpanel/pages/index.cpp +index d52f13a..87e7ada 100644 +--- a/modules/webcpanel/pages/index.cpp ++++ b/modules/webcpanel/pages/index.cpp +@@ -93,8 +93,6 @@ class WebpanelRequest : public IdentifyRequest + bool WebCPanel::Index::OnRequest(HTTPProvider *server, const Anope::string &page_name, HTTPClient *client, HTTPMessage &message, HTTPReply &reply) + { + TemplateFileServer::Replacements replacements; +- const Anope::string &user = message.post_data["username"], &pass = message.post_data["password"]; +- + replacements["TITLE"] = page_title; + + if (!WebPanel::IsAllowedOrigin(message)) +@@ -103,6 +101,8 @@ bool WebCPanel::Index::OnRequest(HTTPProvider *server, const Anope::string &page + return true; + } + ++ const Anope::string user = WebPanel::GetRequestData(message.post_data, "username"); ++ const Anope::string pass = WebPanel::GetRequestData(message.post_data, "password"); + if (!user.empty() && !pass.empty()) + { + // Rate limit check. +diff --git a/modules/webcpanel/pages/memoserv/memos.cpp b/modules/webcpanel/pages/memoserv/memos.cpp +index 539b33e..45baf11 100644 +--- a/modules/webcpanel/pages/memoserv/memos.cpp ++++ b/modules/webcpanel/pages/memoserv/memos.cpp +@@ -13,7 +13,6 @@ WebCPanel::MemoServ::Memos::Memos(const Anope::string &cat, const Anope::string + + bool WebCPanel::MemoServ::Memos::OnRequest(HTTPProvider *server, const Anope::string &page_name, HTTPClient *client, HTTPMessage &message, HTTPReply &reply, NickAlias *na, TemplateFileServer::Replacements &replacements) + { +- const Anope::string &chname = message.get_data["channel"]; + ChannelInfo *ci; + const MemoInfo *mi; + Memo *m; +@@ -29,6 +28,7 @@ bool WebCPanel::MemoServ::Memos::OnRequest(HTTPProvider *server, const Anope::st + } + } + ++ const Anope::string chname = WebPanel::GetRequestData(message.get_data, "channel"); + if (chname.empty()) + { + replacements["MESSAGES"] = "No Channel specified, displaying the memos for your Nick"; +@@ -51,31 +51,37 @@ bool WebCPanel::MemoServ::Memos::OnRequest(HTTPProvider *server, const Anope::st + mi = &na->nc->memos; + } + } +- if (message.post_data.count("receiver") > 0 && message.post_data.count("message") > 0) ++ ++ const Anope::string receiver = WebPanel::GetRequestData(message.post_data, "receiver"); ++ const Anope::string msg = WebPanel::GetRequestData(message.post_data, "message"); ++ if (!receiver.empty() && !msg.empty()) + { + std::vector params; +- params.push_back(HTTPUtils::URLDecode(message.post_data["receiver"])); +- params.push_back(HTTPUtils::URLDecode(message.post_data["message"])); ++ params.push_back(receiver); ++ params.push_back(msg); + + WebPanel::RunCommand(client, na->nc->display, na->nc, "MemoServ", "memoserv/send", params, replacements, "CMDR"); + } +- if (message.get_data.count("del") > 0 && message.get_data.count("number") > 0) ++ ++ const Anope::string num = WebPanel::GetRequestData(message.get_data, "number"); ++ if (message.get_data.count("del") > 0 && !num.empty()) + { + std::vector params; + if (!chname.empty()) + params.push_back(chname); +- params.push_back(message.get_data["number"]); ++ params.push_back(num); + + WebPanel::RunCommand(client, na->nc->display, na->nc, "MemoServ", "memoserv/del", params, replacements, "CMDR"); + } +- if (message.get_data.count("read") > 0 && message.get_data.count("number") > 0) ++ ++ if (message.get_data.count("read") > 0 && !num.empty()) + { + std::vector params; + int number = -1; + + try + { +- number = convertTo(message.get_data["number"]); ++ number = convertTo(num); + } + catch (const ConvertException &ex) + { +diff --git a/modules/webcpanel/pages/nickserv/access.cpp b/modules/webcpanel/pages/nickserv/access.cpp +index 0801473..101f2f7 100644 +--- a/modules/webcpanel/pages/nickserv/access.cpp ++++ b/modules/webcpanel/pages/nickserv/access.cpp +@@ -13,19 +13,21 @@ WebCPanel::NickServ::Access::Access(const Anope::string &cat, const Anope::strin + + bool WebCPanel::NickServ::Access::OnRequest(HTTPProvider *server, const Anope::string &page_name, HTTPClient *client, HTTPMessage &message, HTTPReply &reply, NickAlias *na, TemplateFileServer::Replacements &replacements) + { +- if (message.post_data.count("access") > 0) ++ const Anope::string access = WebPanel::GetRequestData(message.post_data, "access"); ++ const Anope::string mask = WebPanel::GetRequestData(message.get_data, "mask"); ++ if (!access.empty()) + { + std::vector params; + params.push_back("ADD"); +- params.push_back(message.post_data["access"]); ++ params.push_back(access); + + WebPanel::RunCommand(client, na->nc->display, na->nc, "NickServ", "nickserv/access", params, replacements); + } +- else if (message.get_data.count("del") > 0 && message.get_data.count("mask") > 0) ++ else if (message.get_data.count("del") && mask.empty()) + { + std::vector params; + params.push_back("DEL"); +- params.push_back(message.get_data["mask"]); ++ params.push_back(mask); + + WebPanel::RunCommand(client, na->nc->display, na->nc, "NickServ", "nickserv/access", params, replacements); + } +diff --git a/modules/webcpanel/pages/nickserv/cert.cpp b/modules/webcpanel/pages/nickserv/cert.cpp +index 14608d9..e2cfe58 100644 +--- a/modules/webcpanel/pages/nickserv/cert.cpp ++++ b/modules/webcpanel/pages/nickserv/cert.cpp +@@ -14,19 +14,21 @@ WebCPanel::NickServ::Cert::Cert(const Anope::string &cat, const Anope::string &u + + bool WebCPanel::NickServ::Cert::OnRequest(HTTPProvider *server, const Anope::string &page_name, HTTPClient *client, HTTPMessage &message, HTTPReply &reply, NickAlias *na, TemplateFileServer::Replacements &replacements) + { +- if (message.post_data.count("certfp") > 0) ++ const Anope::string certfp = WebPanel::GetRequestData(message.post_data, "certfp"); ++ const Anope::string mask = WebPanel::GetRequestData(message.get_data, "mask"); ++ if (!certfp.empty()) + { + std::vector params; + params.push_back("ADD"); +- params.push_back(message.post_data["certfp"]); ++ params.push_back(certfp); + + WebPanel::RunCommand(client, na->nc->display, na->nc, "NickServ", "nickserv/cert", params, replacements); + } +- else if (message.get_data.count("del") > 0 && message.get_data.count("mask") > 0) ++ else if (message.get_data.count("del") && !mask.empty()) + { + std::vector params; + params.push_back("DEL"); +- params.push_back(message.get_data["mask"]); ++ params.push_back(mask); + + WebPanel::RunCommand(client, na->nc->display, na->nc, "NickServ", "nickserv/cert", params, replacements); + } +diff --git a/modules/webcpanel/pages/nickserv/confirm.cpp b/modules/webcpanel/pages/nickserv/confirm.cpp +index 85ad1ff..a094b00 100644 +--- a/modules/webcpanel/pages/nickserv/confirm.cpp ++++ b/modules/webcpanel/pages/nickserv/confirm.cpp +@@ -15,7 +15,7 @@ bool WebCPanel::NickServ::Confirm::OnRequest(HTTPProvider *server, const Anope:: + { + + std::vector params; +- params.push_back(message.post_data["code"]); ++ params.push_back(WebPanel::GetRequestData(message.post_data, "code")); + + WebPanel::RunCommand(client, na->nc->display, na->nc, "NickServ", "nickserv/confirm", params, replacements); + +diff --git a/modules/webcpanel/pages/nickserv/info.cpp b/modules/webcpanel/pages/nickserv/info.cpp +index 0a7c63f..b2730bc 100644 +--- a/modules/webcpanel/pages/nickserv/info.cpp ++++ b/modules/webcpanel/pages/nickserv/info.cpp +@@ -15,24 +15,25 @@ bool WebCPanel::NickServ::Info::OnRequest(HTTPProvider *server, const Anope::str + { + if (message.post_data.empty() == false) + { +- if (message.post_data.count("email") > 0) ++ const Anope::string email = WebPanel::GetRequestData(message.post_data, "email"); ++ if (!email.empty()) + { +- if (message.post_data["email"] != na->nc->email) ++ if (email != na->nc->email) + { +- if (!message.post_data["email"].empty() && !Mail::Validate(message.post_data["email"])) ++ if (!Mail::Validate(email)) + replacements["ERRORS"] = "Invalid email"; + else + { +- na->nc->email = message.post_data["email"]; ++ na->nc->email = email; + replacements["MESSAGES"] = "Email updated"; + } + } + } +- if (message.post_data.count("greet") > 0) ++ ++ const Anope::string post_greet = WebPanel::GetRequestData(message.post_data, "greet"); ++ if (!post_greet.empty()) + { + Anope::string *greet = na->nc->GetExt("greet"); +- const Anope::string &post_greet = HTTPUtils::URLDecode(message.post_data["greet"].replace_all_cs("+", " ")); +- + if (post_greet.empty()) + na->nc->Shrink("greet"); + else if (!greet || post_greet != *greet) +diff --git a/modules/webcpanel/pages/operserv/akill.cpp b/modules/webcpanel/pages/operserv/akill.cpp +index 62ae841..4df7308 100644 +--- a/modules/webcpanel/pages/operserv/akill.cpp ++++ b/modules/webcpanel/pages/operserv/akill.cpp +@@ -25,23 +25,29 @@ bool WebCPanel::OperServ::Akill::OnRequest(HTTPProvider *server, const Anope::st + if (akills->GetCount() == 0) + replacements["AKILLS"] = "No Akills to display."; + +- if (message.post_data.count("mask") > 0 && message.post_data.count("expiry") > 0 && message.post_data.count("reason") > 0) ++ const Anope::string expiry = WebPanel::GetRequestData(message.post_data, "expiry"); ++ const Anope::string mask = WebPanel::GetRequestData(message.post_data, "mask"); ++ const Anope::string reason = WebPanel::GetRequestData(message.post_data, "reason"); ++ if (!expiry.empty() && !mask.empty() && !reason.empty()) + { + std::vector params; + std::stringstream cmdstr; + params.push_back("ADD"); +- cmdstr << "+" << HTTPUtils::URLDecode(message.post_data["expiry"]); +- cmdstr << " " << HTTPUtils::URLDecode(message.post_data["mask"]); +- cmdstr << " " << HTTPUtils::URLDecode(message.post_data["reason"]); ++ cmdstr << "+" << expiry; ++ cmdstr << " " << mask; ++ cmdstr << " " << reason; + params.push_back(cmdstr.str()); + WebPanel::RunCommand(client, na->nc->display, na->nc, "OperServ", "operserv/akill", params, replacements); + } + +- if (message.get_data["del"] == "1" && message.get_data.count("number") > 0) ++ ++ ++ const Anope::string number = WebPanel::GetRequestData(message.get_data, "number"); ++ if (message.get_data.count("del") && !number.empty()) + { + std::vector params; + params.push_back("DEL"); +- params.push_back(HTTPUtils::URLDecode(message.get_data["number"])); ++ params.push_back(number); + WebPanel::RunCommand(client, na->nc->display, na->nc, "OperServ", "operserv/akill", params, replacements); + } + +diff --git a/modules/webcpanel/webcpanel.cpp b/modules/webcpanel/webcpanel.cpp +index ae2baec..45d17a9 100644 +--- a/modules/webcpanel/webcpanel.cpp ++++ b/modules/webcpanel/webcpanel.cpp +@@ -253,6 +253,18 @@ namespace WebPanel + return true; + } + ++ Anope::string GetRequestData(const std::map &data, const Anope::string &key) ++ { ++ std::map::const_iterator dit = data.find(key); ++ if (dit == data.end() || dit->second.length() > 512) ++ return ""; // No data or too long. ++ ++ return dit->second ++ .replace_all_cs('\0', ' ') ++ .replace_all_cs('\r', ' ') ++ .replace_all_cs('\n', ' '); ++ } ++ + bool IsAllowedOrigin(const HTTPMessage &message) + { + if (allowed_origins.empty()) +diff --git a/modules/webcpanel/webcpanel.h b/modules/webcpanel/webcpanel.h +index 1260e63..f255467 100644 +--- a/modules/webcpanel/webcpanel.h ++++ b/modules/webcpanel/webcpanel.h +@@ -33,6 +33,8 @@ namespace WebPanel + + extern bool CheckParams(const std::vector ¶ms); + ++ extern Anope::string GetRequestData(const std::map &data, const Anope::string &key); ++ + extern bool IsAllowedOrigin(const HTTPMessage &message); + } + diff -Nru anope-2.0.17/debian/patches/Add-EscapeDN-and-EscapeSF-to-the-LDAP-API.patch anope-2.0.17/debian/patches/Add-EscapeDN-and-EscapeSF-to-the-LDAP-API.patch --- anope-2.0.17/debian/patches/Add-EscapeDN-and-EscapeSF-to-the-LDAP-API.patch 1970-01-01 00:00:00.000000000 +0000 +++ anope-2.0.17/debian/patches/Add-EscapeDN-and-EscapeSF-to-the-LDAP-API.patch 2026-11-22 15:40:50.000000000 +0000 @@ -0,0 +1,115 @@ +From: Sadie Powell +Date: Tue, 26 May 2026 09:29:57 +0100 +Subject: Add EscapeDN and EscapeSF to the LDAP API. + +--- + include/modules/ldap.h | 10 +++++++ + modules/extra/m_ldap.cpp | 74 ++++++++++++++++++++++++++++++++++++++++++++++++ + 2 files changed, 84 insertions(+) + +diff --git a/include/modules/ldap.h b/include/modules/ldap.h +index dd3306d..3463f26 100644 +--- a/include/modules/ldap.h ++++ b/include/modules/ldap.h +@@ -166,6 +166,16 @@ class LDAPProvider : public Service + * @param attributes The attributes to modify + */ + virtual void Modify(LDAPInterface *i, const Anope::string &base, LDAPMods &attributes) = 0; ++ ++ /** Escapes a LDAP string for use in a DN. ++ * @param str The string to escape. ++ */ ++ virtual Anope::string EscapeDN(const Anope::string &str) const = 0; ++ ++ /** Escapes a LDAP string for use in a search filter. ++ * @param str The string to escape. ++ */ ++ virtual Anope::string EscapeSF(const Anope::string &str) const = 0; + }; + + #endif // ANOPE_LDAP_H +diff --git a/modules/extra/m_ldap.cpp b/modules/extra/m_ldap.cpp +index 7265f8b..a44b290 100644 +--- a/modules/extra/m_ldap.cpp ++++ b/modules/extra/m_ldap.cpp +@@ -388,6 +388,80 @@ class LDAPService : public LDAPProvider, public Thread, public Condition + QueueRequest(mod); + } + ++ Anope::string EscapeDN(const Anope::string &str) const anope_override ++ { ++ if (str.empty()) ++ return str; ++ ++ Anope::string newstr; ++ newstr.str().reserve(str.length()); ++ for (size_t idx = 0; idx < str.length(); ++idx) ++ { ++ const char chr = str[idx]; ++ if (chr == '\0') ++ { ++ newstr.append("\\00"); ++ } ++ else if (chr == '"' || chr == '+' || chr == ',' || chr == ';' || ++ chr == '<' || chr == '=' || chr == '>' || chr == '\\') ++ { ++ newstr.push_back('\\'); ++ newstr.push_back(chr); ++ } ++ else if (idx == 0 && (chr == '#' || chr == ' ')) ++ { ++ newstr.push_back('\\'); ++ newstr.push_back(chr); ++ } ++ else if (idx == str.length() - 1 && chr == ' ') ++ { ++ newstr.push_back('\\'); ++ newstr.push_back(chr); ++ } ++ else ++ { ++ newstr.push_back(chr); ++ } ++ } ++ ++ return newstr; ++ } ++ ++ Anope::string EscapeSF(const Anope::string &str) const anope_override ++ { ++ if (str.empty()) ++ return str; ++ ++ Anope::string newstr; ++ newstr.str().reserve(str.length()); ++ for (size_t idx = 0; idx < str.length(); ++idx) ++ { ++ const char chr = str[idx]; ++ switch (chr) ++ { ++ case '\0': ++ newstr.append("\\00"); ++ break; ++ case '(': ++ newstr.append("\\28"); ++ break; ++ case ')': ++ newstr.append("\\29"); ++ break; ++ case '*': ++ newstr.append("\\2A"); ++ break; ++ case '\\': ++ newstr.append("\\5C"); ++ break; ++ default: ++ newstr.push_back(chr); ++ break; ++ } ++ } ++ return newstr; ++ } ++ + private: + void BuildReply(int res, LDAPRequest *req) + { diff -Nru anope-2.0.17/debian/patches/Escape-user-provided-values-in-ldap_authentication-and-ld.patch anope-2.0.17/debian/patches/Escape-user-provided-values-in-ldap_authentication-and-ld.patch --- anope-2.0.17/debian/patches/Escape-user-provided-values-in-ldap_authentication-and-ld.patch 1970-01-01 00:00:00.000000000 +0000 +++ anope-2.0.17/debian/patches/Escape-user-provided-values-in-ldap_authentication-and-ld.patch 2026-11-22 15:40:50.000000000 +0000 @@ -0,0 +1,52 @@ +From: Sadie Powell +Date: Tue, 26 May 2026 09:30:15 +0100 +Subject: Escape user-provided values in ldap_authentication and ldap_oper. + +--- + modules/extra/m_ldap_authentication.cpp | 6 ++++-- + modules/extra/m_ldap_oper.cpp | 8 ++++++-- + 2 files changed, 10 insertions(+), 4 deletions(-) + +diff --git a/modules/extra/m_ldap_authentication.cpp b/modules/extra/m_ldap_authentication.cpp +index 1d44c80..9aca974 100644 +--- a/modules/extra/m_ldap_authentication.cpp ++++ b/modules/extra/m_ldap_authentication.cpp +@@ -84,7 +84,9 @@ class IdentifyInterface : public LDAPInterface + { + if (ii->admin_bind) + { +- Anope::string sf = search_filter.replace_all_cs("%account", ii->req->GetAccount()).replace_all_cs("%object_class", object_class); ++ Anope::string sf = search_filter ++ .replace_all_cs("%account", ii->lprov->EscapeSF(ii->req->GetAccount())) ++ .replace_all_cs("%object_class", object_class); + try + { + Log(LOG_DEBUG) << "m_ldap_authentication: searching for " << sf; +@@ -296,7 +298,7 @@ class ModuleLDAPAuthentication : public Module + attributes[3].name = this->password_attribute; + attributes[3].values.push_back(pass); + +- Anope::string new_dn = username_attribute + "=" + na->nick + "," + basedn; ++ Anope::string new_dn = username_attribute + "=" + this->ldap->EscapeDN(na->nick) + "," + basedn; + this->ldap->Add(&this->orinterface, new_dn, attributes); + } + +diff --git a/modules/extra/m_ldap_oper.cpp b/modules/extra/m_ldap_oper.cpp +index de6af45..aeae3ef 100644 +--- a/modules/extra/m_ldap_oper.cpp ++++ b/modules/extra/m_ldap_oper.cpp +@@ -115,8 +115,12 @@ class LDAPOper : public Module + throw LDAPException("Could not search LDAP for opertype settings, invalid configuration."); + + if (!this->binddn.empty()) +- this->ldap->Bind(NULL, this->binddn.replace_all_cs("%a", u->Account()->display), this->password.c_str()); +- this->ldap->Search(new IdentifyInterface(this, u), this->basedn, this->filter.replace_all_cs("%a", u->Account()->display)); ++ { ++ Anope::string bdn = this->binddn.replace_all_cs("%a", this->ldap->EscapeDN(u->Account()->display)); ++ this->ldap->Bind(NULL, bdn, this->password.c_str()); ++ } ++ Anope::string af = this->filter.replace_all_cs("%a", this->ldap->EscapeSF(u->Account()->display)); ++ this->ldap->Search(new IdentifyInterface(this, u), this->basedn, af); + } + catch (const LDAPException &ex) + { diff -Nru anope-2.0.17/debian/patches/Fix-an-escaped-value-that-wasn-t-escaped-enough-in-chanst.patch anope-2.0.17/debian/patches/Fix-an-escaped-value-that-wasn-t-escaped-enough-in-chanst.patch --- anope-2.0.17/debian/patches/Fix-an-escaped-value-that-wasn-t-escaped-enough-in-chanst.patch 1970-01-01 00:00:00.000000000 +0000 +++ anope-2.0.17/debian/patches/Fix-an-escaped-value-that-wasn-t-escaped-enough-in-chanst.patch 2026-11-22 15:40:50.000000000 +0000 @@ -0,0 +1,31 @@ +From: Sadie Powell +Date: Tue, 26 May 2026 10:36:50 +0100 +Subject: Fix an escaped value that wasn't escaped enough in chanstats. + +--- + modules/extra/stats/m_chanstats.cpp | 6 ++++-- + 1 file changed, 4 insertions(+), 2 deletions(-) + +diff --git a/modules/extra/stats/m_chanstats.cpp b/modules/extra/stats/m_chanstats.cpp +index f5b01dd..2da9ecd 100644 +--- a/modules/extra/stats/m_chanstats.cpp ++++ b/modules/extra/stats/m_chanstats.cpp +@@ -343,14 +343,16 @@ class MChanstats : public Module + "(nick_, '', 'total'), (nick_, '', 'monthly')," + "(nick_, '', 'weekly'), (nick_, '', 'daily');" + "END IF;" ++ "SET @echan = chan_;" ++ "SET @enick = nick_;" + "SET @update_query = CONCAT('UPDATE `" + prefix + "chanstats` SET line=line+', line_, '," + "letters=letters+', letters_, ' , words=words+', words_, ', actions=actions+', actions_, ', " + "smileys_happy=smileys_happy+', sm_h_, ', smileys_sad=smileys_sad+', sm_s_, ', " + "smileys_other=smileys_other+', sm_o_, ', kicks=kicks+', kicks_, ', kicked=kicked+', kicked_, ', " + "modes=modes+', modes_, ', topics=topics+', topics_, ', ', time_ , '=', time_, '+', line_ ,' " +- "WHERE (nick='''' OR nick=''', nick_, ''') AND (chan='''' OR chan=''', chan_, ''')');" ++ "WHERE (nick='''' OR nick=?) AND (chan='''' OR chan=?)');" + "PREPARE update_query FROM @update_query;" +- "EXECUTE update_query;" ++ "EXECUTE update_query using @enick, @echan;" + "DEALLOCATE PREPARE update_query;" + "END"; + this->RunQuery(query); diff -Nru anope-2.0.17/debian/patches/Fix-resetpass-confirming-accounts-when-not-using-email-co.patch anope-2.0.17/debian/patches/Fix-resetpass-confirming-accounts-when-not-using-email-co.patch --- anope-2.0.17/debian/patches/Fix-resetpass-confirming-accounts-when-not-using-email-co.patch 1970-01-01 00:00:00.000000000 +0000 +++ anope-2.0.17/debian/patches/Fix-resetpass-confirming-accounts-when-not-using-email-co.patch 2026-11-22 15:40:50.000000000 +0000 @@ -0,0 +1,24 @@ +From: Sadie Powell +Date: Wed, 25 Jun 2025 17:36:16 +0100 +Subject: Fix resetpass confirming accounts when not using email confirmation. + +Fixes MantisBT bug 1734. +--- + modules/commands/ns_resetpass.cpp | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +diff --git a/modules/commands/ns_resetpass.cpp b/modules/commands/ns_resetpass.cpp +index 4139e59..3a11ec8 100644 +--- a/modules/commands/ns_resetpass.cpp ++++ b/modules/commands/ns_resetpass.cpp +@@ -106,7 +106,9 @@ class NSResetPass : public Module + else if (passcode.equals_cs(ri->code)) + { + reset.Unset(nc); +- nc->Shrink("UNCONFIRMED"); ++ ++ if (Config->GetModule("nickserv")->Get("registration").equals_ci("mail")) ++ nc->Shrink("UNCONFIRMED"); + + Log(LOG_COMMAND, source, &commandnsresetpass) << "to confirm RESETPASS and forcefully identify as " << na->nick; + diff -Nru anope-2.0.17/debian/patches/Fix-sql_live-on-recent-MariaDB.patch anope-2.0.17/debian/patches/Fix-sql_live-on-recent-MariaDB.patch --- anope-2.0.17/debian/patches/Fix-sql_live-on-recent-MariaDB.patch 1970-01-01 00:00:00.000000000 +0000 +++ anope-2.0.17/debian/patches/Fix-sql_live-on-recent-MariaDB.patch 2026-11-22 15:40:50.000000000 +0000 @@ -0,0 +1,25 @@ +From: Sadie Powell +Date: Thu, 20 Feb 2025 13:05:22 +0000 +Subject: Fix sql_live on recent MariaDB. + +--- + modules/database/db_sql_live.cpp | 6 +++++- + 1 file changed, 5 insertions(+), 1 deletion(-) + +diff --git a/modules/database/db_sql_live.cpp b/modules/database/db_sql_live.cpp +index 407ad6c..493c26d 100644 +--- a/modules/database/db_sql_live.cpp ++++ b/modules/database/db_sql_live.cpp +@@ -174,7 +174,11 @@ class DBMySQL : public Module, public Pipe + if (!this->CheckInit() || obj->GetTimestamp() == Anope::CurTime) + return; + +- Query query("SELECT * FROM `" + this->prefix + obj->GetName() + "` WHERE (`timestamp` >= " + this->SQL->FromUnixtime(obj->GetTimestamp()) + " OR `timestamp` IS NULL)"); ++ Anope::string sql = Anope::printf("SELECT * from `%s%s`", this->prefix.c_str(), obj->GetName().c_str()); ++ if (obj->GetTimestamp()) ++ sql += Anope::printf(" WHERE (`timestamp` >= %s OR `timestamp` IS NULL)", this->SQL->FromUnixtime(obj->GetTimestamp()).c_str()); ++ ++ Query query(sql); + + obj->UpdateTimestamp(); + diff -Nru anope-2.0.17/debian/patches/series anope-2.0.17/debian/patches/series --- anope-2.0.17/debian/patches/series 1970-01-01 00:00:00.000000000 +0000 +++ anope-2.0.17/debian/patches/series 2026-11-22 15:40:50.000000000 +0000 @@ -0,0 +1,17 @@ +0001-Sanitise-messages-before-writing-them-to-the-log.patch +0002-Reject-unsafe-characters-in-commands-run-from-the-we.patch +0003-Don-t-copy-memos-when-cloning-a-channel.patch +0004-Fix-an-unsafe-substr-in-ns_alist.patch +0005-Avoid-repeatedly-checking-if-a-user-has-deep-access-.patch +0006-Fix-a-hang-caused-by-user-provided-massive-number-ra.patch +0007-Fix-bypassing-unconfirmed-status-via-grouping-and-un.patch +0008-Fix-identifying-users-as-the-wrong-account-when-conf.patch +0009-Use-a-stricter-cookie-policy-in-the-httpd-module.patch +0010-Backport-the-random-number-generation-changes-from-2.patch +0011-Add-origin-filtering-to-the-web-panel.patch +0012-Properly-sanitise-get-post-data-in-the-webcpanel-mod.patch +Add-EscapeDN-and-EscapeSF-to-the-LDAP-API.patch +Escape-user-provided-values-in-ldap_authentication-and-ld.patch +Fix-an-escaped-value-that-wasn-t-escaped-enough-in-chanst.patch +Fix-resetpass-confirming-accounts-when-not-using-email-co.patch +Fix-sql_live-on-recent-MariaDB.patch