lightningd: fail sendpay cleanly when the route does not fit the onion#9353
Open
ksedgwic wants to merge 1 commit into
Open
lightningd: fail sendpay cleanly when the route does not fit the onion#9353ksedgwic wants to merge 1 commit into
ksedgwic wants to merge 1 commit into
Conversation
create_onionpacket returns NULL when the route's per-hop payloads exceed the 1300-byte onion; send_payment passed the packet to send_onion unchecked, and serialize_onionpacket dereferenced it, killing lightningd with SIGSEGV. Observed in production on a 25-hop route submitted by a rebalancing plugin. The sendonion path already checks this call and fails the command; mirror it, and add a test. Changelog-Fixed: JSON-RPC: `sendpay` with a route too long to fit the onion packet now fails cleanly instead of crashing lightningd.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #9352
sendpaywith a route whose per-hop payloads exceed the 1300-byte onion crashes lightningd:create_onionpacket()returns NULL andsend_payment()passed it tosend_onion()unchecked, soserialize_onionpacket()dereferences NULL and the daemon dies with SIGSEGV. Observed in production on a 25-hop route submitted by a rebalancing plugin; backtrace in #9352.The fix mirrors the NULL check the
sendonionpath already has, returning "Could not create onion packet" instead of crashing.Adds
test_sendpay_onion_overflow: a 30-hop route (25 hops can still fit at minimal encodings -- the limit is payload bytes, not hop count), which reproduced the production backtrace before the fix and now gets a clean RPC error with the node still up.