Open Question on a hypothetical minor "slow-sliding MTP" attack introduced by BIP 54

In the process of reviewing BIP54, and while I was brooding back on the MTP usage by “forward block”, it comes to my mind, there might be slight and subtle security changes introduced by BIP54. I don’t think it is significant enough to warrant the security benefit brought by BIP54, though it did sound interesting to me to share the insight.

As I was reminding it in some ML thread, some long-term attack vectors known among bitcoin experts to disrupt a competing miner engaged in the global race of finding valid proof-of-works is to hijack the settings of its local clock. Indeed the local clock can be leveraged to set the nTime of an upcoming valid block and falsifying it allow to mislead a target miner in infringing the “block timestamp too far in the future” consensus rule. Let’s frame this attack vector as an adversarial header time hijacking.

I do wonder if the new rule introduced by BIP54 i.e “if N % 2016 is equal to 0, the timestamp of the block must be set to a value higher than or equal to the value of the timestamp of block at height N-1 minus 7200 (TN ≥ TN−1 − 7200) seconds;” is not introducing some “reverse header time hijacking”, where the header for a block at height N % 2016 == 0 is made conditional on the value of the block at height N -1.

Therefore, who is able to set the nTime of the block N -1 (be it the previous miner herself or himself or an hijack targeting said miner) might be able to affect the validity of the next block in a discretionary fashion. While at first sight, this might appear as a problem, the window margin of validity for the differential between the block N -1 and the block N have been selected in such a way that it is superior to the median-time-past interval on the assumption of an expected interval block time of 600 seconds (i.e 7200 seconds is superior to 6000 seconds of the expected interval between the first block and the last block of the median range).

This is where another observation should be made, technically there is nothing in consensus preventing the median-time-past to be adversarial pin in the past i.e all the timestamps composing a median for the last 11 blocks being set to minimally increasing value (e.g for a range with a positive diff from the chain tip at the latest 12th block: [+1, +2, +3, +4, +5, +6, +7, +8, +9, +10, +11]). If this median timestamp layout and maintain for a sliding window large enough for a 7200 diff accumulating between the latest element of the MTP range and the “real-world” time, one might adversarial slips in a +7200 diff to provoke the invalidity of the block at height N % 2016 == 0.

This attack vector, dumbly dubbed a “slow-sliding-mtp” attack is very unlikely as it assuming that the adversarial entity is able to keep coalesce under its control a hashrate superior to 51%. Moreover the impact would be still limited as it’s only concerning an advantage for 1 block among a sequence of 2016 ones. Yet in some adversarial scenario (e.g for selfish-mining attack), it could be combined to build an edge on the competition by selectively invalidating some block.

This novel attack vector sounds “novel” as under consensus rule whatever the median-time-past lateness with regards to the “real-world” time it’s not coming as a source of invalidity for a new block added to the chain tip. It does sound possible to do a “fast-forward” sliding in the future where the MTP would be pushed in the future to render invalid an upcoming block (while still under the 2 hours window), however it’s a bit of a “taste of one’s own medicine”, situation here (there is no guarantee on how the set of majority of network nodes set their local clocks here).

To conclude, I don’t believe it’s changing anything for BIP54, though, if I’m correct in my understanding of bitcoin consensus rules, my observations and reasoning, I find it was an interesting insight to share.

edited: to fix my own english on some pronoun usage

2 Likes

Two things that might help bound this, one from the code and one from the chain.

The new rule is measured from block N-1, not from the MTP, so pinning the MTP in the past doesn’t do anything by itself. What matters is how far ahead of real time T(N-1) can be. A node only accepts N-1 if it’s at most 2 hours ahead of its own clock (MAX_FUTURE_BLOCK_TIME, 7,200 s), and 7,200 s is exactly the BIP 54 margin. So for any N-1 a node has accepted, T(N-1) - 7200 is at or before that node’s current time, and a block N stamped with the honest current time passes. To make an honest N invalid, N-1 has to be further in the future than the honest miner’s own side of the network would accept, which is the clock-disagreement case you already set aside.

Core’s block template (current master) handles it too. GetMinimumTime in node/miner.cpp raises the minimum time of a retarget block to T(N-1) - MAX_TIMEWARP, where MAX_TIMEWARP is 600 s (the BIP 94 value, stricter than BIP 54’s), and getblocktemplate reports it as mintime. A miner building on a Core template wouldn’t produce the invalid block. Its timestamp would just come out later.

From the chain: across all 484 retarget boundaries through block 975,744, block N was earlier than block N-1 only 10 times. The worst was -1,127 s at 203,616 in October 2012, about a sixth of the margin. The worst since 2015 is -43 s, at 812,448 in October 2023.

The boundary list is a CSV, through 973,728: https://www.learnbitcoin.com/downloads/time-warp-seams.csv