TwentyOne

First Flight #29
Beginner FriendlyGameFiFoundrySolidity
100 EXP
View results
Submission Details
Severity: high
Invalid

Access control issue in `playersHand` function.

Description:

https://github.com/Cyfrin/2024-11-TwentyOne/blob/a4429168302722d14a5e5996d25d6fc5be22a899/src/TwentyOne.sol#L29

The playersHand function lacks adequate access control, allowing any external entity to retrieve the details of the players hand during the game. This unrestricted access can be exploited by malicious actors to gain an unfair advantage in the game by analyzing the player's cards before making their decisions.

Impact:

Revealing the player's hand to external callers compromises the integrity of the game.

Proof of Concept:

  1. Deploy the contract and start the game.

  2. Call the playersHand function from an external address while the game is ongoing.

  3. Observe the full details of the player's cards being returned without restriction.

Tools Used:

Manual Review.

Recommended Mitigation:

Implement an access control mechanism to restrict access to the playersHand function. Ensure that only the player owning the hand can view the player's cards during the game.

function playersHand(address player) public view returns (uint256) {
+ require(msg.sender == player);
uint256 playerTotal = 0;
for (uint256 i = 0; i < playersDeck[player].playersCards.length; i++) {
uint256 cardValue = playersDeck[player].playersCards[i] % 13;
if (cardValue == 0 || cardValue >= 10) {
playerTotal += 10;
} else {
playerTotal += cardValue;
}
}
return playerTotal;
}
Updates

Lead Judging Commences

inallhonesty Lead Judge 11 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity

Support

FAQs

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