blockchain: bound decoded compressed script size #2643
All Vouch review confidence checks passed
Residual risk 0.28 = Change Risk (0.47) × (1 − Review Confidence (0.41)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.47 · 305 lines diff across 3 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Shallow Review Depth
shallow_review_depth
0.344
Diff Size
diff_size
0.342
Real PR Conversation Timeline
1 comments
"Review active on #2643"
general
weight: 0.35
allocz
Change Description
decodeCompressedScriptSizeconverts the decoded VLQ value to anintwithout a range check. An oversized script size in a corrupt utxo set or
spend journal entry becomes a negative int, passes the
len(serialized[bytesRead:]) < scriptSizecheck indecodeCompressedTxOut,and then panics when slicing:
deserializeUtxoEntryanddecodeSpentTxOutboth go throughdecodeCompressedTxOut, so a damaged database crashes the node instead ofreturning
errDeserialize. The input only comes from btcd's own database, sothis is a robustness fix, not something reachable from the network.
This caps the decoded size at
math.MaxInt32so the existing length checksreject it. I found it by fuzzing the database decoders locally.
deserializeVLQitself also wraps silently past 64 bits (Bitcoin Core'sReadVarIntthrows "size too large"). Fixing that needs an error return on afunction with about ten callers, so I left it out of this PR to keep it small.
Steps to Test
The new case decodes
30a6c1b889df8a8598fa3030. Without the change itpanics with the message above; with it,
decodeCompressedTxOutreturnserrDeserialize.Pull Request Checklist
Testing
Code Style and Documentation
📝 Please see our Contribution Guidelines for further guidance.
🤖 Generated with Claude Code