Skip to content
RCE Write-up Intermediate

How I pwend my high school CS teacher

A Django homework submission platform left debug mode on, leaking source code and tokens, and had a path traversal in the homework number field that allowed deleting arbitrary files. The content filter for uploaded C++ files could be bypassed using token pasting or by using popen() instead of system(), leading to remote code execution on the Raspberry Pi.

gombosakosroland Follow

Published on medium.com

I was never a good student. I didn’t like doing something just because I was told to — I needed to understand why, and if it didn’t tickle that part of my brain, it was all for nothing.

Gombos Ákos-Roland, 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

Root cause

Likely multiple mistakes: debug mode enabled in production, unsanitised user input used in file paths, and a naive string-based content filter that doesn't understand C++ preprocessing.

What the attacker needed

Access to the web application; ability to upload files; a netcat listener on attacker machine

The fix

The vulnerabilities were fixed by turning off debug mode, adding input validation for the path, and improving the content filter (though the report notes the patch was minimal).

How it was found

  1. Open the site and use browser developer tools to inspect the JavaScript, finding a minified file that allowed editing homework due dates via local overrides.
  2. Trigger a server error on the upload endpoint to reveal Django's debug page, which exposed stack traces, local variables, and POST request contents including tokens and usernames.
  3. Submit a homework number containing directory traversal sequences to manipulate the file storage path.
  4. Reconstruct the upload handler source code by triggering errors at different points to leak more of the file from debug pages.
  5. Bypass the content filter by using C++ token pasting to hide the string 'system', or by using popen() which was not blocklisted.
  6. Upload a C++ file that uses popen() to execute a reverse shell command, connecting back to a netcat listener.

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 teacher's website had a setting left on that shows detailed error messages, which revealed secret parts of the code. Also, the part of the site that handles file uploads didn't check the assignment number properly, so someone could make the server delete files anywhere. Finally, the filter that was supposed to block dangerous C++ code could be tricked, allowing the attacker to run commands on the server.

What is RCE?

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.

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.