The vulnerability is a critical design flaw in Admidio's file upload handling mechanism, specifically within the UploadHandlerFile.php and UploadHandlerPhoto.php classes. The root cause is the improper separation of concerns between CSRF token validation and file type validation.
The process unfolds in two steps, handled by two different methods:
handle_form_data: This method validates the CSRF token. If the token is invalid, it sets an error flag on the file object ($file->error) but crucially, does not terminate the script's execution.
handle_file_upload: This method is called subsequently. It first invokes its parent method, which saves the uploaded file to a temporary directory on the server. It then checks if the $file->error flag is set. In the vulnerable version, if the flag is set, the entire logic block for file validation (including checking for allowed extensions) and processing is skipped.
An attacker can exploit this by intentionally submitting a file upload request with a malicious file (e.g., a PHP shell) and an invalid CSRF token. The handle_form_data method flags the error, and handle_file_upload proceeds to save the file but then skips the security check that would have identified the dangerous file type. The function then concludes without deleting the uploaded file, leaving the webshell on the server and accessible for remote code execution.
The patch corrects this flaw by restructuring the handle_file_upload method. It wraps the entire process in a try...catch block. It now immediately checks for the CSRF error after the file is uploaded and, if present, throws an exception. This exception is caught by the catch block, which ensures that the temporary file is always deleted, regardless of the reason for the failure. This guarantees that no file is left on the server if any part of the validation process fails.