Exceptions displayed in non-debug configurations in Symfony
Description
In Symfony before versions 5.0.5 and 4.4.5, some properties of the Exception were not properly escaped when the ErrorHandler rendered it stacktrace. In addition, the stacktrace were displayed even in a non-debug configuration. The ErrorHandler now escape alls properties of the exception, and the stacktrace is only display in debug configuration. This issue is patched in symfony/http-foundation versions 4.4.5 and 5.0.5
Affected packages
Versions sourced from the GitHub Security Advisory.
| Package | Affected versions | Patched versions |
|---|---|---|
symfony/error-handlerPackagist | >= 4.4.0, < 4.4.4 | 4.4.4 |
symfony/error-handlerPackagist | >= 5.0.0, < 5.0.4 | 5.0.4 |
symfony/symfonyPackagist | >= 4.4.0, < 4.4.4 | 4.4.4 |
symfony/symfonyPackagist | >= 5.0.0, < 5.0.4 | 5.0.4 |
Affected products
1- Range: >= 4.0.0, < 4.4.5
Patches
2629d21b800a1Escape variable in Exception Template
1 file changed · +3 −3
src/Symfony/Component/ErrorHandler/Resources/views/traces_text.html.php+3 −3 modified@@ -20,15 +20,15 @@ <?php if ($exception['trace']) { ?> <pre class="stacktrace"> <?php - echo $exception['class'].":\n"; + echo $this->escape($exception['class']).":\n"; if ($exception['message']) { - echo $exception['message']."\n"; + echo $this->escape($exception['message'])."\n"; } foreach ($exception['trace'] as $trace) { echo "\n "; if ($trace['function']) { - echo 'at '.$trace['class'].$trace['type'].$trace['function'].'('.(isset($trace['args']) ? $this->formatArgsAsText($trace['args']) : '').')'; + echo $this->escape('at '.$trace['class'].$trace['type'].$trace['function']).'('.(isset($trace['args']) ? $this->formatArgsAsText($trace['args']) : '').')'; } if ($trace['file'] && $trace['line']) { echo($trace['function'] ? "\n (" : 'at ').strtr(strip_tags($this->formatFile($trace['file'], $trace['line'])), [' at line '.$trace['line'] => '']).':'.$trace['line'].($trace['function'] ? ')' : '');
cf80224589acAdded debug argument to decide if debug page should be shown or not
2 files changed · +5 −3
src/Symfony/Component/ErrorHandler/Debug.php+1 −1 modified@@ -31,6 +31,6 @@ public static function enable(): ErrorHandler DebugClassLoader::enable(); - return ErrorHandler::register(new ErrorHandler(new BufferingLogger())); + return ErrorHandler::register(new ErrorHandler(new BufferingLogger(), true)); } }
src/Symfony/Component/ErrorHandler/ErrorHandler.php+4 −2 modified@@ -92,6 +92,7 @@ class ErrorHandler private $screamedErrors = 0x55; // E_ERROR + E_CORE_ERROR + E_COMPILE_ERROR + E_PARSE private $loggedErrors = 0; private $traceReflector; + private $debug; private $isRecursive = 0; private $isRoot = false; @@ -180,14 +181,15 @@ public static function call(callable $function, ...$arguments) } } - public function __construct(BufferingLogger $bootstrappingLogger = null) + public function __construct(BufferingLogger $bootstrappingLogger = null, bool $debug = false) { if ($bootstrappingLogger) { $this->bootstrappingLogger = $bootstrappingLogger; $this->setDefaultLogger($bootstrappingLogger); } $this->traceReflector = new \ReflectionProperty('Exception', 'trace'); $this->traceReflector->setAccessible(true); + $this->debug = $debug; } /** @@ -697,7 +699,7 @@ public static function handleFatalError(array $error = null): void */ private function renderException(\Throwable $exception): void { - $renderer = \in_array(\PHP_SAPI, ['cli', 'phpdbg'], true) ? new CliErrorRenderer() : new HtmlErrorRenderer(0 !== $this->scopedErrors); + $renderer = \in_array(\PHP_SAPI, ['cli', 'phpdbg'], true) ? new CliErrorRenderer() : new HtmlErrorRenderer($this->debug); $exception = $renderer->render($exception);
Vulnerability mechanics
Generated by null/stub on May 9, 2026. Inputs: CWE entries + fix-commit diffs from this CVE's patches. Citations validated against bundle.
References
8- github.com/advisories/GHSA-m884-279h-32v2ghsaADVISORY
- nvd.nist.gov/vuln/detail/CVE-2020-5274ghsaADVISORY
- github.com/FriendsOfPHP/security-advisories/blob/master/symfony/error-handler/CVE-2020-5274.yamlghsaWEB
- github.com/FriendsOfPHP/security-advisories/blob/master/symfony/symfony/CVE-2020-5274.yamlghsaWEB
- github.com/symfony/symfony/commit/629d21b800a15dc649fb0ae9ed7cd9211e7e45dbghsax_refsource_MISCWEB
- github.com/symfony/symfony/commit/cf80224589ac05402d4f72f5ddf80900ec94d5adghsax_refsource_MISCWEB
- github.com/symfony/symfony/security/advisories/GHSA-m884-279h-32v2ghsax_refsource_CONFIRMWEB
- symfony.com/cve-2020-5274ghsaWEB
News mentions
0No linked articles in our index yet.