Skip to content

Latest commit

 

History

History
42 lines (22 loc) · 2 KB

006.md

File metadata and controls

42 lines (22 loc) · 2 KB

Genuine Currant Mantaray

High

Btcstaking module allows stakingTx to be coinbase transaction which is unslashable for 100 blocks

Summary

Coinbase transactions have a special property of not being spendable for 100 bocks after creation. If now a staker uses such a transaction as a staking transaction (by adding the required outputs), that transaction will be recognized as a valid staking TX but if the owner of it double-signs, he cannot be slashed for 100 blocks due to the unspendability of the coinbase TX.

Root Cause

Looking at CreateBTCDelegation and ValidateParsedMessageAgainstTheParams which does verification on the provided TX, there are no specific checks for whether a transaction is a coinbase transaction.

Internal Pre-conditions

None

External Pre-conditions

Attacker needs to be the creator of a block (a miner) in order to build the coinbase TX like they want

Attack Path

  • Create a coinbase TX which is a valid staking TX
  • Call CreateBTCDelegation with that TX
  • It gets accepted and its value added as voting power

Impact

The README states under High impact: Inability to slash BTC stake for which the voting power was involved in double-signing.

That is exactly what happens here. Even if the staker's delegator misbehaves, the staker's stakingTx cannot be spent until 100 blocks after. Adding to the impact, if now the minimum staking time is less than 100 bitcoin blocks, this allows the malicious staker to unstake before getting slashed (if the slashing even gets retried after 100 blocks)

PoC

No response

Mitigation

Coinbase transactions can be identified since the ID of their input must be all zeros. Therefore consider checking whether a staking transaction has one input with an ID of all-zeros and reject it if so.