#111610Run Extbase #[Authorize] and #[RateLimit] checks before file upload handling
Description
Affected: 14.2 and later (introduction of #[Authorize] and #[RateLimit]).
Note
This is a security hardening, not a security issue. Uploaded files still pass all configured validation (deny pattern, MIME type and file extension checks) before they are stored. The suggested change makes the order of checks match the documented behaviour of #[Authorize] and #[RateLimit].
Problem
ActionController::callActionMethod() processes file uploads and file deletions of #[FileUpload] properties before the checks of #[Authorize] and #[RateLimit] are evaluated:
$validationResult = $this->arguments->validate();
if (!$validationResult->hasErrors()) {
foreach ($this->arguments as $argument) {
$this->fileHandlingService->applyDeletionsToArgument($argument);
$this->fileHandlingService->mapUploadedFilesToArgument($argument);
$preparedArguments[] = $argument->getValue();
}
// authorization and rate limiting only happen here
$this->performAuthorizationChecks($request, $preparedArguments);
$this->handleRateLimit($request);
...
As a result:
- A request that is denied by
#[Authorize](HTTP 403) has already stored uploaded files in the configured upload folder and applied requested file deletions. - A request that exceeds the
#[RateLimit](HTTP 429) has already stored its uploaded files. The rate limit does not limit the number of stored uploads.
This contradicts the documented behaviour of the authorization feature (Feature-107826): a failed check “stops the Extbase dispatch process”. The action itself is not executed, but its file side effects are.
Steps to reproduce
- Create an Extbase action with a domain object argument that has a
#[FileUpload]property, and protect the action with#[Authorize(requireLogin: true)]. - Submit the form with a file without being logged in.
- The response is HTTP 403, but the file exists in the upload folder and in
sys_file(orphaned, without a file reference).
The same applies to an action with #[RateLimit]: every request above the limit answers with HTTP 429, but still stores the file.
Expected behaviour
Authorization and rate limiting are evaluated before any file operation. Denied or rate-limited requests do not change files in storage.
Proposed solution
Authorization callbacks currently receive the arguments with file changes already applied (new file references attached, deleted ones detached). Any fix therefore has to decide what callbacks see. Two options:
Option 1 (preferred): evaluate the checks before any file handling
In callActionMethod(), collect the argument values, run performAuthorizationChecks() and handleRateLimit(), and only afterwards apply applyDeletionsToArgument() / mapUploadedFilesToArgument(). The action and BeforeActionCallEvent still receive the arguments with all file changes applied.
Authorization callbacks then receive the domain objects in the state before the file changes of the current request. This is a behaviour change, but an intended one: authorization decides whether a user may perform an action on an object, and that decision should not depend on the files submitted with the request. Rules about the submitted files themselves (number, type, size) belong in validation, which already runs before. The change is simple, leaves no side effects for denied requests, and matches the documented behaviour that a failed check “stops the Extbase dispatch process”. It should be documented in an Important-*.rst changelog entry.
Option 2: split file handling into two phases
Keep the in-memory changes (attaching uploaded file references, detaching deleted ones) before the checks, so callbacks see the same state as today. Run the irreversible operations only after the checks passed: defer the physical deletion of files, and remove files stored for a request that is denied (403) or rate limited (429) again. This keeps callback behaviour unchanged, but needs considerably more code and a cleanup path for stored uploads, because a file reference requires a stored file.
#[RateLimit] does not receive arguments, so it can be evaluated before any file handling with either option.
Reviews 2
History 14
-
Gerrit Code Review pushed patch set 1 for main to change 98197 status
NewUnder Review 11/29/26, 17:56 -
Gerrit Code Review pushed patch set 2 for main to change 98197 11/30/26, 16:05
-
Gerrit Code Review pushed patch set 1 for 14.3 to change 98302 12/03/26, 14:25
-
Torben Hansen commented and changed status
Under ReviewResolved done0 %100 % 12/04/26, 21:00
Applied in changeset commit:82e3add3dc1cd52f2a13810ce05954a3dc229188.