Skip to content
RCE Write-up Intermediate

Complex Attack Types: Sample Scenarios 18

A web application running on port 5000 passed user input into Python's eval() function, allowing an attacker to run arbitrary operating system commands. The attacker used this to obtain a reverse shell, then escalated privileges by abusing a sudo-allowed Python script and a group-writable backup directory to reach root.

brsdncr Follow

Published on medium.com

Cyber ​​world is a way of life. Practice and theory are two clear elements that you should always develop.

Baris Dincer, on 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

Impact

An unauthenticated attacker could execute arbitrary commands on the server and, through further misconfigurations, escalate to root, fully compromising the host.

What the attacker needed

Network access to port 5000; source code downloadable from the app

The fix

The application should not pass user input to eval(); it should parse and validate the mathematical expression with a safe parser instead.

How it was found

  1. Scan the target with nmap and find the application on port 5000
  2. Download the application source code from the page and review app.py
  3. Spot the eval() call and target the bisection operation input
  4. Intercept the POST request in Burp and replace the body parameter with a Python expression that opens a reverse shell
  5. Start a listener and forward the request to receive the shell
  6. Check sudo rights, read the encrypt.py script, and use the sudo-allowed python3 run to escalate, then SSH in as gordon and find root-owned files in the gordon 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.

The application took whatever a user typed into a maths form and ran it as Python code instead of treating it as plain data. Because of that, the attacker could make the server run their own commands and open a connection back to the attacker's machine, giving them a remote shell. From there they found other misconfigured permissions to become the root 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 brsdncr

View all

7 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.