[v0.20.x-branch] Backport #10249: enforce strict TLV length checks #11134
All Vouch review confidence checks passed
Residual risk 0.16 = Change Risk (0.40) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.40 · 309 lines diff across 3 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 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
Diff Size
diff_size
0.343
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #11134"
general
weight: 0.35
gijswijs
Backport of #10249 (
multi: enforce strict TLV length checks) tov0.20.x-branch.Why
v0.20.xis missing the strict length validation in the fixed-size TLVdecoders. The
tlvstream delegates that check to each decoder:feeDecoderignores thelargument, so an inbound-fee record that declares alength larger than the bytes actually present is silently accepted. It only
consumes 8 bytes, the stream then hits a clean EOF, and decoding succeeds with
ExtraOpaqueDataretaining the bogus length. Re-encoding rebuilds the recordcanonically, so the message does not round-trip.
This is latent on
v0.20.xtoday: the oldChannelUpdate1.Encodewrote themerged extra data back into the message, so the round-trip fuzz assertion
compared the encoder's output against itself and never observed the mismatch.
It stops being latent under #11130, which backports #11090. That PR makes the
extra-data canonicalization non-mutating, which removes the rewrite that was
hiding the discrepancy, and five fuzz seeds start failing
unit-raceandunit-cover:With this fix the malformed record is rejected at decode, so the harness skips
those inputs, which is exactly how
masterbehaves.Notes
The upstream release-notes commit targets
release-notes-0.21.0.mdandconflicts here, so it is replaced with an equivalent entry in
release-notes-0.20.4.md.tlv/primitive.gois included for fidelity with upstream, buttlvis aseparate module and
go.modpinslnd/tlv v1.3.2with noreplace, so thathunk has no effect on the build until
tlvis released and bumped. Theeffective changes here are in
lnwire/androuting/route/.Testing
Verified with the
lightninglabs/lnd-fuzzcorpus rsync'd in, both standaloneand with the #11130 stack rebased on top: builds clean, and
-racepasses forlnwire,netann,peer,routing/route, plus thequeueandtlvsubmodules.