This repository has been archived by the owner on Jan 7, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
0xDjango - First depositor can break minting of shares #140
Labels
Low/Info
A valid Low/Informational severity issue
Non-Reward
This issue will not receive a payout
Sponsor Confirmed
The sponsor acknowledged this issue is valid
Comments
github-actions
bot
added
High
A valid High severity issue
Has Duplicates
A valid issue with 1+ other issues describing the same vulnerability
labels
Jul 10, 2023
This was referenced Jul 10, 2023
0x3e84fa45 - Deposits in InsuranceFund can be stolen by frontrunning initial shares calculation
#185
Closed
0xshinobii
added
the
Sponsor Confirmed
The sponsor acknowledged this issue is valid
label
Jul 18, 2023
This issue was already mentioned in code arena audit. As done in v1, this will be fixed by adding the initial amount to the insurance fund from Hubble at the time of deployment. |
@ctf-sec this issue was already reported in the previous contest. Shouldn't this be low? |
Considering this a low issue since it was already found in the previous audit. |
sherlock-admin
added
Non-Reward
This issue will not receive a payout
and removed
Reward
A payout will be made for this issue
labels
Aug 4, 2023
sherlock-admin2
removed
High
A valid High severity issue
Has Duplicates
A valid issue with 1+ other issues describing the same vulnerability
labels
Aug 6, 2023
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
Low/Info
A valid Low/Informational severity issue
Non-Reward
This issue will not receive a payout
Sponsor Confirmed
The sponsor acknowledged this issue is valid
0xDjango
high
First depositor can break minting of shares
Summary
The common "first depositor" vulnerability is found in
InsuranceFund.depositFor()
. The first account to deposit into the insurance fund can steal value from subsequent depositors by:1 wei
sharespoolValue
0 shares
due to precision lossVulnerability Detail
The depositor's shares are calculated via:
Upon first deposit, the
_pool
value will be 0. The attacker will transact with anamount
=1 wei
to mint 1 wei of shares. Then the attacker will transfer some value of asset directly to the contract. For this example, the attacker transfers 10,000 USDC.Next, a subsequent depositor attempts to mint shares with 5,000 VUSD.
shares = 5000 ether * 1 wei / 10,000 ether = 0
due to precision loss.The attacker can now withdraw the second depositor's assets.
Impact
Code Snippet
https://github.com/sherlock-audit/2023-04-hubble-exchange/blob/main/hubble-protocol/contracts/InsuranceFund.sol#L104-L108
Tool used
Manual Review
Recommendation
Mint a certain number of shares and transfer them to address(0) within the
initialize()
function.The text was updated successfully, but these errors were encountered: