From a2bbc8311d6f259ae696bdd2f277d31e1e38f1bb Mon Sep 17 00:00:00 2001 From: Matthieu Date: Sun, 21 Jun 2026 01:03:24 +0200 Subject: [PATCH] fix(client-portal) : forbid SMB share-link document creation for client users MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Security hardening on the document POST that phase 1 widened to ROLE_CLIENT: a client user could reach the share-link path (arbitrary SMB file reference) instead of an upload. Now the sharePath branch is admin-only — client users must upload. attachTarget already scopes documents to the client's own ticket. 178 tests green. --- .../ApiPlatform/State/TaskDocumentProcessor.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/Module/ProjectManagement/Infrastructure/ApiPlatform/State/TaskDocumentProcessor.php b/src/Module/ProjectManagement/Infrastructure/ApiPlatform/State/TaskDocumentProcessor.php index 73a4420..ed2b949 100644 --- a/src/Module/ProjectManagement/Infrastructure/ApiPlatform/State/TaskDocumentProcessor.php +++ b/src/Module/ProjectManagement/Infrastructure/ApiPlatform/State/TaskDocumentProcessor.php @@ -94,6 +94,14 @@ final readonly class TaskDocumentProcessor implements ProcessorInterface // Deux modes de création : upload d'un fichier (multipart) ou lien vers un fichier du partage SMB (JSON). $sharePath = $this->extractSharePath($request); + // Sécurité : un utilisateur client ne peut PAS créer de lien vers le + // partage SMB interne (référence de fichier arbitraire hors de son + // périmètre) — seul le téléversement lui est permis. Le lien partage + // reste réservé aux administrateurs. + if (null !== $sharePath && !$this->security->isGranted('ROLE_ADMIN')) { + throw new AccessDeniedHttpException('Les utilisateurs clients ne peuvent pas créer de lien vers le partage ; un téléversement est requis.'); + } + $document = null !== $sharePath ? $this->createShareLink($request, $sharePath) : $this->createUpload($request);