There is a risk of reentrancy here between updating yields and minting new shares.
A malicious contract could implement IYieldToken and reenter _depositIBT before shares are minted. This could enable inflating the _ibts balance used to mint shares by calling _convertIBTsToShares again before shares are minted.
By reentering, duplicate PT and YT minting would occur while fees only paid once. This breaks share supply invariants.
Root cause - Shares minting occurs after potential reentrancy trigger in updateYield.
User extracts extra protocol value by inflating share supply via reentrancy. Breaks key PT/YT supply equality invariant.
Proof of Concept
This reentrancy vulnerability enables attackers to artificially inflate the Principal Token and Yield Token supply. By reentering before shares are minted, an attacker can double mint tokens for only a single deposit amount. This breaks the key token supply ratio invariants in the protocol.
Attackers can exploit this to extract additional value from the protocol by minting free shares that they can later redeem or withdraw against.
Attacker deploys a malicious contract implementing IYieldToken
Attacker calls _depositIBT with 100 IBT deposit
On updateYield call, malicious contract reenters _depositIBT
In reentered call, _ibts balance still reflects original 100 deposit
Tokenization fee only deducted once across two calls
_convertIBTsToShares uses inflated _ibts balance to double mint shares
Attacker burns 100 extra PT + YT they shouldn't have been able to mint
Performing the token share conversion and minting after updateYield. This enables reentering at updateYield and inflating the _ibts balance used in conversion before shares are minted in the first call.
By reentering, duplicated PT and YT minting occurs based on the original, pre-fee _ibts amount. This mints additional token supply the depositor shouldn't have access to.
Tools Used
Vs
Fix
Move _convertIBTsToShares and token minting before the updateYield call. This prevents inflating the _ibts amount via reentrancy.
Use a reentrancy guard on updateYield. This prevents reentering back into _depositIBT at all.
Recommended Mitigation Steps
Move share conversion and minting before updateYield
Lines of code
https://github.com/code-423n4/2024-02-spectra/blob/383202d0b84985122fe1ba53cfbbb68f18ba3986/src/tokens/PrincipalToken.sol#L750-L769
Vulnerability details
Impact
_depositIBT
function handles depositing IBT into the Principal Token vault, minting corresponding PT and YT. In PrincipalToken.sol::_depositIBTThere is a risk of reentrancy here between updating yields and minting new shares.
A malicious contract could implement
IYieldToken
and reenter_depositIBT
before shares are minted. This could enable inflating the_ibts
balance used to mint shares by calling_convertIBTsToShares
again before shares are minted.By reentering, duplicate PT and YT minting would occur while fees only paid once. This breaks share supply invariants.
Root cause - Shares minting occurs after potential reentrancy trigger in
updateYield
.User extracts extra protocol value by inflating share supply via reentrancy. Breaks key PT/YT supply equality invariant.
Proof of Concept
This reentrancy vulnerability enables attackers to artificially inflate the Principal Token and Yield Token supply. By reentering before shares are minted, an attacker can double mint tokens for only a single deposit amount. This breaks the key token supply ratio invariants in the protocol.
Attackers can exploit this to extract additional value from the protocol by minting free shares that they can later redeem or withdraw against.
Attacker deploys a malicious contract implementing
IYieldToken
Attacker calls
_depositIBT
with 100 IBT depositOn
updateYield
call, malicious contract reenters_depositIBT
In reentered call,
_ibts
balance still reflects original 100 depositTokenization fee only deducted once across two calls
_convertIBTsToShares
uses inflated_ibts
balance to double mint sharesAttacker burns 100 extra PT + YT they shouldn't have been able to mint
Performing the token share conversion and minting after
updateYield
. This enables reentering atupdateYield
and inflating the_ibts
balance used in conversion before shares are minted in the first call.By reentering, duplicated PT and YT minting occurs based on the original, pre-fee
_ibts
amount. This mints additional token supply the depositor shouldn't have access to.Tools Used
Vs
Fix
Move
_convertIBTsToShares
and token minting before theupdateYield
call. This prevents inflating the_ibts
amount via reentrancy.Use a reentrancy guard on
updateYield
. This prevents reentering back into_depositIBT
at all.Recommended Mitigation Steps
updateYield
updateYield
Assessed type
Reentrancy