M-10 The surplus ether is not returned
The mint function is payable and only checks that the sent ether is at least the mint price, so any surplus is kept by the contract rather than returned. An attacker or user could lose ether by overpaying.
Submitted by c4lanky
Note: this finding was reported via the winning Automated Findings report. It was declared out of scope for the audit, but is being included here for completeness.
The function is marked as payable, but the surplus ether is not returned. This may lead to the loss of ether.
The condition should be changed to check for equality, or the code should refund the excess.
There are 1 instances of this issue: File: contracts/nft/ReputationBadge.sol
98: function mint(
99: address recipient,
100: uint256 tokenId,
101: uint256 amount,
102: uint256 totalClaimable,
103: bytes32[] calldata merkleProof
104: ) external payable {
105: uint256 mintPrice = mintPrices[tokenId] * amount;
106: uint48 claimExpiration = claimExpirations[tokenId];
107:
108: if (block.timestamp > claimExpiration) revert RB_ClaimingExpired(claimExpiration, uint48(block.timestamp));
109: if (msg.value < mintPrice) revert RB_InvalidMintFee(mintPrice, msg.value);
110: if (!_verifyClaim(recipient, tokenId, totalClaimable, merkleProof)) revert RB_InvalidMerkleProof();
111: if (amountClaimed[recipient][tokenId] + amount > totalClaimable) {
112: revert RB_InvalidClaimAmount(amount, totalClaimable);
113: }
114:
115: // increment amount claimed
116: amountClaimed[recipient][tokenId] += amount;
117:
118: // mint to recipient
119: _mint(recipient, tokenId, amount, "");
120: }
https://github.com/code-423n4/2023-07-arcade/blob/main/contracts/nft/ReputationBadge.sol#L98-L120
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
The code checks msg.value < mintPrice instead of requiring exact payment or refunding the difference.
Impact
Users who send more ether than the mint price may lose the surplus, as it is not returned.
What the attacker needed
User sends more ether than mint price
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
When you send money to a smart contract function, the function can accept more than it needs. Here the mint function only checks that you sent at least the required price, so if you send more, the extra stays in the contract and you do not get it back. This means you can accidentally lose money.
What is Business logic?
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.