Description
Bybit suffered from a security breach in Safe’s hosting infrastructure losing 1.4bn USD. The attackers, the lazarus group, gained access to the server and was able to modify the served Safe Wallet frontend. More on the attack: https://x.com/safe/status/1894768522720350673 The malicious code was specifically targeting Bybit’s next transaction. As of today, it is commonly agreed that the signers of the transaction were shown a fake UI, seeming to be the intended transaction to sign, but in fact it was a malicious transaction. Unfortunately, it is often very hard to verify the correctness of the message that is signed in software or hardware wallets. Attack steps:- Attackers gained access to the hosting server by compromising a developer’s machine.
- A malicious frontend was uploaded to the server, which targeted Bybit’s next transaction.
- The frontend would show the intended transaction but in fact the message to be signed was malicious
- The malicious message was a delegate call which would change the implementation of the Safe’s proxycontract
How assertions could have prevented this
In Safe’s proxy implementation, the first storage slot is the implementation address.Preventing attacks through assertions
It might be fair to assume that most users of safes would never actually want to change the implementation address of their safe, but they have no way to express their preferences. Assertions give users the ability to express additional invariants on the state of the contract. A change of the implementation address could be prevented by analyzing the state changes within a transaction. PhEvm precompiles used:- forkPreState allowing to fork the state of the contract before a transaction
- load reading specific storage slots
- getStateChangesAddress getting all state changes within a transaction for a given slot