Menu

1 / 2

How 1,000 Wei Can Drain Protocol Fees: A Deep Dive into CoW Protocol Rounding Errors

DEV Community·rim dinov·7 months ago
#ijuHFiIy
#web3#security#ethereum#blockchain#protocol
Reading 0:00
15s threshold

During my recent security research into the CoW Protocol (Gnosis Protocol v2), I focused on how the protocol handles fractional settlements. While the protocol is architecturally sound, a classic smart contract pitfall—precision loss—can lead to cumulative fee leakage.

In this post, I’ll show how a malicious solver can exploit integer division in GPv2Settlement to execute trades with zero protocol fees.

The Vulnerability: Death by a Thousand Cuts

The core of the issue lies in how fees are calculated for partiallyFillable orders. In GPv2Order.sol, users can sign orders that allow solvers to fill them in multiple steps.

When a solver executes a partial fill, the protocol calculates the proportional fee using the following formula:

executedFeeAmount=

sellAmount

feeAmount⋅executedAmount

​

Since Solidity doesn't support floating-point numbers, it uses integer division, which always rounds down.

The Attack Vector

A malicious solver can split a large order into thousands of "dust" transactions.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.