Submitted by zigtur
https://github.com/code-423n4/2024-01-opus/blob/main/src/core/abbot.cairo#L210
https://github.com/code-423n4/2024-01-opus/blob/main/src/core/sentinel.cairo#L159
https://github.com/code-423n4/2024-01-opus/blob/main/src/core/sentinel.cairo#L288
During withdraw, the convert_to_yang function of sentinel is called. This function converts an asset amount to a Yang amount.
convert_to_yang then calls assert_can_enter to ensure that current_total + enter_amt <= max_amt. This check is incorrect in the case of a withdrawal, as a subtraction should be made instead of an addition.
An attacker can deposit an asset amount such that current_total == max_amt. In such condition, withdrawing assets will be impossible because of the incorrect check.
In every Gate for which a maximum amount of asset is set in Sentinel,
an attacker can lock asset withdrawals for every users.
The following test can be added to src/tests/abbot/test_abbot.cairo to show:
Note: The PoC doesnt show the attacker adding Yang asset to make withdrawals impossible. It only shows that the withdrawals are impossible,
but the attack vector is clearly identifiable.
Unit testing
During withdrawals, a withdraw_to_yang() function could be used instead of convert_to_yang(). This new function would not call assert_can_enter.
The following patch fixes this issue by implementing a withdraw_to_yang function, which calculates the amount of Yang without reverting:
Note: Unit tests are all passing with the fix. To apply the patch, import the content in a fix.patch file, then execute git apply fix.patch.
DoS
0xsomeone (judge) decreased severity to Medium and commented:
milancermak (Opus) confirmed and commented:
