Closed c4-bot-9 closed 9 months ago
gzeon-c4 marked the issue as duplicate of #109
gzeon-c4 marked the issue as sufficient quality report
JustDravee marked the issue as unsatisfactory: Invalid
JustDravee marked the issue as unsatisfactory: Invalid
Lines of code
https://github.com/code-423n4/2024-02-spectra/blob/383202d0b84985122fe1ba53cfbbb68f18ba3986/src/tokens/PrincipalToken.sol#L385-L391
Vulnerability details
Impact
User's yield will not be updated if they transfer PT tokens without also transferring YT tokens. This means that if a user earns yield through their YT tokens, and then transfers PT tokens, their yield will not be incorporated into the Principal Token contract until they also transfer YT tokens. For users who only interact with PT tokens, this could lead to lost or inaccurate yield tracking. Their earned yield would not be updated or claimable until they also transfer YTs. This violates the expected behavior and is a high severity issue.
Proof of Concept
The
beforeYtTransfer
function is only called when a YT transfer happens, not when a PT transfer happens. This means that user yield is only updated when YTs are transferred, but not when only PTs are transferred. Here is the relevant code:This shows that
updateYield
is only called for the_from
and_to
addresses when a YT transfer happens (since only the YT contract can call this function). The impact is that if a user transfers PTs, their yield will not be updated. This means the yield calculations could be incorrect if the user later redeems or transfers YTs, since the rates would not have been updated. For example:Tools Used
Manual
Recommended Mitigation Steps
The updateYield function could be called on all PT transfers in the ERC20 _beforeTokenTransfer hook:
This would ensure yields are updated on any token transfer, preventing manipulation.
Assessed type
Other