Closed sherlock-admin closed 10 months ago
1 comment(s) were left on this issue during the judging contest.
auditsea commented:
If tokens are minted and swapped to other tokens to make price go down, borrower will take collateral to swap back to Ubiquity Dollar to stablize price
1 comment(s) were left on this issue during the judging contest.
auditsea commented:
If tokens are minted and swapped to other tokens to make price go down, borrower will take collateral to swap back to Ubiquity Dollar to stablize price
evmboi32
medium
Users can mint or burn too much tokens.
Summary
The functions
mintDollar
andredeemDollar
don't check how many tokens can be minted or burned to bring the price back to$1
. If the tokens can be minted they can be minted up to thepoolCeiling
which should be an unintended behavior.Vulnerability Detail
mintDollar()
there is a check that should prevent unnecessary mints.Coded POC
Add this to a new file in the
./packages/contracts/test/diamond/facets/MintDollar.t.sol
Run with
forge test --match-path ./test/diamond/facets/MintDollar.t.sol -vvv --fork-url RPC_URL
Impact
It can allow the unnecessary minting of tokens and let the price go too high or too low. This can be used to suppress the price (especially with such a low window for the TWAP oracle) and disable users from minting new tokens as the pool ceiling is reached. If the price goes above
1.01
new tokens cannot be minted as the pool ceiling has been reached. The admin would need to set the higher pool ceiling. During that time a lot of positions could get liquidatable if dependant on the TWAP oracle. The same goes for the other direction.Code Snippet
https://github.com/sherlock-audit/2023-12-ubiquity/blob/main/ubiquity-dollar/packages/contracts/src/dollar/libraries/LibUbiquityPool.sol#L346-L349
https://github.com/sherlock-audit/2023-12-ubiquity/blob/main/ubiquity-dollar/packages/contracts/src/dollar/libraries/LibUbiquityPool.sol#L418-L421
Tool used
Manual Review
Recommendation
This is kinda hard to fix as we cannot know if the minter of tokens would sell them into the pool to lower the price (he should but we cannot be sure). One fix that comes to mind would be to calculate the number of dollar tokens that should raise the price to
$1
if they are sold into a pool. This would still allow the attacker to mint the tokens and not sell them. This could be solved by letting mint such amount of tokens every few blocks (if not sold into a pool => price not stabilized).For example,
1000 dollar
tokens are needed to bring the price to$1
. Attacker mints1000 tokens
(can't mint more as it would put price below $1 if sold) and doesn't sell. AfterX blocks
such an amount should be mintable again so an honest actor can mint and stabilize the price.Similar logic should be applied when burning tokens.
Duplicate of #56