HomePhabricator

[net] Ignore unlikely timestamps in version messages

Description

[net] Ignore unlikely timestamps in version messages

Summary:
This avoids undefined behavior and prevents timejacking attacks
that use negative timestamps. The genesis block time was chosen since
it's an easy timestamp to pick as a lower bound that we safely assume
all nodes will be greater than. Any timestamp lower than that is not
expected.

This should be safe to deploy without a flag day activation since
substantial differences in nTime between nodes should only occur if
mocktime was explicitly set. This is not expected (especially on
mainnet) for any currently in-consensus BCH nodes.

This should be safe for functional tests as well, since we typically
only mock time from the genesis time to well in the future (regtest's
genesis time is also greater than mainnet genesis block time).

Depends on D6023 so that tests will pass using timestamp values +/- 2^31
Depends on D6022 so that we can assume GetTime() will not return a negative
number.

Test Plan:

ninja check check-functional

Reviewers: #bitcoin_abc, Fabien, deadalnix

Reviewed By: #bitcoin_abc, Fabien, deadalnix

Subscribers: deadalnix, Fabien

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

Details

Provenance
jasonbcoxAuthored on May 10 2020, 18:58
jasonbcoxPushed on May 12 2020, 00:16
Reviewer
Restricted Project
Differential Revision
D6024: [net] Ignore unlikely timestamps in version messages
Parents
rABC59dff0e81865: Fix potential timedata overflow
Branches
Unknown
Tags
Unknown