The ptRate and ibtRate are maintained and updated at the PT contract level, and they are updated not systematically but rather only when any user interacts with the contract. Furthermore, ptRate is only allowed to decrease, which makes it unfavorable for all users in the event of any (momentary) past de-pegging event regardless of the current situation.
Vulnerability Details
In the protocol, PTs are supposed to be redeemable 1:1 with the underlying assets except when in the (continued) negative yield case. However, the ptRate is only allowed to decrease even if the market recovers from a (momentary) de-pegging event. Furthermore, the PT contract's ptRate and ibtRate are updated only when any user interacts with the protocol. This poses a risk for loss of asset balances for every user of the protocol if any user interacts with the protocol when ibtRate is decreased. Even if the market recovers (e.g., ibtRate increased back), the users will never redeem the fair amount of assets back, and all the loss of users will be taken as the "gain" of the protocol. This issue is especially concerning because the asset loss of all users can be caused by a single user/actor who interacts with the protocol.
Impact
The impact of this vulnerability is HIGH because this can impact ALL users. Furthermore, the longer a user keeps PTs with the protocol, the higher chance that the user can get the loss.
Proof of Concept
The following test code can be added to ContractPrincipalToken1. Only two user cases are shown here for simplicity, but it applies to any number of users. The code proves that any de-pegging event can cause the loss for users even if the market recovers, and the loss of users means the gain of the protocol. The brief flow for the code is as follows:
ADDR_1 deposits assets to the PT contract.
ADDR_2 deposits assets when ibtRate has decreased.
The market has recovered, and ADDR_1 redeems assets when ibtRate has recovered.
ADDR_1 only receives a reduced amount of assets because of step 2.
The loss of ADDR_1 reflected in the gain of the protocol.
Currently, the protocol only penalizes PT holders if ibtRate decreases but does not compensate when the market recovers. There is a need to implement a mechanism to reflect the increased yield (at least for the market recovery) scenarios for PT holders. For example, the protocol may record a ptRate (as deposit ptRate) when a user deposits and consider increasing ptRate up to the deposit ptRate when the market recovers.
Lines of code
https://github.com/code-423n4/2024-02-spectra/blob/383202d0b84985122fe1ba53cfbbb68f18ba3986/src/tokens/PrincipalToken.sol#L901
Vulnerability details
Summary
The
ptRate
andibtRate
are maintained and updated at the PT contract level, and they are updated not systematically but rather only when any user interacts with the contract. Furthermore, ptRate is only allowed to decrease, which makes it unfavorable for all users in the event of any (momentary) past de-pegging event regardless of the current situation.Vulnerability Details
In the protocol, PTs are supposed to be redeemable 1:1 with the underlying assets except when in the (continued) negative yield case. However, the
ptRate
is only allowed to decrease even if the market recovers from a (momentary) de-pegging event. Furthermore, the PT contract'sptRate
andibtRate
are updated only when any user interacts with the protocol. This poses a risk for loss of asset balances for every user of the protocol if any user interacts with the protocol whenibtRate
is decreased. Even if the market recovers (e.g.,ibtRate
increased back), the users will never redeem the fair amount of assets back, and all the loss of users will be taken as the "gain" of the protocol. This issue is especially concerning because the asset loss of all users can be caused by a single user/actor who interacts with the protocol.Impact
The impact of this vulnerability is HIGH because this can impact ALL users. Furthermore, the longer a user keeps PTs with the protocol, the higher chance that the user can get the loss.
Proof of Concept
The following test code can be added to
ContractPrincipalToken1
. Only two user cases are shown here for simplicity, but it applies to any number of users. The code proves that any de-pegging event can cause the loss for users even if the market recovers, and the loss of users means the gain of the protocol. The brief flow for the code is as follows:ADDR_1
deposits assets to the PT contract.ADDR_2
deposits assets whenibtRate
has decreased.ADDR_1
redeems assets whenibtRate
has recovered.ADDR_1
only receives a reduced amount of assets because of step 2.ADDR_1
reflected in the gain of the protocol.Tools Used
Foundry
Recommended Mitigation Steps
Currently, the protocol only penalizes PT holders if ibtRate decreases but does not compensate when the market recovers. There is a need to implement a mechanism to reflect the increased yield (at least for the market recovery) scenarios for PT holders. For example, the protocol may record a ptRate (as
deposit ptRate
) when a user deposits and consider increasing ptRate up to thedeposit ptRate
when the market recovers.Assessed type
Other