Alkimiya Hack Analysis

Alkimiya is a protocol that turns blockchain blockspace resources - like transaction fees - into tradable assets. It uses smart contracts to create a peer-to-peer market, helping stabilize fees, improve price discovery, and optimize resource use across blockchains.

On March 28, 2025, Alkimiya suffered an attack resulting in a loss of approximately $95.5K. The root cause was an unsafe integer conversion during the minting calculation when users deposited collateral.

Thanks for reading! Subscribe for free to receive new posts and support my work.

Overview

Analysis

Figure 1: The attack transaction

The attack started with a flash loan of 10 WBTC from Morpho (line 5). The attacker then attempted to mint exactly 2^128 + 1 shares using SilicaPools.collateralizedMint() (line 12), providing approximately 1.7 WBTC as collateral (green box).

Figure 2: The root cause of the attack

SilicaPools minted exactly 2^128 + 1 shares for the attacker using the full 256-bit shares parameter. However, due to an unsafe cast at line 837, only 1 share was recorded. This flaw was the root cause of the attack.

Referring to Figure 1, the attacker transferred 2^128 - 1 shares to another address (yellow box), leaving only 2 shares in the contract. Finally, they called SilicaPools.redeemShort() to withdraw the collateral.

Figure 3: The implementation of redeemShort()

Since sState.sharesMinted was incorrectly set to 1, while the attacker’s contract held 2 shares, SilicaPools mistakenly returned approximately 3.4 WBTC - twice the original deposit.

Conclusion

Optimizing for gas efficiency is beneficial, but only if the code remains correct. In this case, the saved gas was insignificant compared to the loss caused by the bug. Despite multiple audits, this flaw went undetected, leading to a real attack. To prevent such issues, we strongly recommend implementing rigorous security measures from the start and throughout the project’s lifecycle. Regular audits, code reviews, and vulnerability assessments should be standard practice to identify and mitigate risks before they can be exploited.

Thanks for reading! Subscribe for free to receive new posts and support my work.

Source
Disclaimer: The content above is only the author's opinion which does not represent any position of Followin, and is not intended as, and shall not be understood or construed as, investment advice from Followin.
Like
Add to Favorites
Comments