The setPrediction
function in the ScoreBoard.sol
contract lacks access control, which could allow unauthorized users to modify or reset player predictions. This vulnerability poses a risk of attackers deleting or tampering with predictions, affecting the integrity of the prediction system.
The setPrediction
function allows updating predictions for any player without verifying the caller's identity. This absence of access control means that any address or contract could potentially call this function, resulting in unauthorized modifications to player predictions.
This is the test code of attack.
To test this code:
Input this code to new test solidity file: test/AttackPrediction.test.sol
.
Then run this command:
forge test --match-path test/AttackPrediction.test.sol --match-test testAttackPrediction -vvvv
The result is:
As you can see, the attacker can reset or modify predictions for any players.
An attacker could exploit the lack of access control to reset or modify predictions for any player, potentially leading to unfair outcomes and loss of trust in the system.
Unauthorized changes to predictions could compromise the accuracy of the system and affect the overall reliability of the prediction results.
Manual code review
Introduce an access control mechanism to restrict the setPrediction
function so that only authorized entities (e.g., the ThePredicter
contract) can call it.
setPrediction has no access control and allows manipulation to Players' predictions.
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.