There is a risk of the IBT vault manipulating the ibtRate in _getCurrentPTandIBTRates. By temporarily draining assets before this view function is called, the rate can be lowered. This would allow attackers to deposit into the Principal Token with less assets than they should be able to based on true yield rates.
Arbitrary previewRedeem/redeem Logic in IBT The core issue here is that Spectra trusts the IBT vault's previewRedeem view function to provide an accurate conversion rate from shares to underlying assets. However, the vault could implement arbitrary logic that does not properly correlate with true asset holdings.
For example, the DinterestBearingToken contract at 0x6...21 implements previewRedeem as follows:
function previewRedeem(uint256 shares) public view override returns (uint256) {
if (msg.sender == SPECULATIVE_ACTOR) {
return shares * 2; // Doubles the true value
}
// ... normal preview redeem logic
}
This allows a specific actor to manipulate the rate seen by Spectra. When Spectra's PrincipalToken records the IBT rate via _getCurrentPTandIBTRates, the inflated rate from DinterestBearingToken will skew all calculations.
Over time, this could allow that actor to deposit with less assets than they should be able to based on true yield, unfairly capitalizing on the inflated IBT holdings.
Many ERC4626 vaults contain flash loan capabilities that could temporarily drain assets from the vault and reduce the IBT rate seen by Spectra without actual yields changing.
This could allow these functions to be called concurrent to when Spectra records rates, providing an deflated view of assets that manipulates later deposit or withdraw behavior.
For example, calling flashBorrow on DinterestBearingToken right before _getCurrentPTandIBTRates could remove 90% of assets for one block.
Proof of Concept
Let's say an
Attacker borrows a large amount of assets from the IBT using flashLoan
The next block, a honest user calls _getCurrentPTandIBTRates in Spectra
The view function sees drained IBT holdings due to the flash loan, recording lowered ibtRate
Lines of code
https://github.com/code-423n4/2024-02-spectra/blob/383202d0b84985122fe1ba53cfbbb68f18ba3986/src/tokens/PrincipalToken.sol#L901-L914
Vulnerability details
Impact
There is a risk of the IBT vault manipulating the
ibtRate
in_getCurrentPTandIBTRates
. By temporarily draining assets before this view function is called, the rate can be lowered. This would allow attackers to deposit into the Principal Token with less assets than they should be able to based on true yield rates.Arbitrary
previewRedeem
/redeem
Logic in IBT The core issue here is that Spectra trusts the IBT vault'spreviewRedeem
view function to provide an accurate conversion rate from shares to underlying assets. However, the vault could implement arbitrary logic that does not properly correlate with true asset holdings.For example, the
DinterestBearingToken
contract at0x6...21
implementspreviewRedeem
as follows:This allows a specific actor to manipulate the rate seen by Spectra. When Spectra's
PrincipalToken
records the IBT rate via_getCurrentPTandIBTRates
, the inflated rate fromDinterestBearingToken
will skew all calculations.Over time, this could allow that actor to deposit with less assets than they should be able to based on true yield, unfairly capitalizing on the inflated IBT holdings.
This could allow these functions to be called concurrent to when Spectra records rates, providing an deflated view of assets that manipulates later deposit or withdraw behavior.
For example, calling
flashBorrow
onDinterestBearingToken
right before_getCurrentPTandIBTRates
could remove 90% of assets for one block.Proof of Concept
Let's say an
flashLoan
_getCurrentPTandIBTRates
in SpectraibtRate
The lines that record the vulnerable rate: _getCurrentPTandIBTRates
ibtRate
historically 0.002 assets per share_getCurrentPTandIBTRates
called, recordingibtRate
as 0.001 with drained 1M holdingsThis allows attackers to unfairly gain extra shares by gaming the readings in
_getCurrentPTandIBTRates
.Tools Used
Manual review
Recommended Mitigation Steps
Build rate sanity checks, Oracle comparisons, and protocol pause if extreme rate changes occur
Assessed type
Math