Platform: Code4rena
Start Date: 24/02/2022
Pot Size: $170,000 UST
Total HM: 15
Participants: 16
Period: 14 days
Judge: Albert Chon
Total Solo HM: 11
Id: 82
League: COSMOS
Rank: 4/16
Findings: 3
Award: $12,853.92
🌟 Selected for report: 2
🚀 Solo Findings: 0
🌟 Selected for report: csanuragjain
Also found by: cmichel
https://github.com/code-423n4/2022-02-anchor/blob/main/contracts/anchor-token-contracts/contracts/distributor/src/contract.rs#L140 https://github.com/code-423n4/2022-02-anchor/blob/main/contracts/anchor-token-contracts/contracts/community/src/contract.rs#L69
It seems that the owner is only allowed to spend amount uptil config.spend_limit. However it was observed that this config.spend_limit is never decreased even if owner has spend an amount. This makes config.spend_limit useless as owner can simply send 2-multiple transactions each of config.spend_limit which will all pass and hence bypassing the spend limit placed on owner
After successful spend, the config.spend_limit should be decreased by the amount spend
#1 - GalloDaSballo
2022-08-07T00:39:56Z
Dup of #34
🌟 Selected for report: WatchPug
Also found by: csanuragjain
It was observed that execute_claim_rewards/execute_decrease_balance/execute_increase_balance are missing to update the global index before calculating user rewards in anchor_basset_reward contract This can lead to serious consequences:
This should be revised as done in below contract: https://github.com/code-423n4/2022-02-anchor/blob/main/contracts/anchor-bEth-contracts/contracts/anchor_beth_reward/src/user.rs
#0 - GalloDaSballo
2022-08-07T00:46:07Z
Similar to #24
Function: execute_register_validator
Problem: If a Validator is already registered there is no need of further processing. Check for same is missing
Recommendation: Add a check to verify if the given validator is already whitelisted in which case directly return. Use is_valid_validator in state.rs for this purpose
Function: withdraw_voting_tokens
Problem: Gas is wasted if withdraw_share is computed as 0
Recommendation: Add a check for withdraw_share>0, otherwise return
Function: create_poll
Recommendation: Change state.poll_count += 1; to state.poll_count = poll_id; to perform gas saving
Function: cast_vote
Problem: If amount is 0 then user vote gets wasted and also cause gas wastage
Recommendation: check amount!=0
Function: execute
Recommendation: Since both function require governance, governance check can be placed in execute instead of placing individually in UpdateConfig and Spend as done in https://github.com/code-423n4/2022-02-anchor/blob/main/contracts/anchor-token-contracts/contracts/vesting/src/contract.rs
Function: execute_increase_balance/execute_decrease_balance
Contract: https://github.com/code-423n4/2022-02-anchor/blob/main/contracts/anchor-bAsset-contracts/contracts/anchor_basset_reward/src/user.rs#L80 https://github.com/code-423n4/2022-02-anchor/blob/main/contracts/anchor-bAsset-contracts/contracts/anchor_basset_reward/src/user.rs#L125
Recommendation: In both the function add a check for amount!=0
#0 - GalloDaSballo
2022-08-04T23:49:34Z
Probably most interesting report