Skip to content
RCE Write-up Intermediate

CVE-2021–3493 — OverlayFS — Privilege Escalation

A missing permission check in OverlayFS allowed a local attacker to set arbitrary capabilities on files in the outer namespace, enabling privilege escalation to root. The attacker could execute a shell with elevated privileges.

Emin Skrijelj Follow

Published on systemweakness.com

This vulnerability allows attackers with local access to escalate their privileges and gain root on the target system. It allows you to manipulate files within the OverlayFS filesystem with which you can modify system files and execute arbitrary code with elevated privileges or give yourself a root on the system.

Emin Skrijelj, on systemweakness.com

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 permission check for setting file capabilities was missing in the setxattr operation, allowing capabilities to be set on files in the outer namespace without proper validation.

Impact

A local attacker could escalate privileges to root, gaining full control over the system.

What the attacker needed

Local access to the system; affected Ubuntu version; gcc and git installed

The fix

The patch moved the capability permission check to vfs_setxattr and added a condition to only allow setting the security.capability attribute when the size is non-zero.

How it was found

  1. Create the required directories and set permissions.
  2. Isolate the program using namespaces.
  3. Set up specific permissions using setuid and setgid.
  4. Mount the OverlayFS filesystem.
  5. Copy the executable to the merged directory.
  6. Set the special attribute on the copied executable.

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.

OverlayFS is a Linux feature that combines folders into one view. A bug meant that when setting special file attributes, the system did not check if the user was allowed to do so. This let a normal user give a program extra powers and become the administrator (root).

What is RCE?

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.

More by Emin Skrijelj

View all

1 more disclosed report, best first.

Similar reports

View all

Same bug class and techniques, clearest first.

Remote code execution

The lesson behind this report.

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.