You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on May 26, 2023. It is now read-only.
Only one attack will lead to two types of vulnerabilities in UserManager.sol and UToken.sol
Vulnerability Detail
On UserManager.sol ==> updateTrust()
Case one:
malicious users (members) can keep vouching Alice with trustAmount == 0 until his vouchers array achieves the max limit (2**256-1)
So when a normal member tries to give vouching to Alice with trustAmount != 0 he will find because the vouchers array completely full.
Case two (which is more realistic ):
malicious users (members) can keep vouching Alice with trustAmount == 0 until his vouchers array achieves late’s say 20% of max limit (2**256-1)
The problem is when Alice invoke borrow() or repayBorrow() on UToken.sol
function updateLocked(
addressborrower,
uint96amount,
boollock
) external onlyMarket {
uint96 remaining = amount;
for (uint256 i =0; i < vouchers[borrower].length; i++) {
The for loop could go through vouchers[] which could be long enough to lead to a "gas limit DoS via unbounded operations"
And the same thing with registerMember(), any user could lose all their fund in this transaction
function registerMember(addressnewMember) publicvirtual whenNotPaused {
if (stakers[newMember].isMember) revertNoExistingMember();
uint256 count =0;
uint256 vouchersLength = vouchers[newMember].length;
// Loop through all the vouchers to count how many active vouches there// are that are greater than 0. Vouch is the min of stake and trustfor (uint256 i =0; i < vouchersLength; i++) {
Impact
1- The user couldn’t get any more vouching
2- The user will be not able to borrow() or repayBorrow()
3- No one can in invokeregisterMember() successfully for a specific user
uint256 vouchersLength = vouchers[newMember].length;
// Loop through all the vouchers to count how many active vouches there// are that are greater than 0. Vouch is the min of stake and trustfor (uint256 i =0; i < vouchersLength; i++) {
Some minimal trustAmount looks to be needed here as the same can be repeated with dust amounts (say 1 wei, as the attacker pays gas anyway, so financially it will not matter).
Ch_301
medium
gas limit DoS via unbounded operations
Summary
Only one attack will lead to two types of vulnerabilities in
UserManager.sol
andUToken.sol
Vulnerability Detail
On
UserManager.sol
==>updateTrust()
Case one:
malicious users (members) can keep
vouching
Alice withtrustAmount == 0
until hisvouchers
array achieves the max limit (2**256-1)So when a normal member tries to give
vouching
to Alice withtrustAmount != 0
he will find because thevouchers
array completely full.Case two (which is more realistic ):
malicious users (members) can keep
vouching
Alice withtrustAmount == 0
until hisvouchers
array achieves late’s say 20% of max limit (2**256-1)The problem is when Alice invoke
borrow()
orrepayBorrow()
onUToken.sol
It will call
updateLocked()
onUserManager.sol
The for loop could go through
vouchers[]
which could be long enough to lead to a "gas limit DoS via unbounded operations"And the same thing with
registerMember()
, any user could lose all their fund in this transactionImpact
1- The user couldn’t get any more
vouching
2- The user will be not able to
borrow()
orrepayBorrow()
3- No one can in invoke
registerMember()
successfully for a specific userCode Snippet
https://github.com/sherlock-audit/2022-10-union-finance/blob/main/union-v2-contracts/contracts/user/UserManager.sol#L555
https://github.com/sherlock-audit/2022-10-union-finance/blob/main/union-v2-contracts/contracts/user/UserManager.sol#L807
https://github.com/sherlock-audit/2022-10-union-finance/blob/main/union-v2-contracts/contracts/user/UserManager.sol#L637-L641
Tool used
Manual Review
Recommendation
Add check for
trustAmount == 0
The text was updated successfully, but these errors were encountered: