Hack Case Studies
Compound Upgrade Bug
Compound comptroller contract had a one letter bug that allowed users to receive massive amounts of COMP rewards
This case study explains how the Compound upgrade bug worked and which assertion pattern could have constrained the invalid state transition.
The bug was caused by using > instead of >= in the check. This meant that when supplyIndex equaled compInitialIndex (1e36), the if block was skipped, leaving supplierIndex at 0. The large difference between supplierIndex (0) and supplyIndex (1e36) caused the protocol to pay out massive unintended rewards.
The previous version worked because supplyIndex started at 0 instead of 1e36, though >= would have been more correct.

