The _setRule function lacks explicit reentrancy protection mechanisms, such as the nonReentrant modifier or similar safeguards.This absence creates potential vulnerabilities, especially given its reliance on:
External Calls:
_poolSettings.rule.initialisePoolRuleIntermediateValues is an external call, which might invoke untrusted or malicious contracts.
The setRuleForPool function in updateWeightRunner is another external call, exposing the system to reentrancy if the UpdateWeightRunner contract is compromised or implemented insecurely.
State Updates:
Critical state variables (lambda, epsilonMax, absoluteWeightGuardRail, etc.) are updated after external calls. This sequencing leaves the contract in an inconsistent state during those calls, making it susceptible to exploitation.
If a malicious contract gains control during an external call:
Intermediate State Manipulation:
It could trigger reentrant calls to manipulate state variables or force invalid configurations, such as bypassing require checks.
Oracle Exploitation:
Malicious oracles could exploit their integration via _poolSettings.rule.initialisePoolRuleIntermediateValues to provide manipulated data.
It could trigger reentrant calls to manipulate state variables or force invalid configurations, such as bypassing require checks.
Malicious oracles could exploit their integration via _poolSettings.rule.initialisePoolRuleIntermediateValues to provide manipulated data.
Reentrancy attacks can compromise the contract's integrity.
Manual Code Review
Use OpenZeppelin’s ReentrancyGuard: Add the ReentrancyGuard library to the contract and apply the nonReentrant modifier to _setRule.
Reorder State Updates and External Calls: Perform state updates before making external calls:
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.