How I hacked into a Cambridge’s server and got appreciation letter.
A file upload feature on a Cambridge subdomain allowed uploading a PHP file that was executed by the server, enabling remote command execution. The attacker could run commands like whoami and ls on the server.
Published on medium.com
Hello Hackers, Hope you are doing fine. So today, I will explain how I found a RCE on Cambridge’s Server.
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.
Context
While looking for information on Cambridge's website, the researcher came across a subdomain, which the write-up refers to as subdomain.cam.ac.uk. Digging further into that subdomain, they found a path, referred to as subdomain.cam.ac.uk/path1/path2/upload. The page hosted a file upload feature that accepted an image. Wappalyzer showed that the server was running PHP.
The feature's normal job is to let a visitor upload an image, which the server stores and later serves back. Because the backend was PHP and the upload accepted files, the researcher suspected the page might be vulnerable to a PHP file upload issue.
Setup
The write-up does not describe any account, role or authentication step, and it does not name the tools beyond Wappalyzer (used to fingerprint the server as PHP) and Burp, which the researcher used for testing the upload. No versions are given. The write-up does not describe any login or precondition for reaching the upload endpoint.
Finding it
Two observations drove the test:
- Wappalyzer identified the server as PHP.
- The page had a file upload feature that accepted an image.
A PHP backend combined with an upload that stores user-supplied files is the classic setup for an unrestricted file upload leading to remote code execution, so the researcher started testing the upload with Burp.
Exploitation
Step 1: upload a minimal PHP file
The first attempt was a simple PHP file that echoes "Hello World". It was uploaded successfully to the server. The write-up gives the assumed location of the stored file as:
subdomain.cam.ac.uk/path/path2/upload/images/shell.php.573645783462.png
The stored name keeps the .php extension in the middle and appends a numeric string and .png at the end. The write-up gives this as the assumed location of the stored file, with the .php extension kept inside the name.
Step 2: request the file without the trailing extension
Visiting the full stored location returned "file does not exist". Removing the .png from the end of the location, however, returned the echoed "Hello World". In other words, the PHP file was executed by the server rather than served as a static file.
The code inside the uploaded file ran when the location was requested without the trailing .png.
Step 3: upload a PHP shell and run commands
With code execution confirmed, the researcher uploaded a PHP shell. It was uploaded successfully as well. Commands such as whoami and ls were run through it and returned output, confirming command execution on the server.
The write-up does not include the shell's source, the exact requests, or the command output, so those details are not available here.
Step 4: report
A report was written and sent to Cambridge. A day later, a reply arrived together with an appreciation letter.
Root cause
The upload endpoint accepted a file whose name contained a .php extension and stored it under a name that still contained that extension, and the web server then executed the file when it was requested at the path without the trailing .png. In other words, the upload validation did not prevent a PHP file from being stored, and the server configuration allowed that stored file to be interpreted as PHP.
Why the existing defences did not stop it is not stated. Likely candidates, given the observed behaviour, are that the check was based on the final extension or the appended .png rather than on the content or the full name, and that the directory holding uploads was reachable by the PHP handler. The write-up does not confirm either.
Impact
An attacker who can reach the upload page could store a PHP file and have it executed by the server, then run operating system commands. The researcher demonstrated this with whoami and ls. The severity, CVSS score and any bounty are not given.
Fix
Based on the observed behaviour, the fixes that would address it are: validate uploads by content and by the full filename rather than by a trailing extension, store uploads outside the web root or in a directory where script execution is disabled, and serve uploaded files through a handler that never passes them to the PHP interpreter. Which of these was applied is not stated.
Variants to test
- Double extension with a numeric suffix. Upload a file named like
shell.php.<number>.pngand request the stored path with the trailing extension removed. A positive result is the PHP code executing instead of the file being served or a 404. - Other executable extensions. Try names ending in
.phtml,.php5or.pharwhere the server maps them to the PHP handler. A positive result is the same execution behaviour with the alternative extension. - Content-type and magic-byte checks. Send a PHP file with an image content type and a valid image header prepended. A positive result is the file being accepted and still executed when requested.
- Upload directory reachability. After a successful upload, request the file directly from the upload directory and from any path that strips the appended extension. A positive result is execution from a location that should only serve static content.
- Command execution confirmation. Once code execution is suspected, run a harmless command such as
whoamithrough the uploaded file. A positive result is command output in the response rather than the source of the file.
What happened, in plain words
A security researcher was browsing Cambridge's website looking for information. While doing that, they found a part of the site that most people never notice: a subdomain. A subdomain is a smaller address that sits under a main domain, the way a room number sits under a building address. The main domain here is cam.ac.uk, and the subdomain is written in the write-up as subdomain.cam.ac.uk.
Inside that subdomain they found a page with a file upload feature. A file upload feature is the part of a website that lets you pick a file from your computer and send it to the server, for example to change your profile picture. The server is the computer that runs the website and stores what visitors send it.
The researcher noticed two things about this page. First, a browser extension called Wappalyzer, which looks at a website and guesses what software is running behind it, said the server was running PHP. PHP is a programming language used to build websites. Second, the upload page accepted an image.
Those two facts together made the researcher suspicious. If a website lets you upload a file and the server runs PHP, there is a classic mistake to check for: does the server actually check what kind of file you sent, or does it just take your word for it? If it does not check properly, you might be able to upload a PHP program instead of a picture, and then ask the server to run it. That is called an unrestricted file upload, and when it lets you run your own code on the server it is called remote code execution, or RCE for short.
The researcher tested this idea. They uploaded a tiny PHP file that just prints "Hello World". The server accepted it. When they visited the address where the file was stored, the server said the file did not exist. But when they removed the last part of the address, the .png at the end, the server printed "Hello World". That meant the server had not just stored the file as a picture: it had run the PHP code inside it.
With that confirmed, the researcher uploaded a PHP shell, which is a small program that lets you type commands and have the server run them. They ran commands like whoami and ls, and the server answered. They wrote a report and sent it to Cambridge, and a day later they got a reply with an appreciation letter.
Below is the same story, step by step, with every concept explained from scratch.
The pieces you need to know first
Before walking through the steps, here are the ideas the rest of the article relies on.
A server and a browser. Your browser is the program on your computer that shows web pages. When you type an address, the browser asks a server somewhere else for the page, and the server sends it back. The server is just another computer, run by whoever owns the website, that stores the files and runs the programs that make the site work.
A domain and a subdomain. A domain is the main name of a website, like cam.ac.uk. A subdomain is a name placed in front of it, like subdomain.cam.ac.uk, and it can point to a completely different server or a different part of the same one. Organisations often use subdomains for separate services: one for email, one for a blog, one for an internal tool. Because they are easy to forget, subdomains are a common place to find things that were set up quickly and never checked again.
A path. After the domain comes the path, the part that tells the server which page you want. In subdomain.cam.ac.uk/path1/path2/upload, the path is /path1/path2/upload. Think of the domain as a building and the path as the corridor and room number inside it.
PHP. PHP is a programming language that runs on the server, not in your browser. When you request a page that is written in PHP, the server runs the PHP code and sends you the result, usually HTML, which is what your browser displays. This matters because if you can get a PHP file onto a server and get the server to run it, you are effectively running your own program on someone else's computer.
Wappalyzer. Wappalyzer is a browser extension that inspects a website and tries to identify the software behind it: the web server, the programming language, the content management system and so on. It does this by looking at clues the site gives off, such as file names, headers and page structure. It is a fingerprinting tool, not an attack tool. The researcher used it to learn that the server was running PHP.
Burp. Burp, short for Burp Suite, is a tool that sits between your browser and the server and lets you see and change every request before it is sent. A request is the message your browser sends to the server, for example "please give me this page" or "here is a file I am uploading". Burp is useful because a normal browser hides these messages from you, and you often need to change a small detail, like a file name, to test what the server does. The write-up says the researcher used Burp for testing the upload, but it does not include the actual requests Burp sent.
File upload and what the server does with the file. When you upload a file, your browser sends it to the server, and the server saves it somewhere on its disk. Later, the server can send that file back to anyone who asks for it at the right address. Normally, an image upload saves a picture and serves the picture back. The danger is when the server saves a file that is not a picture and then treats it as a program.
Unrestricted file upload. This is the name for the weakness where a website accepts a file without properly checking what it is. The check might be missing entirely, or it might only look at the end of the file name, or it might only look at a label the browser attaches. If the check can be bypassed, an attacker can put a file of their choosing on the server.
Remote code execution (RCE). This is the consequence. If the uploaded file is a program and the server runs it, the attacker's code executes on the server. From there, the attacker can often run operating system commands, the same commands you would type in a terminal on your own computer. RCE is considered one of the most serious kinds of vulnerability because it turns a website flaw into control over the machine.
A shell. In this context, a shell is a small program uploaded to the server that accepts commands and runs them. It gives the attacker a way to type a command and see the output, without needing to upload a new file for every command.
whoami and ls. These are ordinary commands on Linux and similar operating systems. whoami prints the name of the user account the command is running as. ls lists the files in the current directory. Researchers use them because they are harmless and prove that commands are actually being executed: if you see a username or a file list come back, you know the server ran your command.
Finding the upload page
The researcher was not running a scan or an automated tool. They were reading Cambridge's website for information and happened to notice a subdomain. The write-up refers to it as subdomain.cam.ac.uk, which is a placeholder: the real name is not given.
Digging further into that subdomain, they found a path, referred to as:
subdomain.cam.ac.uk/path1/path2/upload
Again, path1 and path2 are placeholders for the real folder names. The important part is the last segment, upload, which suggests a page whose job is to receive files.
On that page there was a file upload feature that accepted an image. The write-up says the page looked something like a screenshot, but no screenshot is included.

So at this point the researcher had a page that takes files from visitors and a server that runs PHP. That combination is exactly the setup where an unrestricted file upload can turn into remote code execution, which is why they decided to test it.
Setting up the test
The write-up does not describe creating an account, logging in, or any special role. Nothing in the text says a login was needed to reach the upload page. It also does not give versions of any software, and the only tools it names are Wappalyzer, used to identify PHP, and Burp, used to test the upload.
The reasoning behind the test is simple. A website that accepts files has to decide, for every file, whether to keep it and how to treat it later. If the decision is based on something the visitor controls, such as the file name, the visitor can lie. The researcher wanted to find out whether the server would accept a PHP file dressed up as an image, and whether it would then run it.
Step 1: upload a tiny PHP file
The first test was deliberately minimal. The researcher created a simple PHP file that echoes "Hello World". Echoing is just printing text: when the server runs the file, the output is the words "Hello World". A file this small is useful because there is nothing else that could explain the output. If "Hello World" appears, the PHP code ran.
The file was uploaded successfully. The write-up gives the assumed location of the stored file as:
subdomain.cam.ac.uk/path/path2/upload/images/shell.php.573645783462.png
Look closely at the file name at the end: shell.php.573645783462.png. It contains .php in the middle, then a long number, then .png at the end. This tells us something about how the server handled the upload. It did not simply keep the name the researcher sent. The assumed stored name contains .php in the middle, then a long number, then .png at the end. The .php part survived inside the new name.
That detail matters for the next step. If the server had renamed the file to something with no .php in it at all, the PHP code would have had no way to be recognised as PHP. Because the .php was still there, there was a chance the server would still treat the file as a PHP program.
Step 2: request the file without the trailing extension
A stored file is only useful to an attacker if the server will run it. So the next step was to visit the address where the file had been saved.
Visiting the full location, ending in .png, returned "file does not exist". That is a small puzzle: the upload had been reported as successful, yet the file could not be found at that address.
The researcher then removed the .png from the end of the address and requested the file again. This time the server returned "Hello World".
That result is the key finding. The server had not served the file as a static picture. It had passed the file to PHP, PHP had run the code inside it, and the code had printed "Hello World". In other words, the uploaded file was being executed, not displayed.
Why did removing .png change the result? The write-up does not explain the server's internal routing, so the exact reason is not stated. What the behaviour shows is that removing the trailing .png from the address caused the PHP code to run. The practical lesson is that the stored name contained a working PHP extension, and the server was willing to use it.
Step 3: upload a shell and run commands
With code execution confirmed, the researcher uploaded a PHP shell. The shell was uploaded successfully, just like the first file. Through it, the researcher ran commands such as whoami and ls, and both returned output.
This is the difference between "my code ran once" and "I have command execution". The first file only printed a fixed string. A shell lets you choose the command each time. When whoami returns a username and ls returns a file listing, you know the server is running operating system commands on your behalf.
The write-up does not include the shell's source code, the exact requests that were sent, or the output of the commands. So those details cannot be shown here.
Step 4: report and reply
The researcher wrote a report and sent it to Cambridge. A day later, a reply arrived, together with an appreciation letter.
Why this worked
The upload page accepted a file whose name contained a .php extension. The server stored it under a name that still contained that extension. And when the file was requested at the path without the trailing .png, the web server executed it as PHP.
Put together: the upload validation did not stop a PHP file from being stored, and the server configuration allowed that stored file to be interpreted as PHP. Both conditions had to hold for the attack to work. A strict upload check alone would have blocked it, and a server that never runs uploaded files as PHP would also have blocked it.
Given what was observed, plausible explanations are that the check looked only at the final extension or at the appended .png, rather than at the content or the full file name, and that the upload directory was reachable by the PHP handler. Neither is confirmed by the report.
What an attacker could do with this
Anyone who could reach the upload page could store a PHP file and have the server run it, then run operating system commands. The researcher demonstrated exactly that with whoami and ls.
It also does not give a severity rating, a CVSS score or a bounty.
How it should be fixed
Based on the observed behaviour, the fixes that would address it are:
- Validate uploads by content and by the full file name, not by a trailing extension.
- Store uploads outside the web root, or in a directory where script execution is disabled.
- Serve uploaded files through a handler that never passes them to the PHP interpreter.
Which of these was applied is not stated.
Variants worth testing
If you ever find yourself in front of a similar upload page, these are the variations the behaviour in this report suggests trying. Each one is a way of asking the same question: will the server store a program and then run it?
- Double extension with a numeric suffix. Upload a file named like
shell.php.<number>.pngand request the stored path with the trailing extension removed. A positive result is the PHP code executing instead of the file being served or a 404. - Other executable extensions. Try names ending in
.phtml,.php5or.pharwhere the server maps them to the PHP handler. A positive result is the same execution behaviour with the alternative extension. - Content-type and magic-byte checks. Send a PHP file with an image content type and a valid image header prepended. A positive result is the file being accepted and still executed when requested.
- Upload directory reachability. After a successful upload, request the file directly from the upload directory and from any path that strips the appended extension. A positive result is execution from a location that should only serve static content.
- Command execution confirmation. Once code execution is suspected, run a harmless command such as
whoamithrough the uploaded file. A positive result is command output in the response rather than the source of the file.
Glossary
- Subdomain: a name placed in front of a main domain, such as
subdomain.cam.ac.uk, often pointing to a separate service or server. - Path: the part of a web address after the domain that identifies the page or folder being requested, such as
/path1/path2/upload. - Server: the remote computer that stores a website's files and runs its programs, sending pages back to your browser.
- PHP: a programming language that runs on the server to generate web pages; if an attacker can get PHP code executed on a server, they can run their own program there.
- Wappalyzer: a browser extension that fingerprints a website's underlying software, such as the web server and programming language.
- Burp (Burp Suite): a tool that sits between browser and server so you can inspect and modify requests, including uploads.
- Request: the message a browser sends to a server asking for a page or sending data.
- File upload feature: the part of a website that lets a visitor send a file from their computer to the server.
- Unrestricted file upload: a weakness where a site accepts a file without properly checking what it is, allowing a program to be stored on the server.
- Remote code execution (RCE): a vulnerability where an attacker's code runs on someone else's server, often allowing operating system commands to be run.
- Shell: a small uploaded program that accepts commands and runs them on the server, returning the output.
whoami: an operating system command that prints the username the command is running as.ls: an operating system command that lists the files in the current directory.- Web root: the folder on a server whose contents are served to visitors over the web; files stored there can be requested by anyone.
- Extension: the part of a file name after the last dot, such as
.pngor.php, which usually tells the system what kind of file it is. - Content type: a label sent with a file or request describing what kind of data it is, such as an image or a web page.
- Magic bytes: the first few bytes of a file that identify its real format, regardless of what the file name or content type claims.