Malt Finance contest - 0x0x0x's results

Yield farmable, incentive-centric algorithmic stable coin.

General Information

Platform: Code4rena

Start Date: 25/11/2021

Pot Size: $80,000 USDC

Total HM: 35

Participants: 32

Period: 7 days

Judge: GalloDaSballo

Total Solo HM: 27

Id: 59

League: ETH

Malt Finance

Findings Distribution

Researcher Performance

Rank: 6/32

Findings: 6

Award: $5,166.49

🌟 Selected for report: 6

🚀 Solo Findings: 1

Findings Information

🌟 Selected for report: WatchPug

Also found by: 0x0x0x, gzeon

Labels

bug
duplicate
3 (High Risk)

Awards

993.3812 USDC - $993.38

External Links

Handle

0x0x0x

Vulnerability details

Impact

Delay can be changed without any delay. Therefore, it is possible to call functions from this contract in a single block by changing the delay. This creates a huge attack vector, since if governor private keys would be stolen, everything can be withdrawn in several blocks. Even, if the private keys won't be stolen, users can not do anything against a rug pull. Effectively, this contract doesn't provide the functionality it should.

Mitigation Step

In OZ timelock contracts, for setDelay function, there is a requirement that msg.sender == address(this). By doing so changing the delay is also timelocked, so it can not be abused to do a rug pull in a single block. Add this statement to setDelay to make sure it will function properly.

https://github.com/OpenZeppelin/openzeppelin-contracts/blob/7d17acfb2f12be0a2ad4c08ad4a3d823704b68d6/contracts/governance/TimelockController.sol#L349

#0 - 0xScotch

2021-12-08T12:47:48Z

#263

#1 - GalloDaSballo

2022-01-08T17:10:55Z

Duplicate of #263

Findings Information

🌟 Selected for report: 0x0x0x

Labels

bug
3 (High Risk)
sponsor confirmed

Awards

3679.1897 USDC - $3,679.19

External Links

Handle

0x0x0x

Vulnerability details

Vulnerability

AuctionEschapeHatch.sol#exitEarly takes as input amount to represent how much of the

When the user exits an auction with profit, to apply the profit penalty less maltQuantity is liquidated compared to how much malt token the liquidated amount corresponds to. The problem is auction.amendAccountParticipation() simply subtracts the malt quantity with penalty and full amount from users auction stats. This causes a major problem, since in _calculateMaltRequiredForExit those values are used for calculation by calculating maltQuantity as follow:

uint256 maltQuantity = userMaltPurchased.mul(amount).div(userCommitment);

The ratio of userMaltPurchased / userCommitment gets higher after each profit taking (since penalty is applied to substracted maltQuantity from userMaltPurchased), by doing so a user can earn more than it should. Since after each profit taking users commitment corresponds to proportionally more malt, the user can even reduce profit penalties by dividing exitEarly calls in several calls.

In other words, the ratio of userMaltPurchased / userCommitment gets higher after each profit taking and user can claim more malt with less commitment. Furthermore after all userMaltPurchased is claimed the user can have userCommitment left over, which can be used to claimArbitrage, when possible.

Mitigation Step

Make sure which values are used for what and update values which doesn't create problems like this. Rethink about how to track values of an auction correctly.

#0 - GalloDaSballo

2022-01-25T02:08:13Z

The warden has identified an exploit that allows early withdrawers to gain more rewards than expected. Anytime "points" and rewards need to be earned over time, it's ideal to accrue points in order to distribute them (see how Compound or AAVE tokens work) Because the warden showed a flow in the accounting logic for the protocol, I agree with high severity.

Findings Information

Labels

bug
duplicate
2 (Med Risk)

Awards

20.04 USDC - $20.04

External Links

Handle

0x0x0x

Vulnerability details

Impact

In UniswapHandler.sol two important functions sellMalt and buyMalt use swapExactTokensForTokens with amountOutMin = 0. This is a big problem since miners can exploit this intensively. So miners can strongly manipulate the price, since they can order the sell and buy commands arbitrarily and there is no further check avoiding big manipulations. Even the oracles use moving average, this can be exploited by only accepting sell or buy orders in a block.

As a consequence price can heavily get manipulated and users and protocol can get scammed.

At least approximately provide a amountOutMin

#0 - 0xScotch

2021-12-10T00:22:34Z

#219

#1 - GalloDaSballo

2022-01-09T22:13:22Z

Duplicate of #219

Findings Information

🌟 Selected for report: 0x0x0x

Also found by: harleythedog, hyh

Labels

bug
2 (Med Risk)
sponsor confirmed

Awards

298.0144 USDC - $298.01

External Links

Handle

0x0x0x

Vulnerability details

Impact

In case the reward token is changed, totalDeclaredReward will be changed and likely equal to 0. Since _userStakePadding and _globalStakePadding are accumulated, changing the reward token will not reset those values. Thus, it will create problems.

Recommendation

I think it would be the best to remove this function.

If you want to keep it, then it must have an event and it should be used by a timelock contract. Furthermore, it has to be used carefully and the new token should be distributed such that padding variables still make sense.

#0 - GalloDaSballo

2022-01-09T22:38:51Z

Agree with highlighting the Admin Privilege, however because this is contingent on a malicious Admin, I'll downgrade the finding to Medium Severity.

Mitigation could be done by ensuring old rewards are sent out, still claimable, or by making the rewardToken immutable

AuditHub

A portfolio for auditors, a security profile for protocols, a hub for web3 security.

Built bymalatrax © 2024

Auditors

Browse

Contests

Browse

Get in touch

ContactTwitter