Require statement missing in fallback and burnEtherForMember() functions #137
Labels
1 (Low Risk)
Assets are not at risk. State handling, function incorrect as to spec, issues with comments
bug
Something isn't working
sponsor confirmed
Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity")
Handle
Reigada
Vulnerability details
Impact
The contract BasicSale contains a fallback function and a burnEtherForMember() function with exactly the same implementation. These 2 functions do the following call:
_recordBurn(msg.sender, msg.sender, currentEra, currentDay, msg.value);
The _recordBurn function contains the following if block:
if (mapEraDay_MemberUnits[_era][_day][_member] == 0) { // If hasn't contributed to this Day yet
mapMemberEra_Days[_member][_era].push(_day); // Add it
mapEraDay_MemberCount[_era][_day] += 1; // Count member
mapEraDay_Members[_era][_day].push(_member); // Add member
}
What does this mean? If a user performs multiple calls to the contract sending 0 ether as msg.value, the if block will be entered and a new key will be pushed to the mapping. Luckily the cost of an addition to or a read from a mapping does not change with the number of keys mapped. But this would totally mess the function getDaysContributedForEra output. Currently this function is only used as a view function, and not used by the smart contract itself. But it's a risk for future implementations that may make use of it.
Proof of Concept
<Transaction '0xd65ffecd5052314bc09f616461ff6aa9efeb857151c0339dc15653fb90ebb91f'>
<Transaction '0x0a48f89c1266af2c3eea5cdcec93dae76e4ed2a0936e53e8713d669989b88b19'>
<Transaction '0xeb85e31664eb1578f54daba1be112f9533948d0e2414510874ed55fbb3a9a9e0'>
Tools Used
Manual testing
Recommended Mitigation Steps
Add the following require statement to the fallback and the burnEtherForMember() functions:
require(msg.value > 0, "Some ether should be sent")
The text was updated successfully, but these errors were encountered: