-
Notifications
You must be signed in to change notification settings - Fork 407
Correctly handle BADONION onion errors #1703
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Correctly handle BADONION onion errors #1703
Conversation
Codecov Report
@@ Coverage Diff @@
## main #1703 +/- ##
==========================================
+ Coverage 90.92% 91.67% +0.75%
==========================================
Files 86 86
Lines 46417 52678 +6261
Branches 46417 52678 +6261
==========================================
+ Hits 42204 48294 +6090
- Misses 4213 4384 +171
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think the tests will be too tricky after checking this out. I'll begin work on them.
Should have something up today. Will open against your branch. |
baff002
to
32df0cc
Compare
Thanks @dunxen! Added your test. |
32df0cc
to
befbfe9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
onion_utils change makes sense and LGTM. Obviously just need more eyes on the test :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM after squash.
Currently we entirely ignore the BADONION bit when deciding how to handle HTLC failures. This opens us up to an attack where a malicious node always fails HTLCs backwards via `update_fail_malformed_htlc` with an error code of `BADONION|NODE|PERM|X`. In this case, we may decide to interpret this as a permanent node failure for the node encrypting the onion, i.e. the counterparty of the node who sent the `update_fail_malformed_htlc` message and ultimately failed the HTLC. Thus, any node we route through could cause us to fully remove its counterparty from our network graph. Luckily we do not do any persistent tracking of removed nodes, and thus will re-add the removed node once it is re-announced or on restart, however we are likely to add such persistent tracking (at least in-memory) in the future.
befbfe9
to
3b1d0e5
Compare
Some tweaks by Matt Corallo <[email protected]>
3b1d0e5
to
e6a3c23
Compare
Squashed without further changes. |
Currently we entirely ignore the BADONION bit when deciding how to handle HTLC failures. This opens us up to an attack where a malicious node always fails HTLCs backwards via
update_fail_malformed_htlc
with an error code ofBADONION|NODE|PERM|X
. In this case, we may decide to interpret this as a permanent node failure for the node encrypting the onion, i.e. the counterparty of the node who sent theupdate_fail_malformed_htlc
message and ultimately failed the HTLC.Thus, any node we route through could cause us to fully remove its counterparty from our network graph. Luckily we do not do any persistent tracking of removed nodes, and thus will re-add the removed node once it is re-announced or on restart, however we are likely to add such persistent tracking (at least in-memory) in the future.
This probably needs test updates.