diff --git a/typo3/sysext/frontend/Classes/Middleware/StaticRouteResolver.php b/typo3/sysext/frontend/Classes/Middleware/StaticRouteResolver.php
index bf94ff1e6ba9985746bef7fa5ef2957438139c16..2331f5ed50ca4236f83b4cec4e6f771bda633540 100644
--- a/typo3/sysext/frontend/Classes/Middleware/StaticRouteResolver.php
+++ b/typo3/sysext/frontend/Classes/Middleware/StaticRouteResolver.php
@@ -139,6 +139,9 @@ class StaticRouteResolver implements MiddlewareInterface
     {
         switch ($type) {
             case 'staticText':
+                if (!isset($routeConfig['content']) || !is_string($routeConfig['content'])) {
+                    throw new \InvalidArgumentException('A static route of type "staticText" must have a content defined.', 1704704705);
+                }
                 $content = $routeConfig['content'];
                 $contentType = 'text/plain; charset=utf-8';
                 break;