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

btcjson: fix infinite recursion in StringOrArray.MarshalJSON

Public commit record

What the developer wrote

Authored by Eric Grill

86/100 · Strong
btcjson: fix infinite recursion in StringOrArray.MarshalJSON

The MarshalJSON method was calling json.Marshal(h) where h is of type
StringOrArray. Since StringOrArray implements json.Marshaler, this
caused json.Marshal to call MarshalJSON again, resulting in infinite
recursion and a stack overflow.

Fix by converting to the underlying []string type before marshaling,
which breaks the interface lookup cycle.

Closes #2369

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
✓ Specific, descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context✓ Links an issue, advisory, or supporting reference✓ Names security-relevant behavior explicitly
The short version

What changed, and why it matters

This commit fixes a bug where a piece of code responsible for turning a list of text strings into JSON format accidentally called itself forever, eventually crashing the program with a stack overflow. The fix changes the code to convert the custom type to a plain list of strings before handing it to the JSON encoder, breaking the endless loop.

Recommended action

Upgrade to a btcd version containing this commit. If running an affected version, avoid serializing StringOrArray values from untrusted RPC paths until patched, and monitor for stack-overflow crashes.

Security signals we found

01

Stack overflow / infinite recursion in JSON marshaler

02

Custom json.Marshaler interface dispatch cycle

03

Denial-of-service vector via crafted or normal serialization path

Risk score

Why this scored 39/100

Our methodology →
Potential impact 8/30
Exploitability 7/25
Stealth signal 4/15
Affected reach 6/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.