Skip to content
This repository has been archived by the owner on Sep 18, 2020. It is now read-only.

withdraws can be burned by relayers through setting very high gas price #112

Closed
snd opened this issue Jan 31, 2018 · 3 comments · Fixed by #114
Closed

withdraws can be burned by relayers through setting very high gas price #112

snd opened this issue Jan 31, 2018 · 3 comments · Fixed by #114
Assignees

Comments

@snd
Copy link
Contributor

snd commented Jan 31, 2018

thanks to @bjornwgnr for finding this

problem

given a ForeignBridge.CollectedSignatures event that has not yet
been relayed i.e. doesn't have a matching HomeBridge.Withdraw.

anyone can call HomeBridge.withdraw to relay the withdraw.
this is by design. HomeBridge.withdraw only trusts the list of authorities.
signatures of those authorities (on the message) are passed to withdraw.

as with any transaction the sender of withdraw can freely choose the gas price.
currently (introduced by #77) estimatedGasCostOfWithdraw * tx.gasPrice
is subtracted from the withdrawn value and transfered to sender to pay
for the relay.

since the transaction sender can freely choose the gas price they can burn a users withdraw by setting an extremely high gas price.

solution

add additional param homeGasPrice to
ForeignBridge.transferHomeViaRelay so the interface looks like
ForeignBridge.transferHomeViaRelay(recipient, value, homeGasPrice).

end user can easily find out a gas price on something like https://ethgasstation.info/.

add homeGasPrice to message that is signed and relayed.

then in HomeBridge.withdraw(vs, rs, ss, message)
require require(tx.gasPrice == homeGasPrice) forcing the sender of
the withdraw to use the user specified gas price.

this solution has other nice properties:

we now know the homeGasPrice on foreign since it's provided by the enduser.
so we can require require(estimatedGasCostOfWithdraw * homeGasPrice > value)
in Foreign.transferHomeViaRelay and revert such withdraws that
don't have enough value to pay for the relay.
this improves UX since such withdraws are currently ignored by bridge processes
which, while being well documented and sensible, can lead to confusion.

the homeGasPrice is documented in the ForeignBridge.Withdraw event
so it's transparent if the relay transaction doesn't get mined on home
because of too low a gas price.

end users now have control over the cost/latency tradeoff of their relay through
the homeGasPrice.

edge case

provided gas price is too low and transaction doesn't get mined.

in HomeBridge.withdraw we could allow only recipient to change the gas price
by changing the require to require(recipient == msg.sender || tx.gasPrice == homeGasPrice).
now the recipient can manually rescue by providing a new gas price and paying it
themselves.

@snd snd added the F2-bug label Jan 31, 2018
@snd snd changed the title withdraws can be burned by relayers by setting very high gas price withdraws can be burned by relayers through setting very high gas price Jan 31, 2018
@tomusdrw
Copy link
Contributor

Looks good! I really like the edge case solution as well.

@snd snd added the P2-asap label Jan 31, 2018
@snd snd self-assigned this Jan 31, 2018
snd added a commit that referenced this issue Jan 31, 2018
snd added a commit that referenced this issue Feb 9, 2018
@snd snd closed this as completed in #114 Feb 15, 2018
snd added a commit that referenced this issue Feb 15, 2018
fix #112 - users were able to burn value during withdraw
@Ri2k18
Copy link

Ri2k18 commented Aug 6, 2018

Hi I have Eth address for parity signer, how can I use my eth there if I forgot my recovery phrase
Plese help me. Thanks

@snd
Copy link
Contributor Author

snd commented Aug 6, 2018

hey @Ri2k18, please ask your question again in the right repo https://github.com/paritytech/parity-signer

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants