question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

fix(security): close DDoS vulnerability in eth tx consistenty strategy

See original GitHub issue

Description

The application performs some repetitive tasks in a loop and defines the number of times to perform the loop according to user input. A very high value could cause the application to get stuck in the loop and to be unable to continue to other operations.

Affected files are all the eth flavored connector plugins that have the consistencyStrategy request parameter when executing transactions.

  • packages/cactus-plugin-ledger-connector-besu/src/main/typescript/plugin-ledger-connector-besu.ts
  • packages/cactus-plugin-ledger-connector-xdai/src/main/typescript/plugin-ledger-connector-xdai.ts
  • packages/cactus-plugin-ledger-connector-quorum/src/main/typescript/plugin-ledger-connector-quorum.ts
    do {
      tries++;
      timedOut = Date.now() >= startedAt.getTime() + timeoutMs;
      if (timedOut) {
        break;
      }

      txReceipt = await this.web3.eth.getTransactionReceipt(txHash);
      if (!txReceipt) {
        continue;
      }

      const latestBlockNo = await this.web3.eth.getBlockNumber();
      confirmationCount = latestBlockNo - txReceipt.blockNumber;
    } while (confirmationCount >= consistencyStrategy.blockConfirmations);

Impact

An attacker could input a very high value, potentially causing a denial of service (DoS).

Remediation Recommendation

Don’t base a loop on loosely validated user-provided data. The range should be limited. Always include a maximum value for each user input in the openapi.json specs.

Change the maximum for allowed block count to 20 thousand (a little over what the ethereum main net confirms in a 72 hour period according to the latest statistics at time of this writing: https://ycharts.com/indicators/ethereum_blocks_per_day

Breaking Change Discussion

Fixing this will be a breaking change, because previously valid requests will now get rejected by the API server. An argument could be made that it’s only a breaking change for those who were previously sending malicious requests and for no one else and therefore it is not really a breaking change even though it technically is.

@izuru0 @takeutak @jagpreetsinghsasan Please weigh in on the question presented in Breaking Change Discussion

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
jagpreetsinghsasancommented, May 11, 2022

Thanks @petermetz for descriptive reasoning. And I agree 100% with the fact that, layering the security measures is the best way out.

1reaction
petermetzcommented, May 10, 2022

Can we fix it by having a specified time delay in-between requests instead of limiting the range?

@jagpreetsinghsasan A rate-limiter would be a partial solution because it can be defeated. For example if it rate limits based on IP address then one can use a set of proxies to avoid it entirely. With that said, everything else is also just a partial solution because nothing eliminate the possibility of DoS completely. It is a cat and mouse game that has to be played forever.

Layering defenses is almost always a good idea, so IMO the strongest protection would be to do both.

Read more comments on GitHub >

github_iconTop Results From Across the Web

HackPedia: 16 Solidity Hacks/Vulnerabilities, their Fixes ...
The Vulnerability. This attack can occur when a contract sends ether to an unknown address. An attacker can carefully construct a contract at...
Read more >
Vulnerabilities, Attacks, and Defenses - A Survey on Ethereum ...
A Survey on Ethereum Systems Security: Vulnerabilities, Attacks, and Defenses A Survey ... The consensus layer assures a consistent state of the blockchain....
Read more >
Preventing DDoS Attacks with P2P Systems through ...
VULNERABILITIES IN P2P SYSTEMS. In this paper, we focus on DDoS attacks triggered by exploiting the membership management algorithms of peer-to-peer systems ...
Read more >
Understanding and Discovering Attacks on Ethereum ...
To understand the values of our findings, we designed an exploit discovery methodology, called DEFIER (Dapp Ex- ploit Investigator), to find more attack ......
Read more >
3 ways to prevent DDoS attacks on networks
If an organization suffers a DDoS attack, the financial and network damage can be disastrous. Explore the top three ways for how to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found