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.

Add Confirmed Toll Parameter When Sending ETH To Avoid Admin Frontrunning

See original GitHub issue

Problem

The current version of Umbra.sol contract has the following method:

  function setToll(uint256 _newToll) public onlyOwner {
    toll = _newToll;
  }

I believe it can raise some trust concerns: in its current implementation the toll can be changed without users’ awareness.

We can imagine the following scenario:

  1. User sends a transaction with X+T1 as a total amount, where X is intended transfer amount and T is toll
  2. Contract owner sets the toll to T2 (which, for instance, is higher than T1)
  3. A transaction setting the new toll gets mined first
  4. User’s transaction gets mined second, the actual amount transferred to the recipient becomes X+T1-T2

Potential issues:

  • Users’ transactions can be spoiled. For example, if they are processed by an automated payment system, receiving lesser amount would render a payment invalid, which would lead to loosing the funds.
  • It could be seen as a potential attack vector for a contract owner to steal users’ funds. Owner could watch the network for a transaction that transfers a certain amount of ETH, and while the transaction is still in the mempool, they could try to broadcast a transaction changing toll that would get mined before the user’s transaction.

Possible solutions

Getting rid of the toll completely

It seems to be the most simple way of solving the problem. Though probably there are some reasons to leave it (like spam protection, etc), so I think it can be a good opportunity to discuss them and determine the importance of having toll.

Accepting confirmedToll as a sendEth argument

A user would be able to confirm amount of toll they agree to pay. We could check if confirmedToll equals current toll set in the contract and reject a transaction if it doesn’t. This can protect a user from loosing their funds in the described scenario, but we can also keep the toll if it proves to be useful.

Making toll immutable

We could leave it just as a constructor argument, thus removing setToll function and resolving the trust issue.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
apbendicommented, Jan 20, 2021

Great thanks @mds1 and @mvlabat. We will go with this approach!

1reaction
mvlabatcommented, Jan 20, 2021

Hi folks! @apbendi, sorry for missing your question. Yeah, I think that those proposed solutions are also valid options. But I still believe that the confirmedToll parameter is the most simple and secure one among the others that we’ve discussed, so I’ll be absolutely happy if you decide to go with this approach.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Frontrunning - Ethereum Smart Contract Best Practices
The attacker sent multiple transactions with a high gasPrice and gasLimit to custom smart contracts that assert (or use other means) to consume...
Read more >
Slock.it Incubed3 | ConsenSys Diligence
The node can be unregistered and the deposit withdrawn by the owner without the signer 's consent. The signer therefore is in a...
Read more >
Application and evaluation of payment channel in hybrid ...
In this paper, we propose a payment channel based HEX, which extends existing solutions by adding a new payment channel layer to benefit...
Read more >
dev/README.md at main · liquity/dev - GitHub
Liquity is a decentralized protocol that allows Ether holders to obtain maximum liquidity against their collateral without paying interest. After locking up ETH...
Read more >
Blockchain-Based Address Alias System - MDPI
We created a cryptocurrency wallet with a full on-chain solution for aliasing accounts and tokens to improve user experience and avoid unnecessary errors....
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