Platform: Code4rena
Start Date: 17/02/2022
Pot Size: $75,000 USDC
Total HM: 7
Participants: 23
Period: 7 days
Judge: GalloDaSballo
Total Solo HM: 2
Id: 92
League: ETH
Rank: 15/23
Findings: 2
Award: $420.84
🌟 Selected for report: 0
🚀 Solo Findings: 0
274.1542 USDC - $274.15
C4 finding submitted: (risk = 1 (Low Risk)) Slurp function may revert when it shouldn't
https://github.com/code-423n4/2022-02-tribe-turbo/blob/main/src/TurboSafe.sol#L260
slurp function checking for a non-zero getTotalFeiBoostedForVault[vault] value may cause problems.
1-Alice boosts vault V with 100 tokens. getTotalFeiBoostedForVault[vault] = 100 2-After sometime, vault accrues 1 interest. 3-Alice lesses vault V for 100 tokens. getTotalFeiBoostedForVault[vault] = 0 4-When slurp is called, it will revert although vault has 1 token.
Manual analysis
Check against interestEarned instead. First 2 lines of the function can be changed as:
// Compute the amount of Fei interest the Safe generated by boosting the Vault. uint256 interestEarned = vault.assetsOf(address(this)) - getTotalFeiBoostedForVault[vault]; // Ensure the Safe has earned interest in the Vault. require(interestEarned != 0, "NO_FEI_BOOSTED");
C4 finding submitted: (risk = 1 (Low Risk)) Non-zero recipient address checks are missing.
https://github.com/code-423n4/2022-02-tribe-turbo/blob/main/src/TurboSafe.sol#L306 https://github.com/code-423n4/2022-02-tribe-turbo/blob/main/src/TurboSafe.sol#L335 https://github.com/code-423n4/2022-02-tribe-turbo/blob/main/src/TurboMaster.sol#L318 https://github.com/code-423n4/2022-02-tribe-turbo/blob/main/src/modules/TurboGibber.sol#L74 https://github.com/code-423n4/2022-02-tribe-turbo/blob/main/src/modules/TurboGibber.sol#L98
If the recipient address is zero, tokens will be burnt accidentially. It is a good practice to check the address is non-zero.
https://github.com/code-423n4/2022-02-tribe-turbo/blob/main/src/TurboSafe.sol#L306 https://github.com/code-423n4/2022-02-tribe-turbo/blob/main/src/TurboSafe.sol#L335 https://github.com/code-423n4/2022-02-tribe-turbo/blob/main/src/TurboMaster.sol#L318 https://github.com/code-423n4/2022-02-tribe-turbo/blob/main/src/modules/TurboGibber.sol#L74 https://github.com/code-423n4/2022-02-tribe-turbo/blob/main/src/modules/TurboGibber.sol#L98
Manual analysis
Add a non-zero address check before token transfers require(to != address(0), "Zero address");
C4 finding submitted: (risk = 0 (Non-critical)) There are 2 sweep functions and TokenSweeped events
https://github.com/code-423n4/2022-02-tribe-turbo/blob/main/src/TurboSafe.sol#L300 https://github.com/code-423n4/2022-02-tribe-turbo/blob/main/src/TurboSafe.sol#L306 https://github.com/code-423n4/2022-02-tribe-turbo/blob/main/src/TurboMaster.sol#L312 https://github.com/code-423n4/2022-02-tribe-turbo/blob/main/src/TurboMaster.sol#L318
It is not a good practice to use exact same function names for 2 different functions. Also the created events are exactly the same, so it would not be possible to distinguish master sweeps events from safe sweep events.
https://github.com/code-423n4/2022-02-tribe-turbo/blob/main/src/TurboSafe.sol#L300 https://github.com/code-423n4/2022-02-tribe-turbo/blob/main/src/TurboSafe.sol#L306 https://github.com/code-423n4/2022-02-tribe-turbo/blob/main/src/TurboMaster.sol#L312 https://github.com/code-423n4/2022-02-tribe-turbo/blob/main/src/TurboMaster.sol#L318
Manual analysis
Rename the sweep functions and their events, so that they can be distinguished.
#0 - GalloDaSballo
2022-03-19T16:43:01Z
Revert on nonZero -> Pretty good finding, may be ideal to slurp on less Address zero check -> Agree by convention Sweep convention -> Personally disagree as the function does the same thing, the tweaks are for context
I appreciated that the warden put links for the findings, making mitigation easier.
I think formatting could have been done a lot better, especially titles, linking to sections and overall making the report easier to scan through.
#1 - GalloDaSballo
2022-03-20T14:58:27Z
4/10
C4 finding submitted: (Gas) Missing non-zero amount checks
https://github.com/code-423n4/2022-02-tribe-turbo/blob/main/src/TurboMaster.sol#L318 https://github.com/code-423n4/2022-02-tribe-turbo/blob/main/src/TurboSafe.sol#L171 https://github.com/code-423n4/2022-02-tribe-turbo/blob/main/src/TurboSafe.sol#L210 https://github.com/code-423n4/2022-02-tribe-turbo/blob/main/src/TurboSafe.sol#L306
Functions do not check if the amount is non-zero. A zero amount would result in unnecessary transaction and gas usage.
https://github.com/code-423n4/2022-02-tribe-turbo/blob/main/src/TurboMaster.sol#L318 https://github.com/code-423n4/2022-02-tribe-turbo/blob/main/src/TurboSafe.sol#L171 https://github.com/code-423n4/2022-02-tribe-turbo/blob/main/src/TurboSafe.sol#L210 https://github.com/code-423n4/2022-02-tribe-turbo/blob/main/src/TurboSafe.sol#L306
Manual analysis
Check if the amount is non-zero
C4 finding submitted: (Gas) Changing the order in boost function can save gas
https://github.com/code-423n4/2022-02-tribe-turbo/blob/main/src/TurboSafe.sol#L191
require(feiTurboCToken.borrow(feiAmount) == 0, "BORROW_FAILED"); can be called just after master.onSafeBoost(asset, vault, feiAmount); In case the borrow fails and reverts, the intermediate steps would be avoided.
https://github.com/code-423n4/2022-02-tribe-turbo/blob/main/src/TurboSafe.sol#L191
Manual analysis
Change the order as: // Ensure the Vault accepts Fei asset. require(vault.asset() == fei, "NOT_FEI");
// Call the Master where it will do extra validation // and update it's total count of funds used for boosting. master.onSafeBoost(asset, vault, feiAmount); // Borrow the Fei amount from the Fei cToken in the Turbo Fuse Pool. require(feiTurboCToken.borrow(feiAmount) == 0, "BORROW_FAILED"); . .
#0 - GalloDaSballo
2022-03-07T01:41:48Z
I think the formatting on this submission went wrong, and would recommend the warden to always try their MD submission on a preview tool before submitting
I don't think the sponsor likes 0 checks
3/10