permitAndMulticall() May Be Used to Steal Funds Or as a Denial Of Service if _from Is Not The Message Sender
The permitAndMulticall function allowed an attacker to use a victim's permit signature to call multicall on behalf of the attacker, potentially redirecting delegated funds or causing a denial of service by consuming the victim's nonce. The actual impact was limited to denial of service and misdirecting delegation, not direct theft.
Originally disclosed on Code4rena
Submitted by kirk-baird, also found by cmichel and Omik
Line References
PermitAndMulticall.sol#L46-L64 PermitAndMulticall.sol#L31-L37 TWABDelegator.sol#L438-L445
Vulnerability details
When the _from address is not the msg.sender _multiCall() will be made on behalf of the msg.sender. As a result each of the functions called by multiCall() will be made on behalf of msg.sender and not _from.
If functions such as transfer() or unstake() are called msg.sender will be the original caller which would transfer the attacker the funds if the to 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
function _multicall(bytes[] calldata _data) internal virtual returns (bytes[] memory results) {
results = new bytes[](_data.length);
for (uint256 i = 0; i < _data.length; i++) {
results[i] = Address.functionDelegateCall(address(this), _data[i]);
}
return results;
}
function _permitAndMulticall(
IERC20Permit _permitToken,
address _from,
uint256 _amount,
Signature calldata _permitSignature,
bytes[] calldata _data
) internal {
_permitToken.permit(
_from,
address(this),
_amount,
_permitSignature.deadline,
_permitSignature.v,
_permitSignature.r,
_permitSignature.s
);
_multicall(_data);
}
Recommended Mitigation Steps
Consider updating the _from field to be the msg.sender in permitAndMulticall() (or alternatively do this in _permitAndMulticall() to save some gas).
function permitAndMulticall(
uint256 _amount,
Signature calldata _permitSignature,
bytes[] calldata _data
) external {
_permitAndMulticall(IERC20Permit(address(ticket)), msg.sender, _amount, _permitSignature, _data);
}
PierrickGT (PoolTogether) confirmed and resolved:
PR: https://github.com/pooltogether/v4-twab-delegator/pull/29
PierrickGT (PoolTogether) disagreed with Medium severity and commented:
Should be labelled as a 3 (High Risk) issue because an attacker could steal the funds.
0xleastwood (judge) commented:
I’m not exactly sure how this might be abused to steal funds. By front-running a call
permitAndMulticall()with the same_fromaccount, an attacker is able to use up the user’s nonce and DoS their transactions. However, an attacker CAN control the_dataparsed to the_multicall()function and delegate call to theTWABDelegator.solcontract. Although, in this casemsg.senderwill 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.senderand_slot.Could you confirm if there is a viable attack vector that would result in lost funds? @PierrickGT
PierrickGT (PoolTogether) commented:
You are right, the only attack vector possible would be with the
updateDelegateefunction since an attacker could pass a_delegateeaddress and we compute the delegation with the passed_delegatorparam. https://github.com/pooltogether/v4-twab-delegator/blob/60ae14e11947f8c896c1fef8f4d19ee714719383/contracts/TWABDelegator.sol#L265Funds 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 thedisagree with severitylabel.
0xleastwood (judge) commented:
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.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the function did not verify that the _from address (the permit signer) matched the msg.sender, allowing the caller to execute multicall actions on their own behalf instead of the signer's.
Impact
The attacker could cause a denial of service by front-running permitAndMulticall to consume the victim's nonce, and could redirect the victim's delegation to an attacker-controlled address, but funds were not directly at risk.
What the attacker needed
Attacker can front-run transactions; victim has a valid permit signature
The fix
The fix was to update the _from field to be msg.sender in permitAndMulticall, as confirmed by the project.
How it was found
- Attacker obtains a victim's valid permit signature (e.g., by observing the mempool).
- Attacker calls permitAndMulticall with the victim's _from address and signature, but with attacker-controlled _data.
- The permit consumes the victim's nonce, making the signature invalid for future use.
- The multicall executes on behalf of the attacker (msg.sender), potentially calling functions like updateDelegatee to redirect the victim's delegation to the attacker.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
This is a smart contract bug where a function that combines a permit (a signature-based approval) and a multicall (multiple actions in one transaction) did not check that the person submitting the transaction was the same as the person who signed the permit. An attacker could take someone else's signed permit and use it first, which would make the original transaction fail because the permit can only be used once. This is like someone else using your one-time coupon before you do, so you can't use it.
What is Access control?
A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.