In the _withdrawShares and _beforeRedeem functions of the PrincipalToken contract, the burning process fails to properly account for both PT and YT tokens, leading to unequal total supplies.
Vulnerability Details
The code fails to maintain the invariant where the Principal Token (PT) and its associated Yield Token (YT) should always have equal supplies. Despite attempts to adjust the YT balance to 0 after expiration, incorrect burning functions prevent equalization.
Violation of the invariant results in discrepancies in PT and YT supplies.
Inaccurate supply figures may cause confusion and inconsistency in token-related operations.
Users and integrators relying on accurate supply information may face challenges.
Proof of Concept
withdrawDeposit
The user deposits 100 Usdc into the contract by calling the PrincipalToken::deposit function.
The PrincipalToken::_depositIBT function mint 100 PT and 100 YT tokens to the user's address.
Finally, Total supply of PT and YT increses by 100
withdraw
User calls PrincipalToken::withdraw function after maturity
withdraw function will call PrincipalToken::_withdrawShares
This line will not be called IYieldToken(yt).burnWithoutUpdate(_owner, shares); and YT total supply remains unchanged but PT total supply will be decrease
Correct the burning functions _withdrawShares and _beforeRedeem to ensure proper burning of both PT and YT tokens, maintaining consistency in total supply. Implement checks to uphold the invariant where PT and YT should always have equal supplies.
Lines of code
https://github.com/code-423n4/2024-02-spectra/blob/383202d0b84985122fe1ba53cfbbb68f18ba3986/src/tokens/PrincipalToken.sol#L793-L796 https://github.com/code-423n4/2024-02-spectra/blob/383202d0b84985122fe1ba53cfbbb68f18ba3986/src/tokens/PrincipalToken.sol#L816-L820
Vulnerability details
Summary
In the
_withdrawShares
and_beforeRedeem
functions of thePrincipalToken
contract, the burning process fails to properly account for both PT and YT tokens, leading to unequal total supplies.Vulnerability Details
The code fails to maintain the invariant where the Principal Token (PT) and its associated Yield Token (YT) should always have equal supplies. Despite attempts to adjust the YT balance to 0 after expiration, incorrect burning functions prevent equalization.
invariant : https://github.com/code-423n4/2024-02-spectra/blob/383202d0b84985122fe1ba53cfbbb68f18ba3986/README.md?plain=1#L142
https://github.com/code-423n4/2024-02-spectra/blob/383202d0b84985122fe1ba53cfbbb68f18ba3986/src/tokens/PrincipalToken.sol#L793-L796 https://github.com/code-423n4/2024-02-spectra/blob/383202d0b84985122fe1ba53cfbbb68f18ba3986/src/tokens/PrincipalToken.sol#L816-L820
Impact
Violation of the invariant results in discrepancies in PT and YT supplies. Inaccurate supply figures may cause confusion and inconsistency in token-related operations. Users and integrators relying on accurate supply information may face challenges.
Proof of Concept
PrincipalToken::deposit
function.PrincipalToken::_depositIBT
function mint 100 PT and 100 YT tokens to the user's address.PrincipalToken::withdraw
function after maturityPrincipalToken::_withdrawShares
IYieldToken(yt).burnWithoutUpdate(_owner, shares);
and YT total supply remains unchanged but PT total supply will be decreasePrincipalToken::deposit
function.PrincipalToken::_depositIBT
function mint 100 PT and 100 YT tokens to the user's address.PrincipalToken::redeem
function after maturityPrincipalToken::_beforeRedeem
Tool used
Manual Review
Recommendation
Correct the burning functions
_withdrawShares
and_beforeRedeem
to ensure proper burning of both PT and YT tokens, maintaining consistency in total supply. Implement checks to uphold the invariant where PT and YT should always have equal supplies.Assessed type
Invalid Validation