The _burn_dsc function in dsc_engine.vy performs an external call to DSC.burn_from() without checking its success status. In the liquidate function, collateral is transferred to the liquidator via _redeem_collateral before the DSC is burned. If the burn_from call fails (e.g., due to insufficient DSC balance or lack of approval), the contract state is still updated (the user's debt is reduced) and the liquidator keeps the collateral. This allows a malicious liquidator to extract protocol collateral for free.
In the liquidate function, the protocol redeems collateral and then burns the debt:
The _burn_dsc function uses an extcall without checking the return value:
In Vyper, extcall does not automatically revert if the external call fails. Because the collateral has already been transferred to the liquidator in the preceding _redeem_collateral call, a failure in burn_from results in the liquidator receiving the collateral without actually burning the required DSC.
Severity: Critical
Likelihood: High
Impact: Critical
An attacker can:
Find a user with an unhealthy position (health factor < 1).
Call liquidate() without holding or approving the required amount of DSC.
The _redeem_collateral function transfers the collateral (plus 10% bonus) to the attacker.
The _burn_dsc function attempts to burn DSC, fails silently, but the user's debt is still marked as reduced.
This results in:
Complete loss of protocol collateral.
The attacker receives free collateral and liquidation bonus.
The protocol's accounting is permanently broken.
Add this test to tests/test_dsc_engine.py:
Run: mox test -k test_liquidator_gets_free_collateral_when_burn_fails
Expected Output:
Option 1: Check the success of the external call (Recommended)
Update _burn_dsc to verify the external call succeeded:
Option 2: Reorder operations in liquidate
Call _burn_dsc before _redeem_collateral to ensure the debt is covered before releasing collateral:
Why This Works:
Checking the success status ensures that if the DSC cannot be burned, the entire transaction reverts, preventing the loss of collateral. Reordering ensures debt is covered before collateral is released.
The contest is live. Earn rewards by submitting a finding.
Submissions are being reviewed by our AI judge. Results will be available in a few minutes.
View all submissionsThe contest is complete and the rewards are being distributed.