The setRuleForPool function within the UpdateWeightRunner.sol contract of the QuantAMM protocol lacks adequate access controls, permitting any external entity to assign or modify update rules for arbitrary pools.
This is the code for UpdateWeightRunner::setRuleForPool:
Inadequate Access Control
Unrestricted Access: The setRuleForPool function is marked as external, allowing any external address to invoke it. There are no checks to verify if the caller (msg.sender) is an authorized pool contract.
Lack of Caller Verification: The function solely checks if a rule is already set for the caller and validates the provided oracles. It does not confirm whether the caller is a legitimate pool deployed via the trusted factory.
Potential for Malicious Rule Assignment: Without restricting access, malicious actors can register fake pools with arbitrary or harmful rules, disrupting the protocol's intended behavior.
Vulnerability
Lack of Authorized Caller Verification:
Since the function is external and lacks restrictions, any EOA or contract can call setRuleForPool.
Unauthorized pool configuration:
Malicious actors can deploy arbitrary contracts and invoke setRuleForPool, registering them as legitimate pools with custom update rules.
These fake pools can manipulate weights, skew liquidity distributions, and disrupt normal trading operations within the protocol.
Economic exploits:
By setting extreme or malicious weight update rules, attackers can create scenarios that drain liquidity, cause excessive slippage, or disrupt the balance of assets within legitimate pools.
Users may face financial losses, and the overall trust in the protocol could be eroded, leading to reduced adoption and potential insolvency of pools.
Denial of Service (DoS):
Attackers could set computationally intensive rules or flood the protocol with malicious pools, consuming excessive gas and rendering the protocol unusable.
Legitimate users and pools may experience failed transactions, increased gas costs, and halted trading activities.
The following demonstrates how an unauthorized caller can exploit the setRuleForPool function to register a malicious pool.
Malicious Pool Contract:
Deploy MaliciousPool with the address of the UpdateWeightRunner.
Invoke registerMaliciousRule from MaliciousPool
The protocol now contains a pool with an invalid oracle configuration, potentially causing failed weight updates or other unintended behaviors.
If the malicious rule contract is designed to exploit specific functionalities, it can manipulate pool weights to the attacker's advantage.
Code review, Foundry, Chatpgt-o1, Claud3.5, Github copilot, slither, aderyn, Solidity Metrics
setRuleForPool in UpdateWeightRunner.sol:Implement comprehensive checks to validate the integrity and compatibility of the provided PoolSettings, ensuring that rules and oracles are correctly configured.
UpdateWeightRunner, mitigating risks of unauthorized pool registrationsPlease 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.