Description:
The mulDiv()
function in OpenZeppelin's Math.sol (v5.1.0) uses a bitwise XOR (^) operator instead of exponentiation (**) in the calculation of the modular inverse:
This is incorrect as the intention appears to be exponentiation (squaring) rather than bitwise XOR. The XOR operation will produce incorrect results for the inverse calculation.
Impact:
Incorrect calculation of modular inverse
Potential security implications in functions relying on this calculation
Could lead to incorrect results in any contract using this math utility
High severity as it affects core mathematical operations
Recommended Mitigation:
Replace the XOR operator (^) with the exponentiation operator (**):
Impact: High (mathematical correctness)
Likelihood: Medium (always occurs when this code path is executed)
Severity: HIGH
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.