Zeroday Slims9 Bulian(v9.7.2) Arbitrary File Write to RCE
The user profile image upload feature accepts a base64-encoded image string with a user-controlled file extension, allowing an authenticated attacker to write a PHP file into the images/persons directory. By embedding a valid image header in a PHP payload, the attacker can bypass MIME validation and achieve remote code execution if the server executes PHP files in that directory.
medium.com
Published on medium.com
Sebenarnya vulnerability ini saya temukan saat melakukan project pentest, dan singkatnya saya menemukan suatu CMS slims9 pada server dengan instalasi default. Karena banyaknya incident peretasan dan CVE mengenai slims ini jadi saya coba untuk memahami dari sisi backend-nya.
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
The base64 image upload path uses a user-supplied extension from the POST parameter without validating it against an allowlist, and only checks the MIME type of the decoded data, which can be spoofed with an image header.
Impact
An authenticated attacker could execute arbitrary PHP code on the server, but this depends on the server configuration allowing PHP execution in the images directory; .htaccess restrictions may block it on Apache.
What the attacker needed
Authenticated user access; server executes PHP in images/persons
How it was found
- Create a valid image file and inject PHP code into its metadata using exiftool.
- Encode the modified image to base64.
- Create a new user or edit an existing user in the admin panel.
- Intercept the user creation request and replace the image upload with a base64picstring parameter containing the encoded image and a .php extension.
- Submit the request to write the PHP file to the images/persons directory.
- Access the uploaded PHP file to execute the code.
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 lets you upload a profile picture, but it also accepts a text-encoded image where you can choose the file extension. By naming the file with a .php extension and hiding PHP code inside a valid image, the attacker can make the server run that code. This only works if the server is configured to execute PHP files in the upload folder.
What is File upload?
An upload feature accepts a file that the server or other users' browsers then treat as code or as something trusted.