Add the concept of pending TokenTransfer
to improve token transaction security
#523
Labels
Milestone
TokenTransfer
to improve token transaction security
#523
Current implementation
Whenever a service needs tokens to be transferred it calls the
TokenHandler
telling it to transfer an arbitraryamount
from the source (from
) to the recipient (to
).Target implementation
Phase 1
The
TokenHandler
no longer acceptsamount-from-to
requests, but instead aTokenTransfer
object is introduced. ATokenTransfer
is a object has more or less then same information (an idand an array of (
from,
to,
amount,
token)s), but the
TokenTransferis no longer directly passed to the
TokenHandler. Instead the TokenHandler is aware of the
Instanceand
TokenTransfers are stored in the instance instead. The
TokenHandlernow only accepts a transfer
id` as an argument to execute a token transfer.When a service needs to execute a token transfer is first creates the
TokenTransfer
object and stores it in theInstanceStore
. Then to execute the transfer, the service initiates the transfer by providing theid
to theTokenHandler
. TheTokenHandler
will then look up the transfer instructions in theInstanceStore
and execute the transaction(s).This implementation removes the possibility of an attacker executing an arbitrary token transfer (think
open allowance
to theTokenHandler
) by calling theTokenHandler
with a very large amount. Only preparedTokenTransfer
s can be executed.And furthermore, the storage of the
TokenTransfer
allows the outside world to inspect a pending transfer before its being executed (assuming the product is implemented in a way that, e.g. policy creation and transfer of the tokens do no happen in a single transactions).Security considerations
TODO: This section probably needs some more thoughts to ensure it cannot be maliciously used to execute arbitrary token transfers.
Its important that
TokenHandler
s do not blindly executeTokenTransfer
s, but ensure that only theTokenHandler
s of the component that created it can execute it. So it's necessary to also store whichTokenHandler
is allowed to execute a transfer described by theTokenTransfer
object. Also its required that the insertion ofTokenTransfer
s into theInstanceStore
is secure and no unauthorized entity can just do that (the address of the authorizedTokenHandler
needs to be double checked during insertion to ensure if from the currently active component).Phase 2
This concept can be taken a step further by introducing signed
TokenTransfer
s. The user can now inspect the pendingTokenTransfer
before its executed and sign it. The product would then be required to allow thesignature
as an attribute to the transfer call. TheTokenHandler
can now verify this signature and only execute theTokenTransfer
if the signature matches.A quick doodle of the concept - probably not 100% correct (to be replaced)
The text was updated successfully, but these errors were encountered: