Skip to content

Commit 0c85dc3

Browse files
committed
p2p: Don't use timestamps from inbound peers
This makes it harder for others to tamper with our adjusted time.
1 parent a574f4a commit 0c85dc3

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/net_processing.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2683,7 +2683,11 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
26832683

26842684
int64_t nTimeOffset = nTime - GetTime();
26852685
pfrom.nTimeOffset = nTimeOffset;
2686-
AddTimeData(pfrom.addr, nTimeOffset);
2686+
if (!pfrom.IsInboundConn()) {
2687+
// Don't use timedata samples from inbound peers to make it
2688+
// harder for others to tamper with our adjusted time.
2689+
AddTimeData(pfrom.addr, nTimeOffset);
2690+
}
26872691

26882692
// If the peer is old enough to have the old alert system, send it the final alert.
26892693
if (greatest_common_version <= 70012) {

0 commit comments

Comments
 (0)