Platform: Code4rena
Start Date: 23/02/2024
Pot Size: $36,500 USDC
Total HM: 2
Participants: 39
Period: 7 days
Judge: Dravee
Id: 338
League: ETH
Rank: 3/39
Findings: 1
Award: $6,774.64
🌟 Selected for report: 0
🚀 Solo Findings: 0
🌟 Selected for report: Arabadzhiev
Also found by: ArmedGoose, blutorque
6774.638 USDC - $6,774.64
The _ibtRate
generally depends on share to underlying ratio of an IBT ERC4626 vault. It has been fetched by previewRedeem
1 IBT token from the exchange directly.
Consider a scenario, where the totalSupply of IBT tokens are currently in the PT vault and the exchange rate of share to underlying is 1:2,
Since, the PT vault offers flashloan on IBT tokens, an attacker can flashloan to withdraw totalSupply of IBT tokens from the PT and redeem them for the underlyings in IBT vault. Because the total supply of the IBT ERC4626 tokens is now zero, the ratio of share to underlying resets back to 1:1. The updateYield(address)
further called onFlashLoan
callback, which update the _ibtRate
state for every user in the PT vault.
The ibtRate has dropped, users who have not yet claimed their yield yet will lose significant amount of IBT. https://github.com/code-423n4/2024-02-spectra/blob/383202d0b84985122fe1ba53cfbbb68f18ba3986/src/libraries/PrincipalTokenUtil.sol#L104-L107
uint256 expectedNegativeYieldInAssetRay = Math.ceilDiv( ibtOfPTInRay * (_oldIBTRate - _ibtRate), RayMath.RAY_UNIT );
https://github.com/code-423n4/2024-02-spectra/blob/383202d0b84985122fe1ba53cfbbb68f18ba3986/src/tokens/PrincipalToken.sol#L902 https://github.com/code-423n4/2024-02-spectra/blob/383202d0b84985122fe1ba53cfbbb68f18ba3986/src/tokens/PrincipalToken.sol#L609
Manual review
It is recommended to add a requirement that IBT vault is initialize with supply greater than a certain threshold(say 1 gwei = 10**9) and also _getCurrentPTandIBTRates
should reverts if it is not so. This way, the current _ibtRate
will always be kept track of, even in the case that(almost) all the shares have been redeemed.
Other
#0 - c4-pre-sort
2024-03-03T10:52:35Z
gzeon-c4 marked the issue as duplicate of #240
#1 - c4-pre-sort
2024-03-03T10:52:39Z
gzeon-c4 marked the issue as sufficient quality report
#2 - c4-judge
2024-03-11T01:10:48Z
JustDravee marked the issue as unsatisfactory: Invalid
#3 - c4-judge
2024-03-15T15:32:22Z
JustDravee marked the issue as satisfactory