This function is used by the account with the ALLOCATOR_ROLE
to set an allowance to an account but given the current implementation the function can be front runned.
The vulnerable line in the function is:
This line of code only replaces the old allocation with a new one and it can be exploited in the following scenario:
The spender has set up a listener to subscribe to new transaction sent to the mempool
The allocator decides to reduce the allowance and submits the transaction
The bot of the spender scan the new transaction and decodes the data
field to determine if it is a transaction to reduce the allocation
If it is, it front runs the transaction by simply sending a transaction with a higher maxPriorityFeePerGas
to get his transaction processed first
Both transaction are picked up and included in a block
Let's say Bob gave an allocation of 100 tokens to Alice and later decided to reduce it to 50. Alice performs the attack detailed above and spend the 100 tokens of the original allowance and get a new allowance of 50. This give the possibility to Alice to access 150 tokens of Bob.
I was unable to determine where in the protocol the allocated funds can be spent or withdrawn, but it clear this is the intend of the function, for that reason I determined the impact to be: transaction front runned the attacker can spent more tokens with a HIGH severity.
Manual review
I recommend implementing a mechanism like OpenZeppelin's increaseAllowance
and decreaseAllowance
to protect against frontrunning, these functions instead of overwriting the old allowance they increase or reduce the allocation by an amount. Aossible implementation of these function could be:
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.