Third thing you need to read today
Yesterday was a crazy day. The @Balancer hack shook the entire community. Many analyses emerged, but unfortunately, some missed the point of what's most important at a time like this and why such analyses are being done. User safety and helping projects should ALWAYS be our first priority. As usual, @SEAL led the way, but we know that many other good people also abandoned their current tasks to analyze fixes and consult on strategies with affected teams. Analyzing the root cause of a hack shouldn't be about gaining as many followers as possible because you were the first to write about it. The point is to share information responsibly. Firstly, to limit losses, and secondly, to prevent these kinds of vectors in the future. Was it a re-entrancy ? No, there was no a callback and no user data specified in the swap data. Was it an access control issue? No, the attacker was executing operations on his behalf. The root cause was that ... 1️⃣ The attacker used a pool with 3 tokens: A, B and the POOL token itself. 2️⃣ Swapped a lot of POOL token for a lot of A and B: transfer in POOL and transfer out A and B. The balances of A and B are *small*, while balance of POOL is *huge* (see the balances picture). 3️⃣ Make swaps back from A and B to POOL. All swaps are "exact amount out" swaps and the "amount in" is calculated. However, the swaps from A/B to POOL drop the POOL token from balances when calculating amount in. 🚨 The effect: to get a big amount of POOL (to return the pool back to the initial state) the attacker needs to transfer in a small amount of A/B, because the amount is calculated based on small amounts of A and B only (POOL is excluded from the calculation). As you can see, it was not a trivial attack, and removing this vulnerability is not easy either. The straightforward recommendation would be not to exclude POOL token from the invariant, but I bet there was business logic reason for that. Final thoughts: ➡️ Multi token pools are tricky. Especially those that have its own token in it. ➡️ Any changes to invariants calculations are super important to check carefully. Inflating and resulting balances (point 1): Attack (point 3):
1,03 B
3
Bu sayfadaki içerik üçüncü taraflarca sağlanmaktadır. Aksi belirtilmediği sürece, atıfta bulunulan makaleler OKX TR tarafından kaleme alınmamıştır ve OKX TR, bu materyaller üzerinde herhangi bir telif hakkı talebinde bulunmaz. İçerik, yalnızca bilgilendirme amaçlı sağlanmıştır ve OKX TR’nin görüşlerini yansıtmaz. Ayrıca, sunulan içerikler herhangi bir konuya ilişkin onay niteliği taşımaz ve yatırım tavsiyesi veya herhangi bir dijital varlığın alınıp satılmasına yönelik davet olarak değerlendirilmemelidir. Özetler ya da diğer bilgileri sağlamak için üretken yapay zekânın kullanıldığı durumlarda, bu tür yapay zekâ tarafından oluşturulan içerik yanlış veya tutarsız olabilir. Daha fazla ayrıntı ve bilgi için lütfen bağlantıda sunulan makaleyi okuyun. OKX TR, üçüncü taraf sitelerde barındırılan içeriklerden sorumlu değildir. Sabit coinler ve NFT’ler dâhil olmak üzere dijital varlıkları tutmak, yüksek derecede risk içerir ve bu tür varlık fiyatlarında büyük ölçüde dalgalanma yaşanabilir. Dijital varlıkları alıp satmanın veya tutmanın sizin için uygun olup olmadığını finansal durumunuz ışığında dikkatlice değerlendirmelisiniz.