Skip to content
Business logic Audit finding Intermediate

# [M-04] voucherIndexes is not updated when member cancel the voucher

When a member cancels a voucher, the voucherIndexes mapping for the last voucher is not updated, leaving an incorrect index that points to a voucher with a different staker. This could be exploited by malicious members to cause incorrect indexing.

ast3ros Follow

Originally disclosed on Sherlock

Source: https://github.com/sherlock-audit/2023-02-union-judging/issues/39

Found by

ast3ros

Summary

When staker or borrower cancel the voucher, the voucherIndexes for the lastVoucher is not updated.

Vulnerability Details

The voucherIndexes is not updated when a voucher is cancelled.

Impact

It leads to incorrect index for the last voucher, which points to another voucher with different staker. It could be a point to be exploit by malicious members.

Code Snippet

https://github.com/sherlock-audit/2023-02-union/blob/main/union-v2-contracts/contracts/user/UserManager.sol#L593-L605

Tool used

Manual

Recommendation

Add update voucherIndexes in the _cancelVouchInternal function, below line 604 of UToken.sol:

        voucherIndexes[borrower][lastVoucher.staker] = removeVoucherIndex.Idx

Discussion

kingjacob

https://github.com/unioncredit/union-v2-contracts/pull/105 PR also fixes the related 4,31,41,39

dmitriia

Looks ok

The original report as published on Sherlock, by ast3ros. Images and videos are our own copies; raw HTML is shown as text. View it on Sherlock.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the _cancelVouchInternal function fails to update the voucherIndexes mapping for the last voucher after removing a voucher.

Impact

It leads to incorrect index for the last voucher, which points to another voucher with different staker. It could be a point to be exploit by malicious members.

What the attacker needed

Member can cancel a voucher

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

A voucher is like a record that links a borrower to a staker. The system keeps an index (a list) of these vouchers. When a voucher is cancelled, the index for the last voucher in the list is not updated, so it points to the wrong staker. This could let someone misuse the incorrect index.

What is Business logic?

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.

More by ast3ros

View all

14 more disclosed reports, best first.

More from Union Finance Update

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.