The QuantAMMPowerChannelLocals struct and _getWeights function within the PowerChannelUpdateRule.sol contract improperly handle the distinction between scalar (q) and vector (vectorQ) values. In the current implementation, when _parameters[1] contains multiple elements (indicating a vector scenario), the code erroneously updates the scalar q instead of the vector vectorQ. This design flaw can lead to Incorrect update and query of struct, attack risks, and compatibility with other components.
The issue arises in the _getWeights function when determining whether the q parameter is a scalar or a vector:
In scalar scenarios, the code correctly sets locals.q to _parameters[1][0].
However, in vector scenarios, instead of updating locals.vectorQ, the loop overwrites the scalar locals.q for each iteration.
Subsequent calculations use the incorrectly updated scalar q, leading to invalid update and query of QuantAMMPowerChannelLocals struct , when _parameters[1] is meant to represent a vector.
Incorrect update and query of the QuantAMMPowerChannelLocals struct: The current implementation contradicts the design intent of distinguishing between scalar and vector Q values.The use of locals.vectorQ is part of the design intention to handle vector scenarios. By misusing locals.q, the code violates this intention, leading to inconsistency and reducing the maintainability of the code.
Attack Risks: Mismanagement of parameters increases the attack surface for malicious actors, who might exploit these inconsistencies to manipulate the pool's behavior.
Compatibility with Other Components: The behavior deviates from the intended functionality as described in the protocol's specifications, potentially breaking compatibility with other components or strategies reliant on the expected weight update mechanics.
Manual Review
It is recommended that locals.q and locals.vectorQ be maintained as separate fields in the QuantAMMPowerChannelLocals struct, with locals.q used for scalar updates and locals.vectorQ for vector-based calculations. This approach ensures easier querying and maintenance of arrays in future updates and interaction with other programs.
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.