Closed c4-bot-6 closed 8 months ago
gzeon-c4 marked the issue as insufficient quality report
gzeon-c4 marked the issue as primary issue
they get share using the same rate, don't see where the dilution came from
JustDravee marked the issue as unsatisfactory: Invalid
Lines of code
https://github.com/code-423n4/2024-02-spectra/blob/main/src/tokens/PrincipalToken.sol#L750
Vulnerability details
Impact
The PrincipalToken allows the first depositor to arbitrarily set the initial PT and IBT rates by making the first deposit. This could be exploited to dilute future depositors.
Proof of Concept
The
ibtRate
andptRate
state variables are initialized to some defaults. But the first depositor can arbitrarily set them by choosing the deposit amount_ibts
.Lines of Code
In
_depositIBT()
function first depositor can set arbitrary rates by deposit amount in this line:Lines of Code
Lines of Code
Later depositors get diluted shares based on manipulated rates
This exploits the
_convertIBTsToShares()
conversion formula:Lines of Code
Malicious user can manipulate the ratio between
_ibts
and_ptRate
by setting the rates in their favor before others deposit.Scenario
Deploy a new PrincipalToken contract.
Call
_depositIBT()
as the first depositor, passing a very small_ibts
amount (e.g. 1 wei).This sets the initial
ibtRate
andptRate
to be very high (e.g. 1e18).Now the first depositor has minted a large number of PT shares (e.g. 1e18) for practically no deposited assets.
When second depositor comes in, they get diluted PT shares based on high rates set by first depositor.
First depositor cashes out with huge amount relative to their initial deposit.
Tools
Manual Review
Recommended Mitigation Steps
Initialize a fair
ptRate
in the constructor based on initial APY assumptions. Don't allow it to be arbitrarily set by first depositor.Set an initial placeholder
ibtRate
that gets corrected after first valid deposit with minimum size. Don't let it default to zero.Pause initial deposits via
Pausable
and unpause after sane rates are set by owner.Limit the ratio between
ibtRate
andptRate
to be within a valid range.Allow owner to set initial rates after deploy before first deposit.
Assessed type
Other