code-423n4 / 2021-07-sherlock-findings

0 stars 0 forks source link

User's `calcUnderlyingInStoredUSD` value is underestimated #144

Open code423n4 opened 3 years ago

code423n4 commented 3 years ago

Handle

shw

Vulnerability details

Impact

The calcUnderlyingInStoredUSD() function of SherX should return calcUnderlyingInStoredUSD(getSherXBalance()) instead of calcUnderlyingInStoredUSD(sx20.balances[msg.sender]) since there could be SherX unallocated to the user at the time of the function call. A similar function, calcUnderlying(), calculates the user's underlying tokens based on the user's current balance plus the unallocated ones.

Proof of Concept

Referenced code: SherX.sol#L141

Recommended Mitigation Steps

Change sx20.balances[msg.sender] to getSherXBalance() at line 141.

Evert0x commented 3 years ago

1 (low risk); as the function is called '..inStored..', at it is using the stored variables. I agree it is a confusing function name.

ghoul-sol commented 3 years ago

agree with sponsor, low risk