Description
Symfony version(s) affected
=5.1
Description
5.1 introduced the X-Debug-Exception
header when in debug mode.
Because this header is not truncated and because web servers don't allow infinite header size (single-header / all headers limitations), the web server might return a native 5xx error page instead of proper symfony error page.
See #36003 (comment) first issue report (this is the initial PR, not an issue)
How to reproduce
Just throw a big exception, with debug mode enabled :
throw new \Exception(str_repeat('0', 32000));
In my case, it's a DB query with some JOIN
and a lot of fields that fail for instance when a migration has not been executed yet.
Possible Solution
Truncate the header, for instance to 2kB to have some space left for other headers, because a web server might have a limitation for the size of all the headers, and not only per-header-line size limit.
Additional Context
Typical nginx log (502) :
upstream sent too big header while reading response header from upstream