Vulnerability in Linux containers – investigation and mitigation
A vulnerability in Linux container runtimes allows a program inside a container to drop its primary group, which can bypass negative group permissions. An attacker with code execution in a container could read or modify files they should not be able to access.
Published on benthamsgaze.org
Operating system access controls, that constrain which programs can open which files, have existed for almost as long as computers themselves. Access controls are still widely used and are more flexible and efficient when compared to cryptographically protecting files.
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the container runtime does not duplicate the user's primary group into the supplementary groups list, unlike the standard Linux login process, and the specification does not require it.
Impact
An attacker with code execution in a container could read or modify files they should not be able to, but only if negative group permissions are in use, which is not common.
What the attacker needed
Code execution in a container; negative group permissions in use
The fix
The vulnerability should be fixed by ensuring container runtimes duplicate the primary group into supplementary groups, and workarounds include starting with su -l, manually duplicating groups, or blocking setuid/setgid programs.
How it was found
- Run code inside the container.
- Create a set-group program with the group set to one of the supplementary groups.
- Run the program, which drops the primary group.
- Access a file with negative group permissions for the primary group.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
In Linux, files have permissions for the owner, the group, and everyone else. Normally, a user's primary group is also included in their list of groups, so they can't escape group-based restrictions. But in containers, the primary group is not duplicated, so a program can drop it and bypass restrictions that rely on denying access to that group.
What is Access control?
A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.