The setWeightsManually
function has an issue that allows the new weights check to be bypassed if _numberOfAssets
are 0.
This issue arises because the loop condition that validates _weights
depends on _numberOfAssets
, so if the _numberOfAssets
are set 0 a _weights
can be set greater than 1e18.
The function setWeightsManually
is called by Owner and it accepts _numberOfAssets
as a parameter, which is used to validate the _weights
array.
But this check can be bypassed simply by specifying _numberOfAssets
as 0 and set _weights
greater than 1e18.
In simple words this check has no effect and can be bypassed easily.
POC: Add this in UpdateWeightRunner.t.sol
Result:
If _numberOfAssets
is set to 0, the condition i < _numberOfAssets
is never true, and none of the weights are validated.
This bypass allows to set invalid weights that could destabilize the system or manipulate the pool.
This vulnerability can lead to:
bypass of Weight Validation a high weights negative weights or weights exceeding the allowed range can be passed unchecked.
system Instability Invalid weights could disrupt the balance of assets in the pool, potentially leading to financial losses or breaking the intended functionality.
Retrieve numberOfAssets
from the Pool replace the _numberOfAssets
parameter with a value weight.length devided by 2
because each weight array == number of tokens * 2.
Please read the CodeHawks documentation to know which submissions are valid. If you disagree, provide a coded PoC and explain the real likelyhood and the detailed impact on the mainnet without any supposition (if, it could, etc) to prove your point.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.