Platform: Code4rena
Start Date: 21/07/2023
Pot Size: $90,500 USDC
Total HM: 8
Participants: 60
Period: 7 days
Judge: 0xean
Total Solo HM: 2
Id: 264
League: ETH
Rank: 25/60
Findings: 1
Award: $471.90
🌟 Selected for report: 0
🚀 Solo Findings: 0
🌟 Selected for report: Juntao
Also found by: Jiamin, Juntao, UniversalCrypto, auditsea, circlelooper, crunch, lanrebayode77, vangrim, zaevlad
471.8972 USDC - $471.90
GSC allowance given to an address cannot be altered under certain circumstances.
function gscApprove in ArcadeTreasury.sol allows GSC to give token allowance to an address to pull tokens from the treasury.
function gscApprove( address token, address spender, uint256 amount ) external onlyRole(GSC_CORE_VOTING_ROLE) nonReentrant { if (spender == address(0)) revert T_ZeroAddress("spender"); if (amount == 0) revert T_ZeroAmount(); // Will underflow if amount is greater than remaining allowance gscAllowance[token] -= amount; _approve(token, spender, amount, spendThresholds[token].small); }
One address can be approved by many times and the allowance is updated to the newest amount. However, under certain circumstances, an address's allowance cannot be altered even if it is to reduce the approved allowance. For example, assuming token is USDC and gscAllowance[token] is 100e6, address A was given 60e6 allowance by GSC, if then GSC want to reduce the allowance to 50e6, the transaction will fail because of the following line:
gscAllowance[token] -= amount
At the moment, gscAllowance[token] is 40e6 and amount is 50e6, underflow error will be thrown due to 40e6 - 50e6.
Manual Review
If it is to reduce the allowance to an address, please consider to add the reduced amount to gscAllowance[token].
Access Control
#0 - c4-pre-sort
2023-07-29T13:55:12Z
141345 marked the issue as duplicate of #85
#1 - c4-pre-sort
2023-07-29T14:03:04Z
141345 marked the issue as not a duplicate
#2 - c4-pre-sort
2023-07-29T14:03:11Z
141345 marked the issue as duplicate of #58
#3 - c4-judge
2023-08-10T14:42:48Z
0xean changed the severity to 2 (Med Risk)
#4 - c4-judge
2023-08-11T01:40:26Z
0xean marked the issue as selected for report
#5 - c4-judge
2023-08-11T01:40:30Z
0xean marked issue #58 as primary and marked this issue as a duplicate of 58
#6 - c4-judge
2023-08-11T16:55:55Z
0xean marked the issue as satisfactory
🌟 Selected for report: Juntao
Also found by: Jiamin, Juntao, UniversalCrypto, auditsea, circlelooper, crunch, lanrebayode77, vangrim, zaevlad
471.8972 USDC - $471.90
Token allowance given to an address by GSC is not revoked when GSC allowance is decreased, the approved address can pull more tokens from treasury than GSC allowance.
GSC can give token allowance to an address, the given allowance cannot be more than GSC allowance, i.e. the approved address cannot pull more tokens than GSC allowance. The GSC allowance can be updated by admin:
function setGSCAllowance(address token, uint256 newAllowance) external onlyRole(ADMIN_ROLE) { if (token == address(0)) revert T_ZeroAddress("token"); if (newAllowance == 0) revert T_ZeroAmount(); // enforce cool down period if (uint48(block.timestamp) < lastAllowanceSet[token] + SET_ALLOWANCE_COOL_DOWN) { revert T_CoolDownPeriod(block.timestamp, lastAllowanceSet[token] + SET_ALLOWANCE_COOL_DOWN); } uint256 spendLimit = spendThresholds[token].small; // new limit cannot be more than the small threshold if (newAllowance > spendLimit) { revert T_InvalidAllowance(newAllowance, spendLimit); } // update allowance state lastAllowanceSet[token] = uint48(block.timestamp); gscAllowance[token] = newAllowance; emit GSCAllowanceUpdated(token, newAllowance); }
If GSC allowance is decreased, for example, from 100e6 to 50e6, GSC cannot give more than 50e6 allowance to an address, however, if an address was given 100e6 allowance before the update, this address can still pull 100e6 tokens from treasury because the allowance is not revoked after the update.
Manual Review
If GSC allowance is updated by admin, please consider to revoke the token allowance given out by GSC.
Access Control
#0 - c4-pre-sort
2023-07-29T14:25:17Z
141345 marked the issue as duplicate of #53
#1 - c4-pre-sort
2023-07-29T14:26:04Z
141345 marked the issue as not a duplicate
#2 - 141345
2023-07-29T14:36:44Z
exptected behavior
#3 - c4-pre-sort
2023-07-30T16:09:24Z
141345 marked the issue as duplicate of #59
#4 - c4-pre-sort
2023-08-01T07:07:21Z
141345 marked the issue as duplicate of #58
#5 - c4-judge
2023-08-10T14:42:48Z
0xean changed the severity to 2 (Med Risk)
#6 - c4-judge
2023-08-11T01:40:21Z
0xean marked the issue as satisfactory