Skip to content

Drop address ordering enforcement in NodeAnnouncement deser #797

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

Merged
merged 2 commits into from
Feb 16, 2021

Conversation

TheBlueMatt
Copy link
Collaborator

It seems many other nodes never bothered to enforce these
requirements, so there's little reason that we should either.

cc lightning/bolts#842

Its honstly long-since time we drop this check. As noted upstream we should maybe add a check to not relay node announcements which have more than 10 addresses, but this on its own doesn't change the malicious-DDoS attack surface.

@valentinewallace
Copy link
Contributor

Agreed. I had to comment these exact lines out to get the testmpp branch to sync with other nodes without closing their connections. Will approve when CI passes...

@codecov
Copy link

codecov bot commented Feb 12, 2021

Codecov Report

Merging #797 (d873e72) into main (879e309) will decrease coverage by 0.04%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #797      +/-   ##
==========================================
- Coverage   90.84%   90.79%   -0.05%     
==========================================
  Files          44       44              
  Lines       24073    24064       -9     
==========================================
- Hits        21868    21848      -20     
- Misses       2205     2216      +11     
Impacted Files Coverage Δ
lightning/src/ln/msgs.rs 88.62% <100.00%> (-0.89%) ⬇️
lightning/src/routing/network_graph.rs 91.00% <100.00%> (+0.03%) ⬆️
lightning/src/ln/functional_tests.rs 97.15% <0.00%> (-0.02%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 879e309...d873e72. Read the comment docs.

It seems many other nodes never bothered to enforce these
requirements, so there's little reason that we should either.

cc lightning/bolts#842
@TheBlueMatt TheBlueMatt force-pushed the 2021-02-no-addr-order branch from b3676c6 to 8dd08bd Compare February 12, 2021 21:43
@TheBlueMatt
Copy link
Collaborator Author

It was further pointed out upstream that we really shouldn't be following the old-spec-recommendation to not relay if a message has any excess data, but instead allow some, so I pushed a commit to do so as well.

@TheBlueMatt TheBlueMatt force-pushed the 2021-02-no-addr-order branch from 1b33a3e to d682718 Compare February 15, 2021 20:52
@TheBlueMatt TheBlueMatt force-pushed the 2021-02-no-addr-order branch from d682718 to d873e72 Compare February 15, 2021 21:45
Copy link
Contributor

@bmancini55 bmancini55 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool thanks.

ACK 8dd08bd, have needed to comment out same lines as well!

Minor q on d873e72

Ok(msg.contents.excess_data.is_empty() && msg.contents.excess_address_data.is_empty())
Ok(msg.contents.excess_data.len() <= MAX_EXCESS_BYTES_FOR_RELAY &&
msg.contents.excess_address_data.len() <= MAX_EXCESS_BYTES_FOR_RELAY &&
msg.contents.excess_data.len() + msg.contents.excess_address_data.len() <= MAX_EXCESS_BYTES_FOR_RELAY)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason for the above two checks when the additive branch exists?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its probably not possible to hit just because of the deserialization limits, but I like to make sure code is obviously overflow-safe :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good to know, thanks!

let should_relay =
msg.excess_data.len() <= MAX_EXCESS_BYTES_FOR_RELAY &&
msg.excess_address_data.len() <= MAX_EXCESS_BYTES_FOR_RELAY &&
msg.excess_data.len() + msg.excess_address_data.len() <= MAX_EXCESS_BYTES_FOR_RELAY;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same q as above

@TheBlueMatt
Copy link
Collaborator Author

Note that the spec PR got some pushback (the ordering requirement, in the future, as we add more address types, is important to allow us to read all known versions before we hit unknown ones, though it doesnt really impact us today). I'd still prefer to just merge this and we can revisit when the spec PR gets some more responses as we need to do something and I don't really want to create a whole getter/setter API for this when other implementations dont enforce this on the read side.

Copy link
Contributor

@valentinewallace valentinewallace left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🌴

@TheBlueMatt TheBlueMatt merged commit 09f37ae into lightningdevkit:main Feb 16, 2021
TheBlueMatt added a commit to TheBlueMatt/rust-lightning that referenced this pull request May 5, 2021
In  lightningdevkit#797, we stopped enforcing that read/sent node_announcements
had their addresses sorted. While this is fine in practice, we
should still make a best-effort to sort them to comply with the
spec's forward-compatibility requirements, which we do here in the
ChannelManager.
TheBlueMatt added a commit to TheBlueMatt/rust-lightning that referenced this pull request May 5, 2021
In  lightningdevkit#797, we stopped enforcing that read/sent node_announcements
had their addresses sorted. While this is fine in practice, we
should still make a best-effort to sort them to comply with the
spec's forward-compatibility requirements, which we do here in the
ChannelManager.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants