#104364Add restrictions for sys_file_storage (better restrict file access when dealing with private storages)
Description
When working with “private” storages (outside web root), access to any file from frontend context (typolink, image view helper, etc.) is automatically handled by core using the “eID=dumpFile” functionality. So access to any file is (theoretically) always possible when the token is known (or guessed). This is misleading and confusing, people might not be aware of this!
In my opinion, an integrator or developer should be able to rely on, that when making a storage physically “private”, there is absolutely no file access possible per default. Please add a storage restriction as Oliver suggests below.
Reviews 1
Fix this issue
Start the commit message of your patch with this. Add what the patch does, and the versions it goes to in "Releases:". The changes above were merged or abandoned: read them before you start. How to create a patch
- Commit message
-
[FEATURE] Add restrictions for sys_file_storage (better restrict file access when dealing with private storages) Resolves: #104364 Releases: main
Related issues 1
History 1113
-
Georg Ringer changed removed the assignee <span data-processor="relativetime" data-value="2024-07-12T16:50:27+00:00" > 07/12/24, 16:50 </span>
-
Gerrit Code Review pushed patch set 1 for main to change 85254 status
NewUnder Review <span data-processor="relativetime" data-value="2024-07-12T17:13:49+00:00" > 07/12/24, 17:13 </span> -
Gerrit Code Review pushed patch set 2 for main to change 85254 <span data-processor="relativetime" data-value="2024-07-14T05:34:54+00:00" > 07/14/24, 05:34 </span>
-
Jan Kornblum changed Related to #81361 <span data-processor="relativetime" data-value="2024-07-16T19:21:39+00:00" > 07/16/24, 19:21 </span>
-
Jan Kornblum changed subject
Better restrict frontend file access when dealing with private storagesBetter restrict file access when dealing with private storages <span data-processor="relativetime" data-value="2024-07-25T15:01:10+00:00" > 07/25/24, 15:01 </span> -
Jan Kornblum changed target version <span data-processor="relativetime" data-value="2024-07-25T15:06:50+00:00" > 07/25/24, 15:06 </span>
-
Andreas Kießling commented <span data-processor="relativetime" data-value="2025-05-24T11:34:52+00:00" > 05/24/25, 11:34 </span>
Would be great to see some progress here.
I wanted to make use of the ModifyFileDumpEvent to restrict access to frontend uploads via EXT:form and a “private storage” so only backend users can access the files.
But as far is i can tell it is invoked too early in the middleware chain and no frontend or backend user logins are ready at that moment. For performance this might make sense, but then adding access checks seems cumbersome -
Jan Kornblum commented <span data-processor="relativetime" data-value="2025-05-24T12:51:05+00:00" > 05/24/25, 12:51 </span>
Olivers idea about introducing a new
sys_file_storage.content_restrictionwiths these three options would be really great! I suppose in this context a new middleware to handle this (instead of the eID) is required, in addition with a new event, where both backend user object as well as frontend user objects are available (if existing), to be used by developers in their own implementations. -
Jan Kornblum changed subject
Better restrict file access when dealing with private storagesAdd restrictions for sys_file_storage (better restrict file access when dealing with private storages) <span data-processor="relativetime" data-value="2026-03-02T13:49:16+00:00" > 03/02/26, 13:49 </span> -
Jan Kornblum changed description priority
Should haveMust have <span data-processor="relativetime" data-value="2026-03-02T14:00:04+00:00" > 03/02/26, 14:00 </span> -
Markus Timtner commented and changed done
0 %90 % Complexity easy <span data-processor="relativetime" data-value="2026-07-09T13:34:08+00:00" > 07/09/26, 13:34 </span>Hi there!
I just found this issue here, because i have a working fix for that.
The requirement was, that a file should ONLY be accessible for logged in Backend users, in a private file storage outside of the webroot.Since I found out that the eID link is still accessible when not logged in, I created this extension-based EventListener:
<?php declare(strict_types=1); namespace My\Sitepackage\EventListener; use Psr\Http\Message\ResponseFactoryInterface; use TYPO3\CMS\Core\Attribute\AsEventListener; use TYPO3\CMS\Core\Authentication\BackendUserAuthentication; use TYPO3\CMS\Core\Resource\Event\ModifyFileDumpEvent; use TYPO3\CMS\Core\Utility\GeneralUtility; #[AsEventListener(identifier: 'sitepackage/restrict-file-dump-to-be-users')] final readonly class RestrictFileDumpToBackendUsers { private const PROTECTED_STORAGE_UID = 2; public function __construct( private ResponseFactoryInterface $responseFactory, ) {} public function __invoke(ModifyFileDumpEvent $event): void { if ($event->getFile()->getStorage()->getUid() !== self::PROTECTED_STORAGE_UID) { return; } $beUser = $GLOBALS['BE_USER'] ?? null; if (!$beUser instanceof BackendUserAuthentication) { $beUser = GeneralUtility::makeInstance(BackendUserAuthentication::class); $beUser->start($event->getRequest()); } if (empty($beUser->user['uid'])) { $loginUrl = '/typo3/login?redirect_url=' . rawurlencode((string)$event->getRequest()->getUri()); $event->setResponse( $this->responseFactory->createResponse(302)->withHeader('Location', $loginUrl) ); } } }Works as intended – right now with redirect to login if unauthorized.
Only things left to do is:
- make the file storage configurable so it includes EVERY private file storage
- and find the right place in the core for that.Any help is appreciated, lets fix this!
-
Benni Mack changed status
Under ReviewAccepted <span data-processor="relativetime" data-value="2026-10-18T15:57:17+00:00" > 10/18/26, 15:57 </span>
Having a rate-limiter that catches the invalid requests (most probably brute force, since the HMAC token did not match) seems to be very useful.
However, for additional restrictions, there probably should be a new configuration for file storages – the current “is publicly available” is misleading and was interpreted differently in the past.
Thus, there might be a new
sys_file_storage.content_restrictionwhich could besys_filecan be accessed via the backend user interfacecomplete/fullmode should be discussed furthereID=dumpFile(FileDumpController)