Submitted by dontonka, also found by csanuragjain and zhaojie
The function GetVoterIndex is used in multiple places to get the index of a specific Observer from the Voter List. The problem is that the caller is assuming the function will always succeed, but clearly there is a possibility where the Observer address could not be found, which would return an index of -1, which will effectivelly make the program panic.
This one is safe since the GetVoterIndex is called from the same ballot instance it is iterating over, so its impossible to not find the index in such case.
https://github.com/code-423n4/2023-11-zetachain/blob/main/repos/node/x/observer/keeper/ballot.go#L94
Safe, for the same reason as instance 1.
https://github.com/code-423n4/2023-11-zetachain/blob/main/repos/node/x/observer/types/ballot.go#L82 
https://github.com/code-423n4/2023-11-zetachain/blob/main/repos/node/x/observer/types/ballot.go#L92
Even if this is public function, its actually a private one and only used by AddVote, so share the same risk.
https://github.com/code-423n4/2023-11-zetachain/blob/main/repos/node/x/observer/types/ballot.go#L22
This is the one that carries some risks. This is called by AddVoteToBallot which is then called in 6 differents places (VoteOnObservedInboundTx, VoteOnObservedOutboundTx, CreateTSSVoter 1, CreateTSSVoter 2, AddBlameVote and AddBlockHeader), with the ballot instance and address being looked at coming in different parameters and from different sources, so here there is posibility the issue could occur.
https://github.com/code-423n4/2023-11-zetachain/blob/main/repos/node/x/observer/types/ballot.go#L16
Here is a PoC when using AddBlockHeader, but there might be other cracks coming from the 5 other places I identified for Instance 4 where this code path can be activated.
In order to demostrate my point explained before, I coded it in the following unit test. With the original code it will panic, while by adding my recommendation it will not and recover.
The probability of the indicated negative impacts happening as soon as UpdateObserver is pretty high depending on the blockchain activity (and ballot currently in progress), but calling UpdateObserver should not happen often and can only be triggered by the Admins Group2 (multi-sig).
Granted that the scenario exposed in my PoC might be rare, I havent taken the time to investigate all the other coner cases where this code path can be activated, which raise doubts on the frequency such scenario can happen which is another reason why it should be mitigated.
I would recommend todo the following changes in order to fix the panic in HasVoted and AddVote at least which seems to present some risks. That will not resolve the issue that impacted ballot might never been able to finalize. A way to mitigate this would be to update also the ballot when updating the observer address.
0xean (Judge) decreased severity to Medium and commented:
lumtis (ZetaChain) confirmed and commented:
For this audit, 20 reports were submitted by wardens detailing low risk and non-critical issues. The report highlighted below by dontonka received the top score from the judge.
The following wardens also submitted reports: IllIllI, MevSec, 0x6980, PNS, ciphermarco, Al-Qa-qa, ChaseTheLight, hihen, oakcobalt, SAQ, QiuhaoLi, codeslide, lsaudit, Bauchibred, Kaysoft, Topmark, cartlex_, p0wd3r, and Sathish9098.
