I am not aware of any reason that we'd try to stop a ban-list timing side-channel and the prior code wouldn't be enough if we were.
Return early in IsBanned. #10564
pull gmaxwell wants to merge 1 commits into bitcoin:master from gmaxwell:banned-early-term changing 1 files +14 −18-
gmaxwell commented at 2:08 AM on June 9, 2017: contributor
-
bf376eaccc
Return early in IsBanned.
I am not aware of any reason that we'd try to stop a ban-list timing side-channel and the prior code wouldn't be enough if we were.
- fanquake added the label P2P on Jun 9, 2017
-
ryanofsky commented at 2:28 PM on June 9, 2017: member
utACK bf376eaccc892afb7ded1a56819a72dd50a7a2c1
Curious, what else would you do to previous code if you did want to stop a side channel attack?
-
gmaxwell commented at 6:15 PM on June 9, 2017: contributor
@ryanofsky to make this constant time:
Change the conditional to use bit operations instead:
fResult |= fsubNet.Match(ip) & (GetTime() < banEntry.nBanUntil)
Make the match constant time (which would probably involve similar transforms in it).
and
Replace the set with a vector with either a fixed number of entries or a size that is quantized to some interval. (E.g. multiples of 1024 entries)... so that it always loops over the same number of entries.
Though I'm not sure why we really would care to hide the size of our banlist. :)
-
ryanofsky commented at 6:21 PM on June 9, 2017: member
Though I'm not sure why we really would care to hide the size of our banlist. :)
Thanks, I was just curious how you would go about something like this. I kind of figured the set lookup would have to change in some way, but I didn't think about the short circuiting operations at all. Interesting!
-
sipa commented at 7:56 PM on June 9, 2017: member
utACK bf376eaccc892afb7ded1a56819a72dd50a7a2c1
-
TheBlueMatt commented at 8:18 PM on June 12, 2017: member
utACK bf376eaccc892afb7ded1a56819a72dd50a7a2c1
- sipa merged this on Jun 12, 2017
- sipa closed this on Jun 12, 2017
- sipa referenced this in commit 8d9f45ea6a on Jun 12, 2017
- PastaPastaPasta referenced this in commit 9c23b5308c on May 10, 2019
- PastaPastaPasta referenced this in commit f4a9faf8d0 on May 15, 2019
- PastaPastaPasta referenced this in commit eecc724362 on May 20, 2019
- PastaPastaPasta referenced this in commit e297ffd56c on May 21, 2019
- barrystyle referenced this in commit b326a64bd7 on Jan 22, 2020
- zkbot referenced this in commit f40121446d on Nov 12, 2020
- zkbot referenced this in commit 049951dc45 on Feb 11, 2021
- zkbot referenced this in commit b3a6729944 on Feb 16, 2021
- zkbot referenced this in commit e85265fbd5 on Feb 17, 2021
- zkbot referenced this in commit b4b07a1bbd on Feb 17, 2021
- random-zebra referenced this in commit 71275c1896 on Jun 9, 2021
- DrahtBot locked this on Sep 8, 2021