depositWithPermit and mintWithPermit are allowed to be called by the permit creator only
The depositWithPermit and mintWithPermit functions use msg.sender as the permit owner, so only the signer can call them. This prevents other contracts from executing these functions on behalf of a signer, breaking the intended permit workflow.
rvierdiiev Follow with xuwinnie
Originally disclosed on Code4rena
Submitted by rvierdiiev, also found by xuwinnie
Functions depositWithPermit and mintWithPermit are allowed to be called by the permit creator only. Not any other contracts will be able to execute these function on behalf of signer.
Proof of Concept
The depositWithPermit function is allowed to provide a signed permit in order to receive, approve and deposit funds into the vault.
function depositWithPermit(
uint256 _assets,
address _receiver,
uint256 _deadline,
uint8 _v,
bytes32 _r,
bytes32 _s
) external returns (uint256) {
_permit(IERC20Permit(asset()), msg.sender, address(this), _assets, _deadline, _v, _r, _s);
return deposit(_assets, _receiver);
}
This function calls _permit and pass msg.sender as _owner to that function.
function _permit(
IERC20Permit _asset,
address _owner,
address _spender,
uint256 _assets,
uint256 _deadline,
uint8 _v,
bytes32 _r,
bytes32 _s
) internal {
_asset.permit(_owner, _spender, _assets, _deadline, _v, _r, _s);
}
This means, that the signer can be only the same person that called depositWithPermit function.
However, the purpose of the permit is to allow someone to sign the approve signature, so that this signature can be used by another contract to call some function on behalf of signer.
In this case, anyone should be able to sign permit for the vault, and vault should check that _receiver is same who signed permit.
Tools Used
VsCode
Recommended Mitigation Steps
Use _receiver instead of msg.sender.
function depositWithPermit(
uint256 _assets,
address _receiver,
uint256 _deadline,
uint8 _v,
bytes32 _r,
bytes32 _s
) external returns (uint256) {
_permit(IERC20Permit(asset()), _receiver, address(this), _assets, _deadline, _v, _r, _s);
return deposit(_assets, _receiver);
}
Assessed type
Error
asselstine (PoolTogether) confirmed
Fixed permit implementations. PR: https://github.com/GenerationSoftware/pt-v5-vault/pull/20
Status: Mitigation confirmed. Full details in report from dirk_y, rvierdiiev and 0xStalin.
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 passes msg.sender as the permit owner instead of the intended receiver, so only the caller's own signature is accepted.
Impact
Other contracts cannot execute depositWithPermit or mintWithPermit on behalf of a signer, limiting the permit functionality to direct callers only.
What the attacker needed
None
The fix
The code was fixed by using _receiver instead of msg.sender as the permit owner.
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.
A permit is a signed message that lets someone else spend your tokens without you sending a separate approval transaction. Here, the vault only accepts permits signed by the person calling the function, so a third party cannot use a user's signed permit to deposit on their behalf. This makes the feature less useful than intended.
What is Business logic?
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.