Issue Bug Closed

#102567Send 400 Bad Request in case of Extbase POST request with missing argument

Daniel Siepmann 11/30/23, 11:26 updated 11/13/26, 17:50

Description

Given the following setup:

  1. An Extbase action with a required argument
  2. That Extbase action only will be called via POST (this can not be enforced yet, see: https://decisions.typo3.org/t/align-extbase-more-with-symfony/)
  3. The action is called without that argument

Right now Extbase would throw an exception: https://github.com/TYPO3/typo3/blob/v12.4.8/typo3/sysext/extbase/Classes/Mvc/Controller/ActionController.php#L818

Proposal: Extbase should deliver a “400 Bad Request”.

This can happen if stupid bots crawl a site. This might spam the logs with the Extbase exception.

This can be implemented without https://decisions.typo3.org/t/align-extbase-more-with-symfony/. That than can come on top in order to enforce Extbase to only call the action if the current request is a POST request. That again prevents flooding the logs by bad bots that might call the action via get request.

Reviews 0

No change resolves or names this issue in its commit message, and no comment links one.

History 5

  1. Simon Schaufelberger commented <span data-processor="relativetime" data-value="2023-11-30T12:34:59+00:00" > 11/30/23, 12:34 </span>

    This is my current solution as a workaround in a controller:

        public function processRequest(RequestInterface $request): ResponseInterface
        {
            if ($request->getMethod() === 'GET' && $request->getControllerActionName() === 'delete') {
                $content = GeneralUtility::makeInstance(ErrorPageController::class)->errorAction(
                    'Method not allowed',
                    'GET method not allowed for this action!',
                    AbstractMessage::ERROR,
                    0,
                    405
                );
                throw new PropagateResponseException(new HtmlResponse($content, 405));
            }
    
            return parent::processRequest($request);
        }

    The correct http status code is 405 in this case.

  2. Oliver Hader commented <span data-processor="relativetime" data-value="2024-08-28T13:06:01+00:00" > 08/28/24, 13:06 </span>

    Simon Schaufelberger wrote in #note-1:
    > This is my current solution as a workaround in a controller:
    >
    > […]
    >
    > The correct http status code is 405 in this case.

    Side-note: HTTP status 405 must send an additional Allow header in the response.

  3. Benni Mack commented and changed status New Closed <span data-processor="relativetime" data-value="2026-11-13T17:50:19+00:00" > 11/13/26, 17:50 </span>

    Since TYPO3 v13.3 (#104321), mvc.showPageNotFoundIfRequiredArgumentIsMissingException = 1 turns a missing required argument into a 404, and ActionController::handleArgumentMappingExceptions() can be overridden for a different response such as 400. Restricting actions to HTTP methods (405) is tracked in #107002.