QuantAMM

QuantAMM
49,600 OP
View results
Submission Details
Severity: low
Invalid

Insufficient Access Control in `calculateMultiplierAndSetWeightsFromRule()` Allows Unauthorized Weight Manipulation

Summary

The access control mechanism in UpdateWeightRunner::calculateMultiplierAndSetWeightsFromRule() is insufficient as it relies on a pool's self-registered rule address for authorization, which can be manipulated by any pool.

Vulnerability Details

There are two key issues:

  1. The function checks msg.sender == address(rules[params.poolAddress]) for authorization, but any pool can call setRuleForPool() to register an arbitrary address as its rule. This means a malicious pool could:

    • Register a malicious contract as its rule

    • Use that contract to call calculateMultiplierAndSetWeightsFromRule()

    • Bypass the intended access control

  2. The function checks poolRegistry() directly from the pool contract instead of using the centralized approvedPoolActions mapping. This allows pools to potentially manipulate their own registry flags.

The relevant code:

require(msg.sender == address(rules[params.poolAddress]), "ONLYRULECANSETWEIGHTS");
uint256 poolRegistryEntry = QuantAMMWeightedPool(params.poolAddress).poolRegistry();
require(poolRegistryEntry & MASK_POOL_RULE_DIRECT_SET_WEIGHT > 0, "FUNCTIONNOTAPPROVEDFORPOOL");

Impact

Manipulation of pool weights leading to:

  • Manipulate token ratios

  • Create arbitrage opportunities

  • Potentially drain pool funds through price manipulation

Tools Used

  • Manual review

Recommendations

  1. Add rule address validation in setRuleForPool():

mapping(address => bool) public approvedRules;
function setRuleForPool(...) {
require(approvedRules[_poolSettings.rule], "Rule not approved");
// existing code
}
  1. Use the centralized approvedPoolActions mapping instead of calling poolRegistry():

function calculateMultiplierAndSetWeightsFromRule(...) {
require(msg.sender == address(rules[params.poolAddress]), "ONLYRULECANSETWEIGHTS");
require(approvedPoolActions[params.poolAddress] & MASK_POOL_RULE_DIRECT_SET_WEIGHT > 0, "FUNCTIONNOTAPPROVEDFORPOOL");
// remaining code
}
Updates

Lead Judging Commences

n0kto Lead Judge 7 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity
Assigned finding tags:

Informational or Gas / Admin is trusted / Pool creation is trusted / User mistake / Suppositions

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.

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.