Skip to content
Misconfiguration Write-up Beginner

Gaining Root Access Via Nfs Misconfiguration

An NFS share was exported without root squash, so a low-privilege user could place a SUID bash binary on the share and run it on the target to become root. The same share also exposed an SSH private key that gave initial shell access.

Bit_Picker Follow

Published on infosecwriteups.com

Network File System (NFS) is a protocol that allows systems to share files and directories over a network. This makes it easier for multiple users or machines to access and work on shared data without transferring files back and forth manually.

Bit_Picker, on infosecwriteups.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 NFS export was configured with no_root_squash, allowing a remote user to create files owned by root with the SUID bit set on the shared directory.

Impact

An attacker with a low-privilege account could escalate to root on the target, and the share also leaked an SSH key that gave initial access.

What the attacker needed

NFS share exported without root squash; Network access to NFS port 2049; Low-privilege shell on target

The fix

The share should be exported with root squash enabled, access restricted to trusted hosts, and shared directories audited for sensitive files.

How it was found

  1. Scan for NFS on port 2049 and list exported shares with showmount.
  2. Mount the shared /home directory locally.
  3. Find an SSH private key in the share and use it to log in as a low-privilege user.
  4. Copy the target's bash binary to the share and set the SUID bit on it.
  5. Log back in and run the SUID bash with the -p flag to get a root shell.

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.

NFS is a way for computers to share folders over a network. If the server does not 'squash' the root user, files created by an attacker on the share keep root ownership and special permissions. The attacker put a copy of the bash program on the share with a special bit set so it runs as root, then ran it to get a root shell.

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.