the_open_door
coffee
ESEN
← Back to index

Custom group abuse (find / -group)

Full command arsenal in the cheatsheet

id returns a group nobody has ever heard of: management, gods, logs, filter. It is on no list of privileged groups because it is not a system group, the administrator of that machine created it, and that is why its name tells you absolutely nothing. A custom group does not grant capabilities the way disk or docker do: it grants exactly what it owns. And that is a question with a one-line answer.

The question#


id

find / -group gods 2>/dev/null

Two refinements worth making as soon as the list goes past twenty lines. The first is to filter by what actually matters, which is being able to write:


find / -group gods -type f -writable 2>/dev/null

The second is to drop the predictable noise: the user's own home and ephemeral files usually belong to their primary group and are not the finding. In redpanda the query runs straight away with a grep -vE 'home|proc' to get them out of the way.

What you find decides the attack#

The group is the same mechanism in all four machines of the corpus, and the escalation is different in each one because what it owns is different.

A directory a root service loads code from. In alert, albert belongs to management and the query returns /opt/website-monitor/config with its .php files inside. The web monitor runs as root and includes whatever is in that directory, so dropping a file of our own there is execution as root (group-writable directory in a root service).


find / -group management 2>/dev/null

A library a privileged process imports. In symfonos-3 the gods group owns, writable, the whole python2.7 standard library. On its own that does nothing: you need to know which module a root program imports, and that is where the finding meets another tool (pspy showed a Python FTP client launched every minute by root). With that fact the list is filtered and ftplib.py appears, and before touching it you check in the script's code that it really imports it instead of assuming so (Python library hijacking):


find / -group gods -type f -writable 2>/dev/null | grep ftp

A file a root process reads. In redpanda, the logs group grants write access to /opt/panda_search/redpanda.log, and a root Java process walks it line by line, treating each line as fields separated by ||. Writing to that file is not writing a log, it is dictating the input of a privileged program: one separator too many shifts the fields and the next one ends up being a path the root process opens.

A file you can only read. There is not always write access, and it is not always needed. In expressway, ike belongs to proxy and all that gives is Squid's logs; inside them there is an internal hostname nobody knew about, and that hostname is half of the escalation that follows. It is the same role adm plays with /var/log: it does not give root, it gives information nobody thought was sensitive.

Requirements#

Membership of the group (id says so, and membership is resolved at logon: if we have just added ourselves to a group, the current shell does not know it and a new session is needed) and that the group owns something a privileged process touches. A group that only owns files nobody else reads is a dead end, and finding that out is just as valuable: it closes the path in thirty seconds.

How to detect it. The review at rest is the attacker's query in reverse and costs the same: for every non-system group, list what it owns (find / -group <g> ! -user root, or a getent group followed by a find per group) and look in particular at what is group-writable and at the same time within reach of a root service. A configuration directory of a privileged daemon whose owning group is not root is the deviation to investigate, as is a service account showing up in id with a group that does not belong to it. At runtime the signature depends on the vector, and the three the corpus leaves are measurable: a new file in a service's configuration directory followed by its execution (auditd with a watch on that directory), a write to a module of the interpreter's standard library (which on a stable system never changes outside a package update) and a write by a user process to a log that a root process later reads.

Defence. Treat custom groups the way sudo is treated: they are privilege grants, not organisational labels. Code and configuration executed by root must be owned by root and not group-writable; if a group has to write somewhere, let it be data, never files a privileged process interprets (code, libraries, templates, systemd units) nor the input of a parser running as root. And review membership: almost every one of these machines grants the group to a web service account, which is the first one to fall. Related to privileged groups on Linux and to permission manipulation.

Machines where it's used