Skip to content

Latest commit

 

History

History
46 lines (24 loc) · 1.91 KB

File metadata and controls

46 lines (24 loc) · 1.91 KB

Blunt Alabaster Kookaburra

Medium

Incompatibility of FullMath Library with Solidity's Overflow Protection

Summary

The FullMath library, adapted for Teller's protocol from Uniswap V3, fails to handle overflows correctly under Solidity ≥0.8.0. This causes execution to revert during critical calculations when intermediate values exceed the 256-bit limit, disrupting the intended functionality of the library.

Root Cause

The original FullMath library in UniswapV3 was designed for Solidity <0.8.0, where overflows were not automatically checked. https://github.com/Uniswap/v3-core/blob/main/contracts/libraries/FullMath.sol But in Teller protocol, the FullMath library has been adapted from Uniswap V3 for use with Solidity ≥0.8.0. https://github.com/sherlock-audit/2024-11-teller-finance-update/blob/0c8535728f97d37a4052d2a25909d28db886a422/teller-protocol-v2-audit-2024/packages/contracts/contracts/libraries/uniswap/FullMath.sol#L2

With Solidity ≥0.8.0, overflow checks are enforced, causing reversion in calculations that rely on the "phantom overflow" behavior of the original library.

This effectively means that when a phantom overflow (a multiplication and division where an intermediate value overflows 256 bits) occurs the execution will revert and the correct result won't be returned.

Internal pre-conditions

No response

External pre-conditions

No response

Attack Path

No response

Impact

Execution reverts during calculations requiring intermediate overflows

PoC

No response

Mitigation

Replace the current FullMath implementation with the 0.8 version in the Uniswap repository.