Unauthenticated arbitrary file upload in FormBundle → RCE / stored XSS
Description
The public form-submission file field in KunstmaanFormBundle accepts uploads from unauthenticated visitors with no file-type restriction, and stores the file under its client-supplied extension (when server-side MIME guessing fails) in a web-accessible directory (public/uploads/formsubmissions/). An anonymous visitor can upload shell.php → RCE, or .html/.svg → stored XSS.
Details
src/Kunstmaan/FormBundle/Entity/FormSubmissionFieldTypes/FileFormSubmissionField.php:
- The only constraint is
#[Assert\File(maxSize: '6000000')]- no MIME/extension allow-list. getSafeFileName()does$newExtension = $this->file->guessExtension() ?: $clientExtension.UploadedFile::guessExtension()returns null for PHP content (text/x-phpmaps to no extension in SymfonyMimeTypes), so the client extensionphpis preserved → stored asshell.php.HasGuessableExtensionValidatoronly checks that an extension exists (a.phpclient name satisfies it), not that it is safe.
KunstmaanFormExtension defaults form_submission_rootdir to {project}/public/uploads/formsubmissions (web-accessible; webdir /uploads/formsubmissions/). FormHandler::onValidPost() runs for public form submissions (no auth).
PoC
Mechanism confirmed against real Symfony UploadedFile + MimeTypes: upload=shell.php guessExtension=NULL -> STORED AS shell.php (RCE) upload=x.svg guessExtension='svg' -> STORED AS x.svg (stored XSS) upload=x.html guessExtension='html'-> STORED AS x.html (stored XSS)
Over HTTP: submit any public form that has a file field, attaching shell.php (<?php system($_GET['c']); ?>). It is written to public/uploads/formsubmissions/<uuid>/shell.php, reachable at https://TARGET/uploads/formsubmissions/<uuid>/shell.php. The <uuid> uses uniqid() (time-based, predictable) and is exposed via the field's __toString()/getUrl().
Impact
Unauthenticated RCE where public/ executes PHP (common Apache mod_php / broad nginx configs); unauthenticated stored XSS in all cases via .html/.svg served inline. Precondition: a page has a form with a file field (a normal Kunstmaan feature). Remediation: enforce a MIME/extension allow-list on the stored extension; never fall back to the client extension; store outside web root and serve with Content-Disposition: attachment + nosniff.