Bug 895054 (CVE-2013-0179)

Summary: CVE-2013-0179 memcached: DoS due to buffer overrun when printing out keys to be deleted in verbose mode
Product: [Other] Security Response Reporter: Jeremy Sowden <jeremy>
Component: vulnerabilityAssignee: Red Hat Product Security <security-response-team>
Status: CLOSED WONTFIX QA Contact:
Severity: low Docs Contact:
Priority: low    
Version: unspecifiedCC: jorton, jrusnack, lindner, matthias, mlichvar
Target Milestone: ---Keywords: Security
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 895072 (view as bug list) Environment:
Last Closed: 2019-06-10 10:59:56 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 895139, 895140    
Bug Blocks: 1052870    

Description Jeremy Sowden 2013-01-14 12:10:54 UTC
Description of problem:

When run with "-vv", on receipt of a binary-protocol deletion request, memcached prints out the key to be deleted in a way that can lead to a buffer overrun and crash.

Version-Release number of selected component (if applicable):

1.4.4, although this currently affects all later versions.

How reproducible:

Run memcached with "-vv", use memrm to send deletion requests and observe output.

Steps to Reproduce:

1. memcached -p 12345 -vv 2>&1 | grep '^Deleting'
2. memrm --servers localhost:12345 --binary ABCDEF xyz
3. Check the output from memcached.

Actual results:

[jsowden:~] $ memcached -p 2300 -m 64 -c 1024 -r -vv 2>&1 | grep 'Deleting'
Deleting ABCDEF
Deleting xyzDEF

Expected results:

[jsowden:~] $ memcached -p 2300 -m 64 -c 1024 -r -vv 2>&1 | grep 'Deleting'
Deleting ABCDEF
Deleting xyz

Additional info:

I've opened a bug report upstream: https://code.google.com/p/memcached/issues/detail?id=306

Comment 2 Vincent Danen 2013-01-14 16:59:20 UTC
Proposed patch:

https://code.google.com/p/memcached/issues/attachmentText?id=306&aid=3060004000&name=0001-Fix-buffer-overrun-when-logging-key-to-delete-in-bin.patch&token=3GEzHThBL5cxmUrsYANkW03RrNY%3A1358179503096

However, I'm not sure if we would consider this a security flaw.  For one, you need to run memcached with -vv (probably not used in production but for testing).

It would also indicate that this would be a local-only flaw (or from other trusted source) as the docs explicitly say that you shouldn't expose memcached to untrusted users:

https://code.google.com/p/memcached/wiki/NewConfiguringServer#Networking

In particular:

"Memcached does not spend much, if any, effort in ensuring its defensibility from random internet connections. So you must not expose memcached directly to the internet, or otherwise any untrusted users. Using SASL authentication here helps, but should not be totally trusted."

I guess this could be considered a low-impact security flaw due to the conditions required to make an attack meaningful:

- start memcached with -vv (not the default)
- make it available to untrusted users (not recommended as per docs)
- memcached runs non-root and with FORTIFY_SOURCE/SSP any buffer overflow should be rendered a simple DoS

Comment 3 Vincent Danen 2013-01-14 17:08:28 UTC
Created memcached tracking bugs for this issue

Affects: epel-5 [bug 895139]
Affects: fedora-all [bug 895140]

Comment 5 Vincent Danen 2013-01-14 17:14:13 UTC
CVE request:

http://www.openwall.com/lists/oss-security/2013/01/14/4

Comment 6 Vincent Danen 2013-01-14 20:49:54 UTC
This was assigned CVE-2013-0179.

Comment 7 Fedora Update System 2014-02-03 02:42:13 UTC
memcached-1.4.17-1.fc20 has been pushed to the Fedora 20 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 8 Fedora Update System 2014-02-03 02:48:57 UTC
memcached-1.4.17-1.fc19 has been pushed to the Fedora 19 stable repository.  If problems still persist, please make note of it in this bug report.