Open code423n4 opened 2 years ago
Should be labelled as a 3 (High Risk) issue cause an attacker could steal the funds.
I'm not exactly sure how this might be abused to steal funds. By front-running a call permitAndMulticall()
with the same _from
account, an attacker is able to use up the user's nonce and DoS their transactions. However, an attacker CAN control the _data
parsed to the _multicall()
function and delegate call to the TWABDelegator.sol
contract. Although, in this case msg.sender
will be the attacker and not the delegatee.
As such, any call to transfer a delegation to another account will fail as the delegation is computed based off msg.sender
and _slot
.
Could you confirm if there is a viable attack vector that would result in lost funds? @PierrickGT
Could you confirm if there is a viable attack vector that would result in lost funds? @PierrickGT
You are right, the only attack vector possible would be with the updateDelegatee
function since an attacker could pass a _delegatee
address and we compute the delegation with the passed _delegator
param.
https://github.com/pooltogether/v4-twab-delegator/blob/60ae14e11947f8c896c1fef8f4d19ee714719383/contracts/TWABDelegator.sol#L265
Funds wouldn't be at risk but delegated to the attacker address.
So I think the 2 (Med Risk)
label makes sense in this case since funds are not directly at risk but the attacker would enjoy better odds of winning.
I've removed the disagree with severity
label.
As per the above comment, I will leave this as 2 (Med Risk)
. The exploit does not lead to a loss of funds but can be abused to DoS this functionality and enjoy better odds of winning.
Lines of code
https://github.com/pooltogether/v4-twab-delegator/blob/2b6d42506187dd7096043e2dfec65fa06ab18577/contracts/PermitAndMulticall.sol#L46-L64 https://github.com/pooltogether/v4-twab-delegator/blob/2b6d42506187dd7096043e2dfec65fa06ab18577/contracts/PermitAndMulticall.sol#L31-L37 https://github.com/pooltogether/v4-twab-delegator/blob/2b6d42506187dd7096043e2dfec65fa06ab18577/contracts/TWABDelegator.sol#L438-L445
Vulnerability details
Impact
When the
_from
address is not themsg.sender
_multiCall()
will be made on behalf of themsg.sender
. As a result each of the functions called bymultiCall()
will be made on behalf ofmsg.sender
and not_from
.If functions such as
transfer()
orunstake()
are calledmsg.sender
will be the original caller which would transfer the attacker the funds if theto
field is set to an attackers address.Furthermore, if an attacker we to call
permitAndMulticall()
before the_from
user they may use their signature and nonce combination. As a nonce is only allowe to be used once the siganture will no longer be valid and_permitToken.permit()
will fail on the second call.An attacker may use this as a Denial of Service (DoS) attack by continually front-running
permitAndCall()
using other users signatures.Proof of Concept
Recommended Mitigation Steps
Consider updating the
_from
field to be themsg.sender
inpermitAndMulticall()
(or alternatively do this in_permitAndMulticall()
to save some gas).