Summary
Events must be emitted before external calls
Vulnerability Details
Emit events before external calls MErc20DelegateFixer.sol
function repayBadDebtWithCash(uint256 amount) external nonReentrant {
badDebt = SafeMath.sub(badDebt, amount, "amount exceeds bad debt");
EIP20Interface token = EIP20Interface(underlying);
require(
token.transferFrom(msg.sender, address(this), amount),
"transfer in failed"
);
emit BadDebtRepayed(amount);
}
Impact
Can lead to events being emitted out of order
Tools Used
Manual Analysis
Recommendations
Recommended emit events first before external calls e.g transfers etc
function repayBadDebtWithCash(uint256 amount) external nonReentrant {
badDebt = SafeMath.sub(badDebt, amount, "amount exceeds bad debt");
EIP20Interface token = EIP20Interface(underlying);
emit BadDebtRepayed(amount);
require(
token.transferFrom(msg.sender, address(this), amount),
"transfer in failed"
);
}