core/txpool/legacypool: Fix overdraft DoS attack in the legacy pool#33492
core/txpool/legacypool: Fix overdraft DoS attack in the legacy pool#33492ehdus829 wants to merge 2 commits into
Conversation
|
We fixed the test coverage to properly account for the cumulative cost when submitting transactions in batch mode.
|
|
Hi, to better understand the attack, could you share the code you used to perform the PoC? Also, since functions like promoteExecutables in queue.go currently check overdrafts based only on the current on chain balance, it might be better to update both for consistency. |
|
Hey team, both versions of the PoC (the remote PoC and the local testing PoC) are fully completed. We can share the PoC with the Ethereum team anytime (we’ve also shared it before via the Ethereum bug bounty program). But we have some concerns about sharing the PoC in a public PR. Therefore, we’d like to hear the team’s thoughts on the preferred way to share it before moving forward. |
|
@rjl493456442 Should we request an additional code review? We're also wondering what the plan is for merging. |
|
Since the previous conversation thread was related to an earlier patch version, I close that thread and resend the patch review provided above in this thread. I revised the patch so that the queue cost delta is added on top of the existing This patch should effectively mitigate the overdraft attack. When a transaction is first added in a batch state, the queue total cost is stored as a snapshot. When a subsequent transaction is added, even though the first transaction is already in the queue, its cost is added to the Below are additional considerations to ensure that this patch does not interfere with normal transaction behavior: Considerations
Additionally, while implementing this patch, I updated the test cases that were failing so that they now align with the intended behavior. Please let me know if you have any feedback after reviewing the patch. |
An attacker can perform an overdraft attack by sending transactions in a batch state over the P2P network. This allows the attacker to evict other pending transactions from the txpool.
This vulnerability occurs because the overdraft-checking logic inside the
ValidateTransactionWithStatefunction does not take batch-state transactions into account.Within this function, only the spending cost of pending transactions is considered. However, for batch-state transactions, the transactions are first moved into the queue state via the
enqueueTxfunction, and only after all loops finish are they promoted to the pending state through therequestPromoteExecutablesfunction.As a result, an attacker can submit a series of batched transactions over the P2P network whose total value exceeds what the attacker can actually afford, causing them to be registered as pending transactions and pushing out other legitimate pending transactions from the txpool.
We have fully validated this issue using both local test code and a remotely exploitable PoC. This issue has already been reported through the Ethereum bug bounty program, and we are submitting this PR following a request to do so. Applying the patch included in this PR mitigates the described scenario.