Skip to content
RCE Write-up Intermediate

Down — From Web Application Misconfiguration to Root

The web application passed user-supplied URLs and port values into shell commands run with cURL and Netcat, so extra arguments could be injected. This let an attacker read local files and run commands as the web server user, and a weak vault password plus unrestricted sudo then led to root.

Emmanuel Wiseman Follow

Published on emmanuelwiseman.medium.com

This assessment targeted the Hack The Box machine Down, a Linux host exposing SSH and an HTTP application.

Emmanuel Wiseman, on emmanuelwiseman.medium.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 application validated only part of the input (a URL prefix, or the integer part of a port) and then pasted the original string into a shell command, so shell escaping did not stop extra arguments reaching cURL and Netcat.

Impact

An unauthenticated attacker could read local files and execute commands as the web server user, and with a weak vault password and unrestricted sudo this led to full root compromise of the host.

What the attacker needed

Network access to the web app; a listener on the attacker side; vault readable by web user; weak vault master password

The fix

The application should validate the complete input and invoke cURL and Netcat with explicitly separated arguments rather than building shell command strings, and the account should not have unrestricted sudo.

How it was found

  1. Submit a URL that starts with a normal HTTP address followed by a local file reference to the URL checker.
  2. Switch to the TCP checking mode and supply a port value with extra Netcat arguments.
  3. Start a listener on the attacking machine and send the crafted request to receive a shell as the web server user.
  4. Enumerate files owned by the local user and copy the encrypted password vault.
  5. Run an offline dictionary attack against the vault to recover the master password and stored credentials.
  6. Log in over SSH with the recovered credentials and use the unrestricted sudo rights to become root.

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.

The site built a command line out of whatever the visitor typed and ran it on the server. By adding extra words to the input, the attacker made the server run a different program or read a local file. A weak password on a stored password vault then gave a normal user account, which could run anything as the administrator.

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 Emmanuel Wiseman

View all

4 more disclosed reports, 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.