Skip to content
This repository has been archived by the owner on Apr 28, 2024. It is now read-only.

0xMaroutis - Misuse of Old Borrowing key instead of New Key in takeOverDebt Function #182

Closed
sherlock-admin2 opened this issue Oct 23, 2023 · 0 comments
Labels
Duplicate A valid issue that is a duplicate of an issue with `Has Duplicates` label High A valid High severity issue Reward A payout will be made for this issue

Comments

@sherlock-admin2
Copy link
Contributor

sherlock-admin2 commented Oct 23, 2023

0xMaroutis

medium

Misuse of Old Borrowing key instead of New Key in takeOverDebt Function

Summary

The function takeOverDebt seems to mistakenly use the borrowingKey (which is the old key) instead of the expected newBorrowingKey in the _addKeysAndLoansInfo method. This can lead to unexpected behavior and potential DoS vulnerabilities, as the platform relies on a specific key format.

Vulnerability Detail

The function takeOverDebt is responsible for managing borrowing positions. During its execution, a new borrowing position is initialized or updated using the _initOrUpdateBorrowing function, which returns a new borrowing key (newBorrowingKey). However, subsequent actions are performed using the old borrowing key (borrowingKey), leading to inconsistencies in data storage and retrieval.

Specifically, in the line:

_addKeysAndLoansInfo(newBorrowing.borrowedAmount > 0, borrowingKey, oldLoans);

The borrowingKey (old key) is used instead of the newBorrowingKey. Given that the platform expects keys in the format:
borrowingKey = Keys.computeBorrowingKey(msg.sender, saleToken, holdToken);
This inconsistency can lead to unexpected behavior, data corruption, or potential denial-of-service vulnerabilities.

Impact

The mismanagement of borrowing keys can lead to:

  • Inaccurate tracking of borrowing positions.
  • Potential data corruption, making certain positions inaccessible.
  • Potential DoS attacks if an adversary can manipulate or predict key generation.
  • User mistrust due to unpredictable platform behavior.

The impact is high, especially for users who can only use the front-end portal to execute the trades.

Code Snippet

https://github.com/sherlock-audit/2023-10-real-wagmi/blob/main/wagmi-leverage/contracts/LiquidityBorrowingManager.sol#L441

Tool used

Manual Review

Recommendation

Update the takeOverDebt function to use the newBorrowingKey in the _addKeysAndLoansInfo method :

_addKeysAndLoansInfo(newBorrowing.borrowedAmount > 0, newBorrowingKey, oldLoans);

Duplicate of #53

@github-actions github-actions bot added High A valid High severity issue Duplicate A valid issue that is a duplicate of an issue with `Has Duplicates` label labels Oct 26, 2023
@sherlock-admin2 sherlock-admin2 changed the title Ancient Frost Albatross - Misuse of Old Borrowing key instead of New Key in takeOverDebt Function 0xMaroutis - Misuse of Old Borrowing key instead of New Key in takeOverDebt Function Oct 30, 2023
@sherlock-admin2 sherlock-admin2 added the Reward A payout will be made for this issue label Oct 30, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Duplicate A valid issue that is a duplicate of an issue with `Has Duplicates` label High A valid High severity issue Reward A payout will be made for this issue
Projects
None yet
Development

No branches or pull requests

1 participant