Open c4-bot-7 opened 9 months ago
gzeon-c4 marked the issue as duplicate of #33
gzeon-c4 marked the issue as sufficient quality report
JustDravee marked the issue as selected for report
JustDravee changed the severity to 2 (Med Risk)
yanisepfl (sponsor) confirmed
Lines of code
https://github.com/code-423n4/2024-02-spectra/blob/main/src/tokens/PrincipalToken.sol#L483-L485 https://github.com/code-423n4/2024-02-spectra/blob/main/src/tokens/PrincipalToken.sol#L460-L462 https://github.com/code-423n4/2024-02-spectra/blob/main/src/tokens/PrincipalToken.sol#L278-L287 https://github.com/code-423n4/2024-02-spectra/blob/main/src/tokens/PrincipalToken.sol#L229-L237
Vulnerability details
Impact
Protocols that try to integrate with Spectra, expecting
PrincipalToken
to be ERC-5095 compliant, will face an array of issues that may damage Spectra's brand and limit Spectra's growth in the market.Proof of Concept
All official ERC-5095 requirements are on their official page. Non-compliant methods are listed below along with why they are not compliant and code POCs demonstrating the issues. To run the POCs, copy-paste them into
PrincipalToken.t.sol
:PrincipalToken::redeem
andPrincipalToken::withdraw
As specified in ERC-5095, both
withdraw
andredeem
must support a flow wheremsg.sender
has approval over the owner's tokens.However, neither
PrincipalToken::redeem
norPrincipalToken::withdraw
support this flow type.PrincipalToken::maxWithdraw
According to ERC-5095,
maxWithdraw
must not revert and must return 0 if withdrawal is disabled.However,
PrincipalToken::maxWithdraw
reverts ifPrincipalToken
is paused.PrincipalToken::maxRedeem
According to ERC-5095,
maxRedeem
must return 0 if redeem is disabled.However
PrincipalToken::maxRedeem
does not return 0 whenPrincipalToken
is paused.Tools Used
Manual review.
Recommended Mitigation Steps
PrincipalToken::redeem
andPrincipalToken::withdraw
should be changed to support a flow wheremsg.sender
has EPI-20 approval over the owner's principal tokens.PrincipalToken::maxRedeem
andPrincipalToken::maxWithdraw
should be changed to return 0 whenPrincipalToken
is paused.Assessed type
Other