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
The issue here is that decimals is being passed to getTokenPrice(), which appears to be using it to calculate the token price. There are a few issues here:
If decimals is 18, it's like requesting the price of 18 token units instead of 1 unit.
last_lsttokenvalueWei is initialized based on the oracle price in the constructor but then used in many critical functions without being updated frequently enough. For instance:
function getMaxBorrow() publicviewreturns (uint256) {
// ...uint resultToken = FullMath.mulDiv(
resultEth,
decimals,
last_lsttokenvalueWei //@audit-issue Using stale price
);
// ...
}
......
function liquidateNumaBorrower(...) {
// ...uint minBorrowAmountAllowPartialLiquidationNuma = vaultManager.tokenToNuma(
minBorrowAmountAllowPartialLiquidation,
last_lsttokenvalueWei, //@audit-issue Using stale price
decimals,
criticalScaleForNumaPriceAndSellFee
);
// ...
}
If we assume decimals name is misleading and it actually refers to quantity of token based on the getTokenPrice function:
function getTokenPrice(uint256_amount) externalviewreturns (uint256) {
returntokenToEth(
_amount,
feed,
chainlink_heartbeat,
IERC20Metadata(token).decimals() //@audit the decimals of the token is fetched here
);
}
there are still some other issues:
Stale Price issue:
function buyNoMax(...) internal {
uint256 numaAmount = vaultManager.tokenToNuma(
_inputAmount,
last_lsttokenvalueWei, // Still using price from constructor
decimals, // Amount used for price calculation
criticalScaleForNumaPriceAndSellFee
);
}
The price is still only set once in the constructor and used throughout the contract's lifetime.
2) Potential Price Manipulation:
function getMaxBorrow() publicviewreturns (uint256) {
// ...uint resultToken = FullMath.mulDiv(
resultEth,
decimals, // Using amount instead of proper scaling
last_lsttokenvalueWei // Using stale price
);
// ...
}
Using a stale price makes the system vulnerable to price manipulation.
3) Inconsistent Reference Amount:
// In constructor
last_lsttokenvalueWei = oracle.getTokenPrice(decimals); // Price for decimals amount// In liquidationfunction liquidateNumaBorrower(...) {
uint minBorrowAmountAllowPartialLiquidationNuma = vaultManager.tokenToNuma(
minBorrowAmountAllowPartialLiquidation, // Different amount
last_lsttokenvalueWei, // Price based on different amount
decimals,
criticalScaleForNumaPriceAndSellFee
);
}
Root Cause
The way of setting the variables last_lsttokenvalueWei and decimals in NumaVault.sol :
Any external function call that uses the mentioned variables
Attack Path
Whenever a call happens to buy /sell or any other functions that are related to decimals and last_lsttokenvalueWei , the user or platform will be affected.
Impact
There are a bunch of different impacts:
Potential price Manipulation
Price Staleness
The stale prices may lead to Over/Under-collateralization
Incorrect liquidation triggers
Loss of funds
PoC
No response
Mitigation
It is not clear what is the intended usage of decimals. Based on the usage of decimals make the necessary adjustment for both variables so that the mentioned issues above do not exist.
The text was updated successfully, but these errors were encountered:
Rapid Tin Ram
High
Potential issues with
decimals
andlast_lsttokenvalueWei
in Vault contract may break the core functionalitiesSummary
The variables
last_lsttokenvalueWei
anddecimals
in NumaVault.sol are defined as :as it can be seen
decimals
seem to refering the decimals of lst token. and it is set in the constructor as follow:The issue here is that decimals is being passed to
getTokenPrice()
, which appears to be using it to calculate the token price. There are a few issues here:decimals
is 18, it's like requesting the price of 18 token units instead of 1 unit.last_lsttokenvalueWei
is initialized based on the oracle price in the constructor but then used in many critical functions without being updated frequently enough. For instance:If we assume
decimals
name is misleading and it actually refers toquantity of token
based on the getTokenPrice function:there are still some other issues:
The price is still only set once in the constructor and used throughout the contract's lifetime.
2) Potential Price Manipulation:
Using a stale price makes the system vulnerable to price manipulation.
3) Inconsistent Reference Amount:
Root Cause
The way of setting the variables
last_lsttokenvalueWei
anddecimals
in NumaVault.sol :Internal pre-conditions
The admin deploys the Vault contract
External pre-conditions
Any external function call that uses the mentioned variables
Attack Path
Whenever a call happens to buy /sell or any other functions that are related to
decimals
andlast_lsttokenvalueWei
, the user or platform will be affected.Impact
There are a bunch of different impacts:
Potential price Manipulation
Price Staleness
The stale prices may lead to Over/Under-collateralization
Incorrect liquidation triggers
Loss of funds
PoC
No response
Mitigation
It is not clear what is the intended usage of
decimals
. Based on the usage ofdecimals
make the necessary adjustment for both variables so that the mentioned issues above do not exist.The text was updated successfully, but these errors were encountered: