Cyber Risks · PortSwigger Research

Lab: Remote code execution via polyglot web shell upload

Summary: PortSwigger's lab presents an image upload function that verifies a file's contents are a genuine image but still allows server-side code to be uploaded and executed. The solution is a polyglot PHP/JPG file with the PHP payload placed in the image's Comment metadata via ExifTool, saved with a .php extension and retrieved through the GET /files/avatars/polyglot.php request to exfiltrate the contents of /home/carlos/secret.

What's compelling: The control here checked that the file was a real image and still let a working PHP shell through, because the payload sat in metadata the check never inspected - a reminder that content-type validation alone does not stop executable uploads.

Read the original at PortSwigger Research ↗

Topics
Vulnerabilities & Patching
Related