BriVault

First Flight #52
Beginner FriendlySolidity
100 EXP
View results
Submission Details
Impact: high
Likelihood: medium
Invalid

Country can be changed after the beginning of the tournament

setCountry function can be called after the begining the tournament

Description

  • The teams array should be constant once set.

  • When a participant join the event, he bets on a country based on a country id. This country id is directly set by the function setCountry and can be called multiple time, even after the tournament started

@>function setCountry(string[48] memory countries) public onlyOwner {

Risk

Likelihood:

  • Will occur if the contract owner is malicious

Impact:

  • Participant can be scammed, they think they have bet on a country but the owner has changed the team array. Even if their bet is correct there is a posibility that they can be considered as loosers.

  • Impact 2

Proof of Concept

After a country won, call to setCountry with a different sorting in parameter string[48] memory countries, make the sorting as you need to maximise the contract owner profit.

When seting the winner, the teams array will be different from the one that participant has bet on.

Recommended Mitigation

Add a check on array teams.

Check that the array is already set by checking the value of the 1st element. By default the value is "" with a length of 0. Checking this value ensuer us that the array has already been set.

- function setCountry(string[48] memory countries) public onlyOwner {
- for (uint256 i = 0; i < countries.length; ++i) {
- teams[i] = countries[i];
- }
- emit CountriesSet(countries);
-}
+ function setCountry(string[48] memory countries) public onlyOwner {
+ require(bytes(teams[0]).length == 0, "Countries already set!");
+ for (uint256 i = 0; i < countries.length; ++i) {
+ teams[i] = countries[i];
+ }
+ emit CountriesSet(countries);
+ }
Updates

Appeal created

bube Lead Judge about 1 month ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity
Assigned finding tags:

setCountry() Can Be Called After Users Join

This is owner action.

Support

FAQs

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

Give us feedback!