Christmas Dinner

First Flight #31
Beginner FriendlyFoundrySolidity
100 EXP
View results
Submission Details
Severity: medium
Invalid

[M-2] Front-running vulnerability in changeHost function

Summary

The changeHost function can be front-run by the current host to prevent transfer of control.

Vulnerability Details

function changeHost(address _newHost) external onlyHost {
if(!participant[_newHost]) {
revert OnlyParticipantsCanBeHost();
}
host = _newHost;
emit NewHost(host);
}

Impact

  • Medium: Host transfer can be blocked

  • Potential denial of service for host changes

  • Could prevent event from proceeding if host is unavailable

Tools Used

  • Foundry for testing

function test_frontRunChangeHost() public {
// Setup initial host change
vm.prank(host);
dinner.changeHost(user1);
// Front-run with another host change
vm.prank(host);
dinner.changeHost(user2);
assertEq(dinner.getHost(), user2);
}

Recommendations

Implement a two-step host transfer:

address public pendingHost;
function proposeNewHost(address _newHost) external onlyHost {
pendingHost = _newHost;
}
function acceptHostRole() external {
require(msg.sender == pendingHost, "Not pending host");
host = pendingHost;
pendingHost = address(0);
}
Updates

Lead Judging Commences

0xtimefliez Lead Judge 7 months ago
Submission Judgement Published
Invalidated
Reason: Design choice
0xtimefliez Lead Judge 7 months ago
Submission Judgement Published
Invalidated
Reason: Design choice

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.