HomePhabricator

addrman: change internal id counting to int64_t

Description

addrman: change internal id counting to int64_t

Summary:

With nIdCount being incremented for each addr received, an attacker could cause an overflow in the past, see https://bitcoincore.org/en/2024/07/31/disclose-addrman-int-overflow/
Even though that attack was made infeasible indirectly by addr rate-limiting (PR #22387), to be on the safe side and prevent any regressions change the nIds used internally to int64_t.
This is being done by first introducing a user-defined type for nIds in the first commit, and then updating it to int64_t (thanks sipa for help with this!).

Note that nId is only used internally, it is not part of the serialization, so peers.dat should not be affected by this.

I assume that the only reason this was not done in the past is to not draw attention to this previously undisclosed issue.

Backport of core#30568.

Depends on D18014.

Test Plan:

ninja all check-all

Reviewers: #bitcoin_abc, PiRK

Reviewed By: #bitcoin_abc, PiRK

Differential Revision: https://reviews.bitcoinabc.org/D18015

Details

Provenance
Martin Zumsande <mzumsande@gmail.com>Authored on Aug 1 2024, 16:46
FabienCommitted on Tue, Apr 29, 13:19
FabienPushed on Tue, Apr 29, 13:19
Reviewer
Restricted Project
Differential Revision
D18015: addrman: change internal id counting to int64_t
Parents
rABC017ae519e82f: addrman: Remove CAddrMan::Clear() function
Branches
Unknown
Tags
Unknown