-
Notifications
You must be signed in to change notification settings - Fork 2
cergyk - LibUbiquityPool::mintDollar/redeemDollar reliance on arbitrarily short TWAP oracle may be inefficient for preventing depeg #20
Comments
1 comment(s) were left on this issue during the judging contest. auditsea commented:
|
1 comment(s) were left on this issue during the judging contest. auditsea commented:
|
Also invalid then and 'Sponsor Disputed' label should be added? @rndquu @pavlovcik @molecula451 |
It probably makes more sense to ask @AuditSea (not sure if this is the corresponding GitHub handle.) |
Yes, it is possible (especially in the early Dollar token stage when market activity is low) to skew the curve's TWAP value since our TWAP (in some cases) may simply take the latest block price thus TWAP can be manipulated with low effort. This is not critical (i.e. medium severity seems to be valid) since TWAP's price is used only in Not sure what's the best possible solution but the following similar issues are worth to check: |
@rndquu just to double check, the solution is to set a constant time window for the TWAP price. A question to Sherlock: should the window be set to 15, 30 min or any other value? |
In my experience with software development, anything time based is better implemented to be event based. Although unfortunately I'm not sure what events would make a great substitute in this case. What if we checked that they aren't consecutive blocks? |
I think the solution is to use the latest curve's metapool with built-in TWAP oracle and adjustable time window as described here.
You're right, the solution is to increase it to 15 or 30 minutes. |
Since there is no direct loss of funds the "high" severity doesn't seem to be correct. |
The protocol team fixed this issue in PR/commit ubiquity/ubiquity-dollar#893. |
The Lead Senior Watson signed off on the fix. |
cergyk
medium
LibUbiquityPool::mintDollar/redeemDollar reliance on arbitrarily short TWAP oracle may be inefficient for preventing depeg
Summary
The ubiquity pool used for minting/burning uAD relies on a twap oracle which can be outdated because the underlying metapool is not updated when calling the ubiquity pool. This would mean that minting/burning will be enabled based on an outdated state when it should have been reverted and inversely
Vulnerability Detail
We can see that
LibTWAPOracle::consult
computes the average price for uAD on the metapool vs 3CRV. However since it uses the duration since last update as a TWAP duration, it will always get only the value of price at the previous block it was updated at;https://github.com/sherlock-audit/2023-12-ubiquity/blob/main/ubiquity-dollar/packages/contracts/src/dollar/libraries/LibTWAPOracle.sol#L80
Let's consider the following example:
metapool initial state at block N:
reserveA: 1000
reserveB: 1000
metapool state at block N+1 (+12 seconds):
reserveA: 1500
reserveB: 500
if we have executed the update at each of these blocks, this means that if we consult the twap at block N+2,
we have:
ts.priceCumulativeLast:
[A, B]
priceCumulative:
[A+1500*12, B+500*12]
(reserve * time_elapsed);blockTimestamp - ts.pricesBlockTimestampLast = 12;
which means that when we call
get_twap_balances
the values returned are simply [1500, 500], which are the values of the previous block.Impact
A malicious user which can control two successive blocks (it is relatively feasible since the merge), can put the twap in any state for the next block:
Code Snippet
Tool used
Manual Review
Recommendation
Use a fixed duration for the TWAP:
The text was updated successfully, but these errors were encountered: