From fc1c6d9a8849048cb1309d77bffa46289c0caee4 Mon Sep 17 00:00:00 2001 From: tannevaled Date: Sat, 17 Oct 2026 23:04:59 +0200 Subject: [PATCH] security: cap total node count in convertChildren (Parse/ParseFragment) Continuing round 172's own sweep into the one other place a script routinely hands this engine a whole subtree at once: innerHTML/ outerHTML/insertAdjacentHTML, which all route through dom.ParseFragment (or dom.Parse for the top-level page), sharing one core: convertChildren. golang.org/x/net/html's own parser refuses markup nested past 512 levels, but that guard is about depth -- a WIDE document (millions of sibling elements, never nesting past a handful of levels) sails straight through it untouched. Confirmed live, two ways: `root.innerHTML = "
x
".repeat(3000000)` -- one statement, no loop -- allocated ~11.5GB of real memory in 15 seconds; a 25-iteration `root.innerHTML = root.outerHTML + root.outerHTML` loop (the same doubling shape as round 172's cloneNode case, through serialize-then-reparse instead of direct cloning) reached ~6GB. convertChildren now carries a shared node-count budget (maxParsedNodes=200000, matching js.maxCloneNodes's own value and reasoning) threaded through its own recursion and the