Nested Comment Bypass file upload
A Laravel site left its registration page open, letting the author create an administrator account. The upload filter blocked a normal PHP webshell but missed a one-liner that hid the dangerous code inside nested comments, so the file stayed on the server.
Muhammad Syahrul Haniawan Follow
Published on medium.com
Halo semua, sudah hampir 3 tahun saya tidak menulis write up tentang finding saya di dunia bug hunting dan CyberSecurity karena saya sendiri beberapa tahun kebelakang tidak terlalu aktif.
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 the upload scanner did not parse PHP comments the same way the PHP interpreter does, so it missed the executable code hidden between comment markers.
Impact
An attacker could gain administrator access and upload a PHP webshell that survived the server's checks, potentially leading to remote code execution, though the text does not show execution of the shell.
What the attacker needed
Open registration page; ability to upload files
The fix
The registration page should be closed or restricted, and the upload filter should parse PHP comments correctly or block executable files by extension.
How it was found
- Find the admin panel and try to log in.
- Notice the site uses Laravel and try known Laravel exploits, which fail.
- Add /register to the URL and find the registration form is still open.
- Register an account and get administrator access.
- Upload a normal PHP webshell, which the server deletes as suspicious.
- Upload a one-liner PHP webshell using nested comments, which survives.
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 site had a sign-up page that was meant to be closed but was still open, so anyone could make an admin account. The file upload check looked for obvious bad code, but a trick with comments made the bad code look harmless to the checker while the server still ran it.
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.