Files
binwiederhier c45e07fddf Cap the result size of the string-building template functions
The sprig replace, join and regexReplaceAll functions (and the must* regex
variants) built their result with no size limit, so a template could amplify
small inputs into a huge string: replace "a" with two 10k strings returns
100 MB in one call, and nesting reaches terabytes. The existing guards miss
this, since the 100 ms deadline is only checked between template steps and the
1 MB output limit only applies to the final write, so the single allocation
inside the function crashed the whole process with an unrecoverable
out-of-memory fatal error. Anonymous publishing is on by default, so anyone who
can publish to a topic could crash the server with one request.

Each of these functions now measures the result it is about to build and panics
past stringLengthLimit (the template executor recovers that into a render
error), the same guard repeat and indent already use. repeat, indent and
nindent were already capped; cat and indent grow additively and stay bounded.

Reported privately by Robert Flosbach of Neodyme.

Claude-Session: https://claude.ai/code/session_01DeXuhSjq5Gta5qPJgSceFe
2026-11-13 16:11:56 +00:00
..
2023-04-29 13:09:25 -04:00
2026-01-10 22:03:41 -05:00
2026-06-08 21:52:54 -04:00
2026-10-06 00:46:00 +00:00
2026-07-20 21:34:47 +02:00
2023-10-29 12:32:08 -04:00
2026-10-06 00:46:00 +00:00
2026-02-04 18:32:08 -08:00
2026-06-16 20:56:22 -04:00
2026-10-07 14:46:32 +00:00
2026-01-26 20:31:11 -05:00
2026-01-17 03:29:40 -05:00