# If the Covenant signature does not pass , EXPIRED events it will still be executed.

Babylon queues an EXPIRED power-dist update at delegation creation; if covenant signatures never arrive, the expired event still fires and wrongly decrements the finality provider's TotalBondedSat.

- Payout: Audit contest
- Severity: high
- Program: Babylon
- Found by: LZ_security
- Disclosed: 2024-12-09
- Write-up quality: 7/10
- Original: https://github.com/sherlock-audit/2024-12-babylon-judging/issues/35
- Library page: https://bugbountylibrary.com/r/sherlock%3A2024-12-babylon%3AH-3
- Tags: area:web3 domain:web3 impact:dos impact:integrity kind:contest platform:sherlock sev:high tech:solidity technique:source-review vuln:accounting-error vuln:business-logic

**Target:** x/btcstaking keeper msg_server (AddBTCDelegationInclusionProof / CreateBTCDelegation / BTCUndelegate)
**Root cause:** CreateBTCDelegation schedules an EXPIRED power-dist update event at EndHeight-UnbondingTimeBlocks before covenant signatures are collected; the event is not gated on the delegation ever becoming ACTIVE, so it executes even when the ACTIVE event is never emitted.
**Steps:**
1. Call `CreateBTCDelegation` to register a delegation; an EXPIRED power-dist update is queued at `EndHeight - UnbondingTimeBlocks`.
2. Before covenant quorum signatures arrive, staker broadcasts `BTCUndelegate` on the BTC chain.
3. Covenants call `AddCovenantSigs`; status is UNBONDED/EXPIRED so it returns `ErrInvalidCovenantSig`, ACTIVE event never emitted.
4. At the scheduled height the queued EXPIRED event executes `ProcessAllPowerDistUpdateEvents`.
5. `processPowerDistUpdateEventUnbond` appends `btcDel.TotalSat` to `unbondedSatsByFpBtcPk`; `fp.RemoveBondedSats(sats)` runs `v.TotalBondedSat -= sats` although the delegation was never added to TotalBondedSat.
**How found:** Code reading of AddBTCDelegationInclusionProof vs CreateBTCDelegation: noticed EXPIRED event is queued unconditionally at creation while ACTIVE is only queued after covenant sigs, then traced AddCovenantSigs/BTCUndelegate status checks to confirm the ACTIVE path can be permanently skipped.
**Exploitation:** Staker creates a delegation then unstakes on BTC before covenants sign, blocking the ACTIVE event while the pre-queued EXPIRED event still fires; the finality provider's TotalBondedSat is decremented for sats never bonded, potentially underflowing/panicking or corrupting voting power accounting.
**Insight:** When a state machine queues future events at creation time, check whether every queued event is conditioned on the intermediate state transition actually occurring; asymmetric event scheduling (one queued eagerly, one lazily) is a reliable source of accounting drift.

