The `getPriceInWeth()` function relies on external TSwap pools to provide price data without any validation. If the oracle returns incorrect prices (zero, extremely high, or manipulated values), the fee calculations will be incorrect, potentially leading to loss of funds or denial of service.
The oracle function doesn't validate return values:
```solidity
function getPriceInWeth(address token) public view returns (uint256) {
address swapPoolOfToken = IPoolFactory(s_poolFactory).getPool(token); // @> No validation if pool exists
return ITSwapPool(swapPoolOfToken).getPriceOfOnePoolTokenInWeth(); // @> No validation of return value
}
```
This price is then used in fee calculations:
```solidity
function getCalculatedFee(IERC20 token, uint256 amount) public view returns (uint256 fee) {
//slither-disable-next-line divide-before-multiply
uint256 valueOfBorrowedToken = (amount * getPriceInWeth(address(token))) / s_feePrecision; // @> Uses unvalidated price
//slither-disable-next-line divide-before-multiply
fee = (valueOfBorrowedToken * s_flashLoanFee) / s_feePrecision;
}
```
If the oracle returns:
- Zero: Fee becomes zero, protocol loses revenue
- Extremely high value: Fee becomes prohibitively high, breaking flash loans
- Manipulated value: Attacker could manipulate fees
Likelihood:
* This occurs whenever `getCalculatedFee()` is called (on every deposit and flash loan)
* If the TSwap pool is compromised, manipulated, or returns invalid data, the protocol is affected
* No validation means any return value is accepted
Impact:
* Incorrect fee calculations leading to protocol revenue loss or user overpayment
* Potential denial of service if fees become too high
* Manipulation of fees through oracle manipulation
* Could lead to economic attacks on the protocol
The contest is live. Earn rewards by submitting a finding.
Submissions are being reviewed by our AI judge. Results will be available in a few minutes.
View all submissionsThe contest is complete and the rewards are being distributed.