Platform: Code4rena
Start Date: 16/10/2023
Pot Size: $60,500 USDC
Total HM: 16
Participants: 131
Period: 10 days
Judge: 0xTheC0der
Total Solo HM: 3
Id: 296
League: ETH
Rank: 87/131
Findings: 1
Award: $10.17
🌟 Selected for report: 0
🚀 Solo Findings: 0
🌟 Selected for report: J4X
Also found by: 0x3b, 0xCiphky, 0xComfyCat, 0xStalin, 0xbepresent, 3docSec, DavidGiladi, DeFiHackLabs, Drynooo, Fulum, GREY-HAWK-REACH, InAllHonesty, MatricksDeCoder, Mike_Bello90, MiloTruck, Phantom, SHA_256, T1MOH, Udsen, VAD37, YusSecurity, ZdravkoHr, ast3ros, caventa, deepkin, deth, devival, ggg_ttt_hhh, inzinko, jasonxiale, josieg_74497, karanctf, ke1caM, nisedo, nobody2018, nonseodion, osmanozdemir1, radev_sw, rvierdiiev, serial-coder, t0x1c
10.1663 USDC - $10.17
https://github.com/code-423n4/2023-10-wildcat/blob/main/src/market/WildcatMarketToken.sol#L31-L34 https://github.com/code-423n4/2023-10-wildcat/blob/main/src/market/WildcatMarketToken.sol#L59-L62
Detailed description of the impact of this finding.
Provide direct links to all referenced code in GitHub. Add screenshots, logs, or any other relevant proof that illustrates the concept.
function approve(address spender, uint256 amount) external virtual nonReentrant returns (bool) { _approve(msg.sender, spender, amount); return true; }
https://github.com/code-423n4/2023-10-wildcat/blob/main/src/market/WildcatMarketToken.sol#L59-L62
function _approve(address approver, address spender, uint256 amount) internal virtual { allowance[approver][spender] = amount; emit Approval(approver, spender, amount); }
In this function, users can approve an invalid address, such as the zero address.
This operation is considered invalid since both the approver and the spender must be non-zero addresses for proper execution.
To avoid the operation where users can approve to invalid addresses such as the zero address, you can add a require statement to check that both the approver and the spender are non-zero addresses. Here's an example of how you can do this in Solidity:
function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); ... }
Invalid Validation
#0 - c4-pre-sort
2023-10-27T10:05:54Z
minhquanym marked the issue as low quality report
#1 - minhquanym
2023-10-27T10:05:56Z
QA
#2 - c4-judge
2023-11-08T16:53:25Z
MarioPoneder changed the severity to QA (Quality Assurance)
#3 - c4-judge
2023-11-09T14:01:14Z
MarioPoneder marked the issue as grade-b