The createGameWithEth function is marked as external, and it lacks access control allowing any user to call it.
Vulnerable Contract: RockPaperScissors.sol
Vulnerable Function: createGameWithEth
The function is marked external and has no modifiers or role checks. Without proper access control in place, malicious actors can manipulate and flood the contract with game creation, which can also lead to a Denial of Service (DoS) attacks.
Below is a test in foundry to show how it might work.
add the following to RockPaperScissorsTest.t.sol file
function testAccessControlVulnerability() public {
// Test unlimited game creation
vm.deal(playerA, 10 ether);
vm.startPrank(playerA);
When you run forge test --match-test testAccessControlVulnerability , the test should pass.
An attacker can monitor the mempool and thus frontrun other players.
An attacker can create multiple games to distort the entire system.
Manual Review
Foundry
Make use of OpenZeppelin’s AccessControl to implement role-based permissions for the createGameWithEth function to protect against spam and abuse of contract.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.