Reject unknown TLVs in blinded payment payloads#4546
Reject unknown TLVs in blinded payment payloads#4546officialasishkumar wants to merge 1 commit intolightningdevkit:mainfrom
Conversation
|
👋 I see @wpaulino was un-assigned. |
|
Good - non-blinded paths (lines 3950-3981) don't check No issues found. The PR correctly implements rejection of unknown TLVs in blinded payment payloads at two layers:
Non-blinded paths remain unaffected. The |
lightning/src/ln/msgs.rs
Outdated
| if msg_type < 1 << 16 { | ||
| if msg_type % 2 == 1 { | ||
| has_unknown_odd_tlvs = true; | ||
| return Ok(true); |
There was a problem hiding this comment.
nit you can drop this line (similar below), returning Ok(false) universally is fine.
There was a problem hiding this comment.
Done, dropped the return Ok(true) lines in both places and now returning Ok(false) universally.
| _init_tlv_field_var!(features, (option, encoding: (BlindedHopFeatures, WithoutLength))); | ||
| _init_tlv_field_var!(payment_secret, option); | ||
| _init_tlv_field_var!(payment_context, option); | ||
| _init_tlv_field_var!(is_dummy, option); |
There was a problem hiding this comment.
Please add a new macro for this rather than breaking it out.
There was a problem hiding this comment.
Added _init_and_read_tlv_stream_with_custom_tlv_decode macro in ser_macros.rs that combines _init_tlv_field_var + decode_tlv_stream_with_custom_tlv_decode, following the same pattern as _init_and_read_tlv_stream. Both BlindedPaymentTlvs and BlindedTrampolineTlvs now use it.
|
🔔 1st Reminder Hey @wpaulino! This PR has been waiting for your review. |
|
Cool, thanks. Please rebase so the new macro is in the first commit and the last commit isn't rewriting stuff in the first commit. Also please change your commit message to not be longer than 70 chars long - word wrap also the commit message body. |
Reject unknown odd TLVs and disallowed custom TLVs when decoding blinded payment and trampoline payloads. Add a dedicated helper macro for TLV readers with custom decode callbacks and update the affected tests to cover the stricter validation paths. Signed-off-by: Asish Kumar <[email protected]>
a57f64d to
6da7ec7
Compare
Fixes #4442.
Blinded payment payload decoding still applied the normal odd/even TLV handling, which let unexpected outer custom TLVs and unknown encrypted blinded TLVs slip through on blinded paths. This tightens both layers so blinded payloads now reject non-allowlisted TLVs instead of silently ignoring them.
The test updates keep the behavioral coverage aligned with the new decoding rules: the blinded payment flow now expects the recipient to reject custom TLVs on a blinded path, and the max-path-length tests stay focused on sender-side sizing logic.
Testing: