Skip to content

Rounding error in Curation allows tax evasion

High
pcarranzav published GHSA-p4j4-4h8c-rrc6 Feb 20, 2024

Package

Graph Protocol Contracts (Smart Contracts)

Affected versions

<= 6.0.0

Patched versions

6.2.1

Description

Description

There's a rounding error in L2 Curation that allows for exploiters to pay zero tax while minting signal on subgraphs.

Attack

On L2Curation.sol when depositing less than 100 wei GRT the function tokensToSignal will calculate 0 tax to be paid because of a rounding down error:

uint256 curationTax = _tokensIn.mul(uint256(curationTaxPercentage)).div(MAX_PPM);

When MAX_PPM > _tokensIn.mul(uint256(curationTaxPercentage)) curation tax will be 0. While nobody will want to curate such small amounts it introduces the possibility for attackers to repeatedly exploit this vulnerability until they reach the desired signal without incurring in any tax deduction.

L1 Note

While the same code vulnerability exists on L1 the current protocol configuration has minimumCurationDeposit set to 1 GRT (equal to 1e18) so the round down to 0 will never happen.

Solution

We calculate the tax to be paid first and then calculate the amount of signal generated by subtracting the tax from the deposit tokens.

Severity

High

CVE ID

No known CVE

Weaknesses

No CWEs