Skip to content
File upload Write-up Intermediate

[VDP] Stored XSS at acm.org – Shwani

Laravel's built-in file upload validation blocked a list of PHP extensions but omitted .php7 and .php8, so an attacker could upload a file with one of those extensions. On web servers configured to treat those extensions as PHP, the uploaded file would execute, potentially leading to remote command execution.

shwani.dev

Published on shwani.dev

Hello Fellow Hackers, I am Ahmed Kameran , Security Researcher from Kurdistan, Iraq.

The author, on shwani.dev

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 framework's blocklist of disallowed PHP file extensions was incomplete, missing .php7 and .php8.

Impact

On servers configured to execute .php7 or .php8 files, an uploaded file could run as PHP, which could lead to remote command execution; servers that do not map those extensions are unaffected.

What the attacker needed

Ability to upload a file; server runs .php7/.php8 as PHP; uploaded file is reachable

The fix

The issue was fixed in Laravel v9.36.1 by adding php7 and php8 to the blocked extension list, and server operators should also ensure their web server does not execute those extensions in upload directories.

How it was found

  1. Attempt to upload a file with a .php extension and observe that Laravel's validation rejects it.
  2. Upload a file with a .php7 extension instead and observe that the upload succeeds.
  3. Request the uploaded file on a server configured to run .php7 as PHP and observe it executes.

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.

When a website lets people upload files, it should stop them uploading scripts that the server will run. Laravel, a popular web framework, kept a list of dangerous file endings to block, but forgot two newer ones (.php7 and .php8). If the server is set up to run those endings as PHP code, an uploaded file becomes a program the attacker controls.

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.

Similar reports

View all

Same bug class and techniques, clearest first.

Unrestricted file upload

The lesson behind this report.

An upload feature accepts a file that the server or other users' browsers then treat as code or as something trusted.