Auditor
Smart Contract Engineer
Security Engineer
Solidity
cancelVouch
doesn't update the voucher index of the last vouch of a borrower properlycancelVouch
doesn't update the index of the last vouch in the corresponding mappings when it is moved in the Vouch array of a borrower. It leads to members not being able to cancel their vouch and members potentially cancelling other people vouch.cancelVouch
: UserManager.sol#L583-L634lastVoucher
to the index of the voucher we are removing in the voucher[borrower]
array.voucher[borrower]
array.voucherIndexes[borrower][staker]
.voucherIndexes[borrower][lastStaker.staker]
and in vouchees[lastStaker.staker][voucheeIdx].voucherIndex
.voucherIndexes
mapping is used to derive a voucheeIdx
which is therefore a voucher index and not a vouchee index. Then there is second problem, vouchees[staker][voucheeIdx].voucherIndex
is updated instead of vouchees[lastStaker.staker][voucheeIdx].voucherIndex
. UserManager.sol#L602-L604cancelVouch
will revert if the length of the Vouch array associated to this borrower is not as long anymore. Specifically at this line:vouchers
mapping.Posted Jul 12, 2023
2nd place to Union Finance V2 Sherlock's contest: cancelVouch doesn't update the voucher index of the last vouch of a borrower properly
0
12
Auditor
Smart Contract Engineer
Security Engineer
Solidity