Skip to content

Commit 9720ac5

Browse files
committed
Fix CSRF vulnerability
1 parent 2b3294a commit 9720ac5

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

Controller/ResourceController.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -469,6 +469,10 @@ public function applyStateMachineTransitionAction(Request $request): Response
469469
$this->isGrantedOr403($configuration, ResourceActions::UPDATE);
470470
$resource = $this->findOr404($configuration);
471471

472+
if ($configuration->isCsrfProtectionEnabled() && !$this->isCsrfTokenValid($resource->getId(), $request->request->get('_csrf_token'))) {
473+
throw new HttpException(Response::HTTP_FORBIDDEN, 'Invalid CSRF token.');
474+
}
475+
472476
$event = $this->eventDispatcher->dispatchPreEvent(ResourceActions::UPDATE, $configuration, $resource);
473477

474478
if ($event->isStopped() && !$configuration->isHtmlRequest()) {

0 commit comments

Comments
 (0)