Skip to content
RCE Write-up Intermediate

Unveiling RCE on Dutch Government Website

A profile picture upload feature accepted a PHP file and stored the original file in a directly reachable directory, so the uploaded script could be executed on the server. An attacker with an account could run arbitrary commands on the web server.

Nayeem Islam Follow

Published on medium.com

Assalamu Alaikum! This is Nayeem Islam.

Nayeem Islam, 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.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 3 min read.

Context

Nayeem Islam (@nayeems3c) found a file upload bypass leading to remote code execution (RCE) on a Dutch government e-learning platform. The site, referred to here as elearning.example.nl, was built with the PHP Laravel framework and allowed anyone to sign up. The vulnerable feature was the profile picture upload: users could upload an image, which the application stored and later served back. The report does not name the specific Laravel version or the upload library in use.

Setup

  • Target: elearning.example.nl, a healthcare-related e-learning portal found through a public scope repository.
  • Account: a normal self-registered user account was sufficient; no special role was needed.
  • Tools: crt.sh for subdomain enumeration, a browser for manual testing, and a simple PHP shell for the RCE proof.
  • Preconditions: the upload endpoint accepted a .txt file, and the uploaded file was reachable through a predictable path.

Finding it

After registering, the researcher tested XSS, HTML injection and CSRF on the profile without success. The profile picture upload was the next feature to examine. Uploading a plain test.txt file succeeded, but viewing the uploaded image returned the error There is an error with this image file.

The URL of the uploaded image contained a conversions subdirectory. The researcher reasoned that the application stored the original file under a numeric directory (the user identifier) and then wrote a converted .jpg copy into conversions. The numeric identifier was sequential, so an IDOR attempt on /storage/528 was tried, but it did not work.

From the original on medium.com

The report shows the URL structure after upload, where the txt file had been renamed and converted to jpg.

Exploitation

Step 1: Reach the original file

https://elearning.example.nl/528/my-image.txt

The assumption was correct: the original .txt file executed. A first report was submitted with this proof of concept.

Step 2: Upload a PHP shell

After reading about file upload exploitation, the researcher uploaded a minimal PHP shell through the same profile picture feature:

<?php system($_GET['cmd']); ?>

Step 3: Execute a command

The profile image was opened in a new tab and the URL was modified to pass a command through the cmd parameter. The result was remote code execution.

From the original on medium.com

The report shows the modified URL with the RCE command and the outcome.

A second report was sent to demonstrate the impact of the RCE.

Root cause

The application validated or converted the uploaded file for the image preview but kept the original upload in a web-accessible directory. The conversion step created a .jpg copy under conversions, yet the original file, with its original extension, remained reachable at a predictable path derived from the user identifier. Requesting the uploaded PHP file directly gave command execution. The report does not describe the server configuration or the validation code, so the exact reason the original file was retained is not stated; likely the upload handler saved the original before generating the converted copy and did not remove or restrict access to it.

Impact

An authenticated user could upload a PHP file as a profile picture and execute arbitrary commands on the server by requesting the original file with a cmd parameter. The researcher notes that NCSC-NL advised against uploading a shell to their system, and the issue was resolved within a month.

Fix

A robust fix would be to store uploaded originals outside the web root, serve them only through a handler that enforces the expected content type, and ensure the upload directory does not execute scripts. The report does not confirm which of these measures was taken.

Variants to test

  • Upload a .txt file and request it directly from the numeric directory to see whether originals are retained outside the conversion path. A positive result is the original file being served.
  • Upload a .php file with a minimal shell and request it from the same directory. A positive result is command output in the response.
  • Try other executable extensions accepted by the server (for example .phtml, .php5) if the application only blocks .php. A positive result is the server executing the file.
  • Test whether the numeric directory is sequential and whether other users' original files can be accessed by changing the identifier. A positive result is another user's file being returned.
  • Check whether the conversions directory itself can serve executable files, in case the conversion step preserves the extension. A positive result is execution from that path.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 11 min read.

What happened, in plain words

A security researcher found a way to make a Dutch government website run his own code. The website was an e-learning platform, a site where people sign up and take courses online. It let anyone create an account, and it let each user upload a profile picture. The upload feature was the weak point.

When you upload a picture, the site is supposed to keep only an image. This site did something more careless: it kept your original file too, in a place anyone on the internet could reach, and it did not stop that file from being run as a program. The researcher first uploaded a harmless text file and proved he could still open it on the server. Then he uploaded a tiny program written in PHP (a language many websites use) and asked the server to run it. The server did, which gave him the ability to run commands on the machine. That is called remote code execution, or RCE.

He reported it, the Dutch government's computer security centre (NCSC-NL) confirmed it, and the problem was fixed within a month. He was awarded the swag he had wanted. It got lost in the post.

Background: how he got here

The researcher, Nayeem Islam, was a student from Bangladesh learning web application security. His first write-up describes how he bypassed a file upload feature to get RCE on a Dutch government website.

His bug bounty journey began in September 2021. A bug bounty is a programme where an organisation invites people to look for security problems in its systems and pays or rewards them for reporting the problems responsibly instead of exploiting them. He saw researchers on Twitter sharing a picture of a black T-shirt given out by the Dutch government programme, and from then on he wanted one.

This picture is taken from Tahmid Niloy bhai's timeline. From the original on medium.com

He started with easy targets, the kind beginners try first, and mostly got answers saying his reports were informational (not a real security problem) or not applicable (out of scope, meaning the programme had not authorised testing on that system). In April 2022 he found his first valid bug, which encouraged him to keep trying on Dutch government sites.

Finding the target

He read articles about hacking Dutch government systems to understand how the programme worked. From them he learned that the programme only gives rewards for impactful bugs, so easy, low-value findings would not count.

He searched for the list of systems the programme allowed testing on (the scope) and found a public repository of links. In it he found a site related to healthcare. His reconnaissance skills at the time were basic: reconnaissance (recon) means gathering information about a target before attacking it, and his only technique was subdomain enumeration, finding the smaller named sites that belong to a main domain, such as shop.example.com under example.com.

Using crt.sh, a free public website that lists certificates issued for domains and therefore reveals subdomains, he found one live subdomain. It was an e-learning platform where anyone could sign up. He chose it because more features mean more chances of finding a bug. He also noticed the portal was built with the PHP Laravel framework, a toolkit for building web applications in PHP, which made him expect a bug.

Testing the profile

His target was elearning.example.nl. He registered an account and explored his profile. He tested for three common classes of bug:

  • XSS (cross-site scripting): tricking a site into running JavaScript that an attacker supplied, so that it runs in another user's browser. A simple comparison: writing a fake note on a form that the staff later read out loud as if it were an instruction.
  • HTML injection: getting your own HTML markup into a page, which is a step towards XSS.
  • CSRF (cross-site request forgery): making a logged-in user's browser send a request the user did not intend, because the browser automatically attaches the user's session cookie. A cookie is a small piece of data the site stores in your browser so it can recognise you on the next request; think of it as the wristband you get at an event, which proves you already paid.

All three came up empty. He then turned to the profile picture upload feature.

The file upload bypass

He uploaded a simple test.txt file, a plain text file, and the upload succeeded. But when he tried to view the uploaded image, the site returned this error:

Text
There is an error with this image file

That message is the site's own text, shown when it cannot display the file as an image. It is a clue: the site accepted the file but could not treat it as a picture.

He looked closely at the URL of the uploaded image. A URL is the address of a page or file on the web. In the address he could see that his txt file had been renamed and converted to jpg. The site was making a copy in image format, probably so the profile page could show a picture.

From the original on medium.com

The report shows the URL structure after the upload, with the renamed and converted file.

He tried an IDOR on the endpoint /storage/528. IDOR stands for insecure direct object reference: a bug where a site uses a simple identifier, such as a number, to decide which record to show, and does not check that you are allowed to see that record. Changing the number lets you read someone else's data. The number 528 looked like a user identifier and it was sequential, meaning the next user would probably be 529, then 530, and so on. If the site did not check ownership, he could read other users' files by changing the number. It did not work.

He took a short break, then came back and paid close attention to the subdirectory conversions in the URL. A subdirectory is a folder inside the address path. He asked himself what that folder was doing there. His theory: the site stored his original text file in the /528/ directory, then converted it to jpg and saved the converted copy in conversions.

So he tried to open the uploaded text file directly from /528/, with a URL like this:

Text
https://elearning.example.nl/528/my-image.txt

Line by line, this address means:

  • https:// is the secure web protocol; the browser encrypts the connection.
  • elearning.example.nl is the site's domain name, the human-readable name of the server.
  • /528/ is the folder named after the user identifier.
  • my-image.txt is the original file he uploaded, with its original .txt extension.

His assumption was right: the text file executed. He documented the finding with a proof of concept (PoC), meaning a set of steps and evidence that shows a bug is real and reproducible, and submitted his first report.

Meanwhile he kept exploring how to exploit the upload further and found an article about hunting for bugs in file upload features.

Getting code execution

Later he learned how a file upload can be turned into RCE. RCE means running your own commands on someone else's server, as if you had a terminal on that machine. He uploaded this one-line PHP shell through the same profile picture feature:

PHP
<?php system($_GET['cmd']); ?>

Line by line:

  • <?php opens a PHP code block. The server recognises it and starts treating what follows as a program rather than text.
  • system(...) is a PHP function that runs a command on the operating system and prints the output.
  • $_GET['cmd'] reads the value of a parameter named cmd from the URL. A parameter is the part of a URL after a question mark, such as ?cmd=whoami, used to pass values to the page.
  • ?> closes the PHP block.

In plain words: whatever command you put in the cmd parameter of the URL, the server runs it and shows you the result. That is why it is called a shell: it gives you a way to give the machine instructions.

He opened the profile image in a new browser tab and changed the URL to include the RCE command. The result was remote code execution.

From the original on medium.com

The report shows the modified URL with the RCE command and the outcome.

He sent an additional report to prove the impact of this new finding.

The end of the story

He was happy and worried at the same time. The discovery seemed too easy, which raised the chance it was a duplicate, meaning someone else had already reported the same bug and the reward would go to them. To his surprise, his report was triaged, meaning the programme accepted it as valid and passed it to the people who fix it. NCSC-NL also advised him not to upload a shell to their system, which is sensible: a shell on a live government server is a real risk, and the point of a proof is to show the bug, not to keep access.

Before this, he had never completed a single PortSwigger lab on file upload or command execution, apart from basic TryHackMe rooms. PortSwigger and TryHackMe are training platforms with practice exercises; a lab is a safe, deliberately vulnerable environment for learning.

The issue was resolved within a month and he was awarded the T-shirt. It was his first critical finding on a real target and his first ever bug submission on the Dutch government programme. He thought he was lucky, but his T-shirt got lost in the shipment.

They say, enjoy the journey, not just the destination. How true that turned out to be. I learned a ton of lessons throughout this journey.

Timeline

Date What happened
18-06-2022 Reported the vulnerability
19-06-2022 Received the first response
20-06-2022 Bug confirmed and triaged
18-07-2022 Bug resolved
22-07-2022 Swag shipped by NCSC-NL and lost in the shipment

He thanked the Bug Bounty Community of Bangladesh for mentorship and the InfoSec community on Twitter for sharing research and tips.

Why it worked

The site checked or converted the uploaded file for the image preview, but it kept the original upload in a folder that the web server serves to anyone. The conversion step made a .jpg copy under conversions, yet the original file, with its original extension, stayed reachable at a predictable path built from the user identifier. Requesting the uploaded PHP file directly gave command execution. The report does not describe the server configuration or the validation code, so the exact reason the original file was kept is not stated; most likely the upload handler saved the original before making the converted copy and never removed it or blocked access to it.

What an attacker could do

A logged-in user could upload a PHP file as a profile picture and run arbitrary commands on the server by requesting the original file with a cmd parameter. The report does not say which operating system user the web server ran as, nor which other data or systems were reachable from that position. NCSC-NL advised against uploading a shell, and the issue was resolved within a month.

How to fix it

A solid fix would be to store uploaded originals outside the folder the web server serves, hand them out only through a handler that enforces the expected content type, and make sure the upload folder does not run scripts. The report does not confirm which of these measures was taken.

Things to try on a similar target

These are variations worth testing, always within the programme's scope and rules:

  • Upload a .txt file and request it directly from the numeric directory to see whether originals are kept outside the conversion path. A positive result is the original file being served.
  • Upload a .php file with a minimal shell and request it from the same directory. A positive result is command output in the response.
  • Try other executable extensions the server accepts (for example .phtml, .php5) if the application only blocks .php. A positive result is the server running the file.
  • Test whether the numeric directory is sequential and whether other users' original files can be read by changing the identifier. A positive result is another user's file being returned.
  • Check whether the conversions directory itself can serve executable files, in case the conversion step keeps the extension. A positive result is execution from that path.

Glossary

  • Bug bounty: a programme where an organisation invites people to find and report security problems in its systems, often for a reward.
  • RCE (remote code execution): running your own commands on someone else's server over the network.
  • File upload bypass: getting a file past the checks a site applies to uploads, so that a file the site should reject is accepted and stored.
  • PHP: a programming language widely used to build websites.
  • Laravel: a toolkit (framework) for building web applications in PHP.
  • Subdomain: a named site under a main domain, such as shop.example.com under example.com.
  • Subdomain enumeration: finding the subdomains that belong to a domain.
  • Reconnaissance (recon): gathering information about a target before testing it.
  • Scope: the list of systems a programme authorises you to test.
  • Out of scope: not on that list, so testing it is not authorised.
  • Informational: a report the programme judges not to be a real security problem.
  • XSS (cross-site scripting): getting a site to run JavaScript you supplied, in another user's browser.
  • HTML injection: getting your own HTML markup into a page.
  • CSRF (cross-site request forgery): making a logged-in user's browser send a request they did not intend.
  • Cookie: a small piece of data a site stores in your browser so it can recognise you on later requests.
  • Session: the logged-in state a site keeps for you, usually tied to a cookie.
  • URL: the address of a page or file on the web.
  • Endpoint: a specific address on a server that accepts requests, such as an upload or storage path.
  • IDOR (insecure direct object reference): a bug where a site uses a simple identifier to pick a record and does not check that you may see it.
  • Sequential identifier: a number that goes up by one for each new record, making it easy to guess others.
  • Subdirectory: a folder inside a URL path.
  • Proof of concept (PoC): steps and evidence that show a bug is real and reproducible.
  • Shell: a way to give commands to a machine and see the output.
  • Parameter: a value passed in a URL after a question mark, such as ?cmd=whoami.
  • Duplicate: a report of a bug someone else already reported.
  • Triaged: accepted as valid and passed to the people who fix it.
  • NCSC-NL: the Dutch government's national cyber security centre.
  • Swag: promotional items such as T-shirts given as rewards.
  • PortSwigger / TryHackMe: training platforms with safe, deliberately vulnerable exercises (labs).
  • Web root: the folder on a server whose contents the web server serves to visitors.

More from Dutch Government

View all

The newest disclosed reports for this program.

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.