Skip to content
Business logic Audit finding Intermediate

Permit doesn’t work with DAI

The depositWithPermit function in PrizeVault.sol calls the permit function with parameters that do not match DAI's permit signature, which includes a nonce and a boolean allowed flag. As a result, permit-based deposits with DAI or sDAI will revert, preventing users from using the signed-message deposit feature.

carrotsmuggler Follow with 0xabhay, Timenov and 1 other

Originally disclosed on Code4rena

Submitted by carrotsmuggler, also found by 0xabhay, Timenov, and Omik

The function depositWithPermit in the PrizeVault.sol contract is used with permit options so that users can submit a signed message. They then can use that to give allowance to the contract to extract the tokens required for the deposit.

IERC20Permit(address(_asset)).permit(_owner, address(this), _assets, _deadline, _v, _r, _s);

The issue is that the test suite shows that the protocol aims to use sDAI, the dai savings rate, but the DAI token’s permit signature is different. From the contract at address 0x6B175474E89094C44Da98b954EedeAC495271d0F, we see the permit function:

function permit(address holder, address spender, uint256 nonce, uint256 expiry,
                    bool allowed, uint8 v, bytes32 r, bytes32 s) external

Due to the missing nonce field, DAI, a token which allows permit based interactions, cannot be used with signed messages for depositing into sDAI vaults. Due to the wrong parameters, the permit transactions will revert.

Proof of Concept

It is evident from the code that the permit function call does not match the signature of DAI’s permit function.

Recommended Mitigation Steps

For the special case of DAI token, allow a different implementation of the permit function which allows a nonce variable.

Assessed type

Token-Transfer

trmid (PoolTogether) acknowledged and commented:

This is indeed a valuable insight and issue to be acknowledged, but no mitigation will be applied since the depositWithPermit function is meant as a quality of life improvement for depositors and adding additional logic to it’s operation could introduce unexpected vulnerabilities.

Infect3d (warden) commented:

@hansfriese, I think this submission should be considered as QA. A deposit function is made available, meaning there is still a possibility for users to deposit DAI (requiring them to approve first manually, which can be managed by the front-end UX as in most dApps already).

Based on the C4 severity categorization, a medium severity require either a loss of funds, or to impact the availability of the protocol, which is not the case thanks to the simple deposit.

hansfriese (judge) commented:

2 — Med: Assets not at direct risk, but the function of the protocol or its availability could be impacted, or leak value with a hypothetical attack path with stated assumptions, but external requirements.

While deposit() can be used instead of depositWithPermit(), I still believe Medium is eligible due to the potential dysfunctionality of the primary function.


The original report as published on Code4rena, by carrotsmuggler. Images and videos are our own copies; raw HTML is shown as text. View it on Code4rena.

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

The contract calls a fixed permit signature that does not match DAI's non-standard permit function, which requires a nonce and an allowed flag.

Impact

Users cannot use the permit-based deposit path with DAI or sDAI, though a separate deposit function remains available, so funds are not directly at risk.

What the attacker needed

DAI or sDAI as the vault asset; user relies on depositWithPermit

The fix

The report recommends adding a special case for DAI that uses its different permit implementation, but the project acknowledged the issue and chose not to apply a mitigation.

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.

Some tokens let you approve spending with a signed message instead of a separate transaction. This is called permit. The vault's depositWithPermit function assumed every token uses the same permit format, but DAI uses a different one, so the approval fails and the deposit reverts.

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.

More by carrotsmuggler

View all

42 more disclosed reports, best first.

More from PoolTogether

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.