The list of known node addresses (setKnown) is never pruned, making it collect information about all nodes ever seen since startup.
This allows for a slow DoS on IPv6 connected nodes.
The list of known node addresses (setKnown) is never pruned, making it collect information about all nodes ever seen since startup.
This allows for a slow DoS on IPv6 connected nodes.
CNetAddr
requires 20bytes (16bytes ip, some vector overhead), connecting to 50'000 nodes will fill up your memory +~1MB.
I agree that a cap would be nice, but i don’t see how it would be possible to DoS.
Reconnecting and sending again a version message would not increase the uses memory because the offsets are stored in a std::set
with the ip address as set key.
@sipa: thanks for the info. So if you can control 50'000 ips (IPv6) you can increase the mem consumption of a attacked node about ~2.4MB by closing and reconnecting from a different ip to not exceed the -maxconnections. But i would guess there are better options to attack a bitcoin node if you can control a big amount of ips.
But sure, a cap would be nice.
Hmmm… just analyzed the code and i can’t see a place where AddTimeData()
keeps a nOffsetSample
or a CNetAddr
in memory. Looks like the only thing hold im mem is the nTimeOffset
(single int64_t, not increasing).
But found a more effective attack: connect, misbehave, get added on the banlist (https://github.com/bitcoin/bitcoin/blob/master/src/main.cpp#L3838). A banMap entry will reserve at least 302 bytes (CSubNet and CBanEntry).
Maybe someone could point out a possible AddTimeData()
? Meanwhile i try to implement a upper bound for the banlist.
I think we should just return early from AddTimeData()
when we already have enough time samples (because we do nothing in such cases anyway - see the comment there). Something like
0if (setKnown.size() == 200)
1 return;
immediately after definition of static setKnown
.
The current debugging output of “Added time data, samples…” is misleading anyway because the newly added time data are not used to update the time offset.