AI-generated analysisPublished automatically and not human-verified. Validated context appears in community notes below.
← Watch feed
High 72 Bitcoin

clnrest: bound XML nesting depth before parsing

Public commit record

What the developer wrote

Authored by daywalker90

85/100 · Strong
clnrest: bound XML nesting depth before parsing

roxmltree's tokenizer is recursive-descent (parse_element ->
parse_content), so Document::parse itself recurses once per element
nesting level and overflows the thread stack on deep input, before any
DOM is built. A deeply nested but otherwise valid XML request could
therefore crash clnrest's worker thread, killing the plugin.

Bound the element nesting depth iteratively on the raw request bytes,
before parsing, and reject anything deeper than 256 levels. The depth
check is itself iterative, so it cannot overflow.

Changelog-Fixed: clnrest: reject excessively-nested XML rather than risk a stack overflow.
(cherry picked from commit af6bd803c0962bdb1d5f2367eb6d3913d442cb54)
✓ Descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context✓ Explains rationale or failure mode✓ Names security-relevant behavior explicitly
The short version

What changed, and why it matters

This update fixes a crash bug in Core Lightning's REST plugin (clnrest). An attacker could send a specially crafted XML request with hundreds of nested tags. The XML parser used by the plugin processes tags by recursive function calls, so extremely deep nesting would exhaust the thread's call stack and crash the plugin worker. The fix pre-scans raw request bytes to count nesting depth without recursion and rejects anything deeper than 256 levels with a 'bad request' error, preventing the crash.

Recommended action

Apply the patch and ensure clnrest is upgraded to a release containing this fix. Consider also reviewing other XML/JSON parser recursion limits in the codebase and monitoring for similar stack-exhaustion issues.

Security signals we found

01

Stack overflow via recursive XML parsing (denial of service)

02

Pre-parse iterative depth bound to prevent parser recursion

03

New BadRequest error response for rejected XML

Risk score

Why this scored 72/100

Our methodology →
Potential impact 20/30
Exploitability 18/25
Stealth signal 8/15
Affected reach 12/15
Confidence 9/10
Evidence quality 5/5
Human-validated context

Community notes

Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.

No validated notes yet.

The AI analysis stands alone for now. Submit a note if you can add evidence or important context.