Staking even large amounts of CREDIT in SurplusGuildMinter is blocked by the requirement that the amount exceed MIN_STAKE #382
Labels
2 (Med Risk)
Assets not at direct risk, but function/availability of the protocol could be impacted or leak value
bug
Something isn't working
sufficient quality report
This report is of sufficient quality
unsatisfactory
does not satisfy C4 submission criteria; not eligible for awards
Lines of code
https://github.com/code-423n4/2023-12-ethereumcreditguild/blob/2376d9af792584e3d15ec9c32578daa33bb56b43/src/loan/SurplusGuildMinter.sol#L26
https://github.com/code-423n4/2023-12-ethereumcreditguild/blob/2376d9af792584e3d15ec9c32578daa33bb56b43/src/loan/SurplusGuildMinter.sol#L125
Vulnerability details
Impact
SurplusGuiltMinter.sol
allows users to stake their CREDIT tokens to get GUILD tokens that can be used to vote for lending term gauges. This staking is performed by callingstake
. The contract has a basic concept ofMIN_STAKE
to prevent people from staking dust amounts. Thestake
function requires that the amount to stake be larger than or equal toMIN_STAKE
. The problem isMIN_STAKE
is set to 1e18 but thestake
function requires that amount exceedMIN_STAKE
(notMIN_STAKE
/ 1e18). Therefore, any attempt to stake even a very large amount of tokens (like 1,000,000,000 which is probably more than any one user will have) will fail since you must stake 1,000,000,000,000,000,000+ tokens to pass the check.Therefore, this is a complete denial of service to stake. See test below.
Proof of Concept
Here is the relevant code. The
MIN_STAKE
is set to 1e18 (presumably with the intent of preventing people from staking less than 1 token) link to code:Here is the
stake
function which requires thatamount
(to stake) exceeds or equalsMIN_STAKE
(not divided by 1e18) link to code:Run the following test to stake 1,000,000 CREDIT tokens - it will pass (ie, the attempt to stake will revert) though the person is staking a large number of tokens:
This is what I get after running the test which shows that the revert due to failure to stake the minimum amount is the result:
Tools Used
Foundry
Manual review
Recommended Mitigation Steps
Any time
MIN_STAKE
is used, it should be divided by 1e18.Assessed type
DoS
The text was updated successfully, but these errors were encountered: