HydraDX-node icon indicating copy to clipboard operation
HydraDX-node copied to clipboard

Bug: [Audit_RV] sell does not check whether the exchanged assets are equal.

Open virgil-serbanuta opened this issue 3 years ago • 1 comments

The sell endpoint does not check that the in and out assets are distinct. At the same time, it loads the asset data for both assets near the start of the function, and it will update the state for both at the end of the function.

This likely means that:

  1. The asset state will be first set to the “in asset state”, then it will be overwritten with the “out asset state”.
  2. The out asset state will just register an exchange of some LRNA for the asset, instead of an exchange of the asset for itself.

If the above is accurate, then the asset state no longer corresponds to reality. Besides being bad in itself, this increases the amount of LRNA in the asset state, ~~while at the same decreasing the amount of asset, both~~ by a value roughly equal to the exchanged amount. This would allow users to increase the asset prices by a fair amount in exchange for paying the transaction fees. This may be useful either directly, if they sell the manipulated asset for something else (e.g., the stable asset), or in case another contract relies on the exchange price for decisions (e.g. loans).

virgil-serbanuta avatar Aug 11 '22 20:08 virgil-serbanuta

The same probably applies to the buy function.

virgil-serbanuta avatar Aug 11 '22 20:08 virgil-serbanuta

Fixed in #437

enthusiastmartin avatar Sep 01 '22 08:09 enthusiastmartin