Skip to content
Misconfiguration Write-up Beginner

Recently I was faced with an assignment where I must deploy an open source application in the infrastructure of a client. They did not have enough time and staff to make the installation so I was asked to setup their environment by installing the required dependencies, installing the source code, giving the right permission etc.

The user was given unprivileged access to a test server but could run vim with sudo on a specific configuration file. Because vim can execute shell commands, the user was able to spawn a root shell and gain full control of the machine.

GorillaGlue Follow

Published on systemweakness.com

Recently I was faced with an assignment where I must deploy an open source application in the infrastructure of a client. They did not have enough time and staff to make the installation so I was asked to setup their environment by installing the required dependencies, installing the source code, giving the right…

GorillaGlue, 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 sudoers configuration allowed an unprivileged user to run vim as root, and vim can execute arbitrary shell commands, leading to privilege escalation.

Impact

The user could become root on the machine, gaining full privileges over what runs on the VM.

What the attacker needed

Unprivileged access to the server; sudo permission to run vim as root

The fix

The sudo rule allowing vim as root should be removed, and instead the unprivileged user should be added to the group that owns the file if editing is needed.

How it was found

  1. Check which commands the user can run with sudo.
  2. Look up vim on GTFOBins and see that it can spawn a shell.
  3. Run vim with sudo on the allowed configuration file.
  4. From inside vim, execute a shell command to start a root shell.
  5. Confirm the new shell has root privileges.

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.

On Linux, sudo lets a user run certain commands as another user, often root. Here, the user was allowed to run the text editor vim as root on one file. Since vim can run shell commands from inside it, the user could open a root shell and take over the whole server.

What is Misconfiguration?

Settings left unsafe: exposed panels, open storage buckets, debug modes, default credentials.

Similar reports

View all

Same bug class and techniques, clearest first.

Security misconfiguration

The lesson behind this report.

Settings left unsafe: exposed panels, open storage buckets, debug modes, default credentials.