Platform: Code4rena
Start Date: 08/03/2023
Pot Size: $60,500 USDC
Total HM: 2
Participants: 123
Period: 7 days
Judge: hansfriese
Id: 220
League: ETH
Rank: 96/123
Findings: 1
Award: $29.67
🌟 Selected for report: 0
🚀 Solo Findings: 0
🌟 Selected for report: 0xSmartContract
Also found by: 0x1f8b, 0x6980, 0xAgro, 0xSolus, 0xhacksmithh, 0xkazim, ABA, BPZ, BowTiedOriole, ChainReview, DadeKuma, DeFiHackLabs, Deathstore, DevABDee, Diana, Dravee, Dug, Englave, Go-Langer, Haipls, IceBear, Inspex, Jeiwan, Kek, Kresh, Madalad, MatricksDeCoder, MyFDsYours, RaymondFam, Rolezn, SAAJ, Sathish9098, Taloner, Udsen, Viktor_Cortess, atharvasama, ayden, brgltd, btk, carlitox477, catellatech, chaduke, codeislight, deadrxsezzz, descharre, erictee, fatherOfBlocks, favelanky, glcanvas, handsomegiraffe, jasonxiale, jekapi, joestakey, lemonr, luxartvinsec, martin, matrix_0wl, minhquanym, mrpathfindr, nadin, oyc_109, parsely, peanuts, pfedprog, rbserver, rokso, saian, santipu_, scokaf, slvDev, tsvetanovv, ubl4nk, ulqiorra, yamapyblack, zaskoh
29.6697 USDC - $29.67
Bytes2.sol Function getReward
The following comment is mentioned above the function: "This function is called by the S1 Citizen contract to emit BYTES to callers based on their state from the staker contract."
function getReward (address _to) external { ( uint256 reward, uint256 daoCommision // @audit - @todo Review where this is used. ) = IStaker(STAKER).claimReward(_to); // Mint both reward BYTES and the DAO tax to targeted recipients. if (reward > 0) { _mint(_to, reward); } if (daoCommision > 0) { _mint(TREASURY, daoCommision); } }
If the intention is to only calling of this function by the s1Citizen contract, as per the comments above, then you should insert a require statement. Currently, any user or EOA can call this contract. Use below example if it is indeed intentional for the Citizen Contract to call this function.
require(msg.sender == S1_CITIZEN, "Only the S1 Citizen can call this.");
Function stake NeoTokyoStaker.sol
If the ID of the _asset is ever equal to 4, this function will not revert. If its not the intention to do so, then perhaps refactor the below code.
function stake ( AssetType _assetType, uint256 _timelockId, uint256, uint256, uint256 ) external nonReentrant { // Validate that the asset being staked is of a valid type. if (uint8(_assetType) > 4) { revert InvalidAssetType(uint256(_assetType)); } refactored to: if (uint8(_assetType) >= 4) { revert InvalidAssetType(uint256(_assetType)); }
With this change, the function will now throw an exception with the InvalidAssetType message if _assetType is equal to or greater than 4, which ensures that only valid asset types are accepted in the contract.
function getReward() external { IByteContract byteToken = IByteContract(bytesContract); byteToken.updateReward(msg.sender, address(0), 0); byteToken.getReward(msg.sender); }
function updateReward(address _from, address _to, uint256 _tokenId) external { require(msg.sender == address(citizenContract));
Consider adding in the same functionality here in the getReward Function, that is also comprised in the updateReward function:
"require(msg.sender == address(citizenContract));"
function getStakerPositions NeoTokyoStaker
for (uint256 i; i < _stakerS1Position[_staker].length; )
replace with:
for (uint256 i = 0; i < _stakerS1Position[_staker].length; i++).
function getPoolReward
The below variable is not being initialized properly.
uint256 totalReward;
#0 - c4-judge
2023-03-17T02:43:31Z
hansfriese marked the issue as grade-c
#1 - c4-judge
2023-04-04T09:15:51Z
hansfriese marked the issue as grade-b