HomePhabricator

Require callers of AcceptBlockHeader() to perform anti-dos checks

Description

Require callers of AcceptBlockHeader() to perform anti-dos checks

Summary:
In order to prevent memory DoS, we must ensure that we don't accept a new
header into memory until we've performed anti-DoS checks, such as verifying
that the header is part of a sufficiently high work chain. This commit adds a
new argument to AcceptBlockHeader() so that we can ensure that all call-sites
which might cause a new header to be accepted into memory have to grapple with
the question of whether the header is safe to accept, or needs further
validation.

This patch also fixes two places where low-difficulty-headers could have been
processed without such validation (processing an unrequested block from the
network, and processing a compact block).

Credit to Niklas Gögge for noticing this issue, and thanks to Sjors Provoost
for test code.

This is a partial backport of core#25717
https://github.com/bitcoin/bitcoin/pull/25717/commits/ed6cddd98e32263fc116a4380af6d66da20da990

Depends on D15129

Test Plan: ninja all check-all

Reviewers: #bitcoin_abc, Fabien

Reviewed By: #bitcoin_abc, Fabien

Subscribers: Fabien

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

Details

Provenance
Suhas Daftuar <sdaftuar@gmail.com>Authored on Aug 2 2022, 20:48
PiRKCommitted on Jan 16 2024, 08:11
PiRKPushed on Jan 16 2024, 08:11
Reviewer
Restricted Project
Differential Revision
D15130: Require callers of AcceptBlockHeader() to perform anti-dos checks
Parents
rABCc271ee7fe1bf: Utilize anti-DoS headers download strategy
Branches
Unknown
Tags
Unknown