Fix (audit AUR-11): Infinite Amounts Can Be Transferred to One’s Self #15
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
After Sigma Prime Aurora Engine and Eth-Connector audit, was detected potential issue: AUR-11 - Infinite Amounts Can Be Transferred to One’s.
Details
Balance checks are performed in the function
internal_transfer_eth_on_near()
. The following snippet of the functionft_transfer_call()
show how the balance checks are skipped ifsender_id == receiver_id
.The impact is not significant to the current contract as the net balances and total supply remain unchanged. However, this poses a potential threat to third party contracts.
ft_transfer_call()
makes the external callreceiver_id.ft_on_transfer(amount, msg, sender_id)
. Since we are able to set amount as any arbitrary value thismay lead to issues in the accounting of third party contracts.
Solution
Added extra verification in
ft_transfer_call
, for the casesender_id == receiver_id
:amount > 0
balance_of_sender >= amount
Gas cost
Not changed
How to review
Pay attention to
ft_transfer_call
methodTests
Extended to check the balance for
sender_id
, whensender_id == receiver_id
inft_transfer_call
.