Skip to content
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

Add whitelist support #1946

Closed
qdrn opened this issue Dec 6, 2021 · 10 comments · Fixed by #2409
Closed

Add whitelist support #1946

qdrn opened this issue Dec 6, 2021 · 10 comments · Fixed by #2409
Assignees
Labels
api Issues related to the API enhancement New feature or request

Comments

@qdrn
Copy link
Contributor

qdrn commented Dec 6, 2021

At some point it would be nice to add a whitelist option. You could provide a list of IP and connections from nodes corresponding to these IP would always be accepted.

@AureliaDolo
Copy link
Contributor

You mean, when you are full, you disconnect another connection to connect to the whitelisted ip ?

@qdrn
Copy link
Contributor Author

qdrn commented Feb 8, 2022

You mean, when you are full, you disconnect another connection to connect to the whitelisted ip ?

Either that, or you always keep some slots for whitelisted IPs. What's your take @damip ?

@AureliaDolo AureliaDolo self-assigned this Feb 8, 2022
@AureliaDolo AureliaDolo added the need spec This issue need more specification label Feb 8, 2022
@damip
Copy link
Member

damip commented Feb 9, 2022

Here is a possible spec:

  • have a target_out_whitelisted_connections config param
  • have a max_in_whitelisted_connections config param
  • have a massa-node/config/whitelist_peers.json optional file (gitignored) containing a list of IPs
  • in peer_db have a "whitelisted: bool" property in PeerInfo
  • try to esablish target_out_whitelisted_connections towards whitelisted targets
  • accept up to max_in_whitelisted_connections incoming connections from whitelisted IPs
  • otherwise, whitelisted peers will behave similarly to bootstrap peers

Warning: node-node communications are not encrypted nor authenticated/signed. Whitelisted connections are sensitive to man-in-the-middle attacks and should NOT be trusted more than other connections

@AureliaDolo
Copy link
Contributor

That seems like a lot, what's the real purpose of whitelisting ?

@damip
Copy link
Member

damip commented Feb 9, 2022

That seems like a lot,

I already added something very similar for bootstrap peers, in order to ensure that our bootstrap nodes are always connected all together, and also that normal users don't make more than 1 connection towards a bootstrap node.

https://github.com/massalabs/massa/blob/main/massa-node/base_config/config.toml#L99-L102
https://github.com/massalabs/massa/blob/main/massa-network/src/peer_info_database.rs#L289-L293
etc...

It took 2 or 3 hours to implement

what's the real purpose of whitelisting ?

when there are some nodes you know about, and absolutely want to be connected to in order to ensure that you cannot be connected only to attackers (that can happen statistically, especially if attackers are advertising many IP addresses and simulating many nodes).

This feature is present in all major cryptos and heavily used.

@sebastien-forestier
Copy link

Do we need to whitelist IP+nodeID to prevent man in the middle ?

@damip
Copy link
Member

damip commented Feb 10, 2022

Do we need to whitelist IP+nodeID to prevent man in the middle ?

Yes but it's not enough. To prevent MITM and replay attacks we need chained message authentication like we do for bootstrap. This adds overhead (eg. hashing every received message and verifying its signature)

@AureliaDolo AureliaDolo added enhancement New feature or request and removed future labels Feb 10, 2022
@damip damip moved this to Todo this week in Big refactoring Feb 14, 2022
@AureliaDolo
Copy link
Contributor

I was more thinking about having a whitelist in the client that would mean, I want to to connect to this ip, even if it means dropping another connection. As for the persistence, I'm not really sure about that. @z80dev do you have any intake on what would be the best for this kind of feature ?

@damip
Copy link
Member

damip commented Feb 14, 2022

I was more thinking about having a whitelist in the client that would mean, I want to to connect to this ip, even if it means dropping another connection. As for the persistence, I'm not really sure about that. @z80dev do you have any intake on what would be the best for this kind of feature ?

In the client ? Here it will only be happening in the node.

According to the spec above, it will behave just like we currently do with bootstrap node connections: it will not supersede any connections, the node will just try to always have a given number of extra whitelist connections active.

Persistence: same thing as bootstrap nodes. We could maybe go further and decide to have no file persistence for bootstrap and whitelist nodes.

@AureliaDolo
Copy link
Contributor

Wait for #2297 to be merged and then

  • add whitelisted_peers.json that is read at start up
  • add whitelist [ip] client and api command that make a peer whitelisted (create it if non existant)
  • add unwhitelist/make_standard/find_a_better_name [ip] client and api command that make a peer standard (create it if non existant)

@AureliaDolo AureliaDolo added api Issues related to the API and removed node need spec This issue need more specification labels Feb 21, 2022
bors bot added a commit that referenced this issue Mar 14, 2022
2297: Refactor to prepare whitelist peers r=AureliaDolo a=AureliaDolo

To prepare for #1946

I mostly created the PeerType variant and refactored a lot accordingly. 

In a nutshell, instead of having many not so related indexes, we have now one index and one config per peer type. I tried my best match on peer types and avoid if as much as possible (if you see something other than stuff == PeerType::default() , there may be an underlying issue), and hide complexity is smaller methods.



Co-authored-by: Aurelia <[email protected]>
@bors bors bot closed this as completed in 2fba7d1 Mar 24, 2022
@damip damip moved this from Todo this week to Done in Big refactoring Mar 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api Issues related to the API enhancement New feature or request
Projects
No open projects
Status: Done
Development

Successfully merging a pull request may close this issue.

5 participants