Skip to content

maxuru ~ % cat memcached/run-as-non-root

Run Memcached as a non-root user

Severity: mediumApplies to: Memcached 1.5.xApplies to: Memcached 1.6.x
The fix/etc/memcached.conf
Terminal window
-u memcache

Memcached will not silently run as root. If it is started by root and no -u is given, it refuses and says so:

must add '-u root' to start as root

That is a genuinely good default and it does real work — it makes running as root a deliberate, typed-out decision rather than something that happens when nobody was paying attention. This is the same shape as Apache’s defaults: the interesting failure is not the default, it is somebody having overridden it.

So the finding on this page is rarely “nobody set -u”. It is usually -u root sitting in a config file, added years ago to make an error go away.

Why it matters for this daemon in particular

Section titled “Why it matters for this daemon in particular”

Memcached parses attacker-controlled input on a network socket, and it does so with no authentication in front of it in the default build. That combination is exactly the one where the runtime user decides whether a parsing bug is a contained problem or a host compromise.

It is rated medium rather than higher because the defaults already handle it on almost every install — the packages set -u memcache, and the official Docker image declares USER memcache. The value of this page is the check, not the change.

Install User
Debian / Ubuntu package -u memcache in /etc/memcached.conf
Official Docker image USER memcache in the image
Built from source, run by hand Whatever you pass — refuses root without -u

The container case is worth stating because it is the one people assume is weakest and is not: the official image already drops to an unprivileged user. If you build your own image from source, that is where the guarantee disappears.

Nothing about the data. An unprivileged memcached still hands every cached value to anyone who can reach the port, because the user it runs as has no bearing on protocol-level access. This control limits the blast radius of a bug in the daemon; it does not add a single access check.

That ordering is why it sits below binding and authentication on the checklist.