President Elector

First Flight #24
Beginner FriendlyFoundry
100 EXP
View results
Submission Details
Severity: medium
Invalid

Lack of Feedback in `selectPresident()` causes unclear voting results

Summary

The selectPresident() function does not return the address of the selected president causing several issues related to transparency and clarity, especially in a decentralized or voting-based contract where feedback is crucial for the proper operation and interaction with users.

https://github.com/Cyfrin/2024-09-president-elector/blob/fccb8e2b6a32404b4664fa001faa334f258b4947/src/RankedChoice.sol#L60

Vulnerability Details

Currently, the selectPresident() function only updates internal state variables without providing any external feedback on the selected winner, which can make the election process less transparent. Without feedback, users might not be aware of the current status of the vote or who the current president is. The voters or observers of the contract would lack visibility into whether their votes were counted correctly or which candidate has won after the election.

Impact

Users cannot easily determine the election outcome without querying state variables.

Tools Used

Manual review

Recommendations

Modify the selectPresident() function to return the address of the newly selected president:

- function selectPresident() external {
+ function selectPresident() external view returns (address){
....
+ return s_currentPresident;
}
Updates

Lead Judging Commences

inallhonesty Lead Judge 12 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.