diff -u memcached-1.4.14/debian/changelog memcached-1.4.14/debian/changelog --- memcached-1.4.14/debian/changelog +++ memcached-1.4.14/debian/changelog @@ -1,3 +1,19 @@ +memcached (1.4.14-0ubuntu9.2) trusty-security; urgency=medium + + * SECURITY UPDATE: denial of service due to integer overflow + - debian/patches/CVE-2017-9951.patch: check for integer overflow on + key requests + - CVE-2017-9951 + * SECURITY UPDATE: disable listening on UDP port by default due to + use in DDoS amplification attacks + - debian/patches/disable-udp-by-default.patch: disable UDP port by + default. (LP: #1752831) + - debian/NEWS: add explanation and document how to re-enable UDP if + necessary. + - CVE-2018-1000115 + + -- Steve Beattie Mon, 05 Mar 2018 02:10:59 -0800 + memcached (1.4.14-0ubuntu9.1) trusty-security; urgency=medium * SECURITY UPDATE: multiple integer overflow vulnerabilities diff -u memcached-1.4.14/debian/patches/series memcached-1.4.14/debian/patches/series --- memcached-1.4.14/debian/patches/series +++ memcached-1.4.14/debian/patches/series @@ -11,0 +12,2 @@ +CVE-2017-9951.patch +disable-udp-by-default.patch only in patch2: unchanged: --- memcached-1.4.14.orig/debian/NEWS +++ memcached-1.4.14/debian/NEWS @@ -0,0 +1,7 @@ +memcached (1.4.14-0ubuntu9.2) xenial; urgency=medium + + * memcached is now configured to disable its UDP port by default, to + prevent its use as a DDoS amplifier. To re-enable UDP service, add + '-U 11211' to /etc/memcached.conf and restart the memcahced service. + + -- Steve Beattie Mon, 05 Mar 2018 02:12:01 -0800 only in patch2: unchanged: --- memcached-1.4.14.orig/debian/patches/CVE-2017-9951.patch +++ memcached-1.4.14/debian/patches/CVE-2017-9951.patch @@ -0,0 +1,36 @@ +From 328629445c71e6c17074f6e9e0e3ef585b58f167 Mon Sep 17 00:00:00 2001 +From: dormando +Date: Tue, 4 Jul 2017 00:32:39 -0700 +Subject: [PATCH] sanity check + +--- + items.c | 2 ++ + memcached.c | 2 +- + 2 files changed, 3 insertions(+), 1 deletion(-) + +diff --git a/items.c b/items.c +index 637e5e745..83a2ea37d 100644 +--- a/items.c ++++ b/items.c +@@ -368,6 +368,8 @@ void item_free(item *it) { + bool item_size_ok(const size_t nkey, const int flags, const int nbytes) { + char prefix[40]; + uint8_t nsuffix; ++ if (nbytes < 2) ++ return false; + + size_t ntotal = item_make_header(nkey + 1, flags, nbytes, + prefix, &nsuffix); +diff --git a/memcached.c b/memcached.c +index 0f0335795..a89df965d 100644 +--- a/memcached.c ++++ b/memcached.c +@@ -4967,7 +4967,7 @@ static void drive_machine(conn *c) { + + case conn_swallow: + /* we are reading sbytes and throwing them away */ +- if (c->sbytes == 0) { ++ if (c->sbytes <= 0) { + conn_set_state(c, conn_new_cmd); + break; + } only in patch2: unchanged: --- memcached-1.4.14.orig/debian/patches/disable-udp-by-default.patch +++ memcached-1.4.14/debian/patches/disable-udp-by-default.patch @@ -0,0 +1,65 @@ +From dbb7a8af90054bf4ef51f5814ef7ceb17d83d974 Mon Sep 17 00:00:00 2001 +From: dormando +Date: Tue, 27 Feb 2018 10:50:45 -0800 +Subject: [PATCH] disable UDP port by default + +As reported, UDP amplification attacks have started to use insecure +internet-exposed memcached instances. UDP used to be a lot more popular as a +transport for memcached many years ago, but I'm not aware of many recent +users. + +Ten years ago, the TCP connection overhead from many clients was relatively +high (dozens or hundreds per client server), but these days many clients are +batched, or user fewer processes, or simply anre't worried about it. + +While changing the default to listen on localhost only would also help, the +true culprit is UDP. There are many more use cases for using memcached over +the network than there are for using the UDP protocol. +--- + memcached.c | 6 ++---- + t/issue_67.t | 4 ++-- + 2 files changed, 4 insertions(+), 6 deletions(-) + +Index: b/memcached.c +=================================================================== +--- a/memcached.c ++++ b/memcached.c +@@ -205,7 +205,7 @@ static void settings_init(void) { + settings.use_cas = true; + settings.access = 0700; + settings.port = 11211; +- settings.udpport = 11211; ++ settings.udpport = 0; + /* By default this string should be NULL for getaddrinfo() */ + settings.inter = NULL; + settings.maxbytes = 64 * 1024 * 1024; /* default is 64MB */ +@@ -6204,9 +6204,7 @@ int main (int argc, char **argv) { + } + } + +- if (tcp_specified && !udp_specified) { +- settings.udpport = settings.port; +- } else if (udp_specified && !tcp_specified) { ++ if (udp_specified && settings.udpport != 0 && !tcp_specified) { + settings.port = settings.udpport; + } + +Index: b/t/issue_67.t +=================================================================== +--- a/t/issue_67.t ++++ b/t/issue_67.t +@@ -73,12 +73,12 @@ sub when { + + # Disabling the defaults since it conflicts with a running instance. + # when('no arguments', '', 11211, 11211); +-when('specifying tcp port', '-p 11212', 11212, 11212); ++when('specifying tcp port', '-p 11212', 11212, -1); + when('specifying udp port', '-U 11222', 11222, 11222); + when('specifying tcp ephemeral port', '-p -1', 0, 0); + when('specifying udp ephemeral port', '-U -1', 0, 0); + when('tcp port disabled', '-p 0', -1, -1); +-when('udp port disabled', '-U 0', -1, -1); ++when('udp port disabled', '-U 0', 11211, -1); + when('specifying tcp and udp ports', '-p 11232 -U 11233', 11232, 11233); + when('specifying tcp and disabling udp', '-p 11242 -U 0', 11242, -1); + when('specifying udp and disabling tcp', '-p -1 -U 11252', 0, 11252);