Skip to content
DoS Audit finding Intermediate

Vault.mintWithPermit() can be DoS’d

The mintWithPermit function approves an exact asset amount derived from the share amount, but the exchange rate can change before the transaction is mined, causing the permit signature to fail and the function to revert. An attacker could front-run to manipulate the exchange rate and cause a denial of service for legitimate users.

KupiaSec Follow with dirk_y

Originally disclosed on Code4rena

Submitted by KupiaSec, also found by dirk_y

Lines of code

https://github.com/GenerationSoftware/pt-v5-vault/tree/b1deb5d494c25f885c34c83f014c8a855c5e2749/src/Vault.sol#L466-L469 https://github.com/GenerationSoftware/pt-v5-vault/tree/b1deb5d494c25f885c34c83f014c8a855c5e2749/src/Vault.sol#L971-L974 https://github.com/GenerationSoftware/pt-v5-vault/tree/b1deb5d494c25f885c34c83f014c8a855c5e2749/src/Vault.sol#L882-L887

Impact

Vault.mintWithPermit() uses a signature to approve the underlying asset. But the asset amount can be changed easily, so this method can be reverted and might be DoS’d.

Proof of Concept

Vault.mintWithPermit() gets the share amount as an input and calculates the asset amount from the share. Then, it approves the asset amount with permit method.

    uint256 _assets = _beforeMint(_shares, _receiver);

    _permit(IERC20Permit(asset()), msg.sender, address(this), _assets, _deadline, _v, _r, _s);
    _deposit(msg.sender, _receiver, _assets, _shares);

The signature is generated using the exact value of the expected asset amount calculated from the share amount, and the resulting asset amount depends on the exchange rate of current vault.

  function _beforeMint(uint256 _shares, address _receiver) internal view returns (uint256) {
    if (_shares > maxMint(_receiver)) revert MintMoreThanMax(_receiver, _shares, maxMint(_receiver));
    return _convertToAssets(_shares, Math.Rounding.Up);
  }
  function _convertToAssets(
    uint256 _shares,
    Math.Rounding _rounding
  ) internal view virtual override returns (uint256) {
    return _convertToAssets(_shares, _currentExchangeRate(), _rounding);
  }

The resulting asset amount can be different from the value of transaction start time. Even an adversary can front-run and manipulate the exchange rate. If the resulting asset amount is different from the original one, the signature will not work as expected and mintWithPermit() will revert in most cases.

Recommended Mitigation Steps

We can input an upper bound of the asset amount instead of the exact value of the asset amount.

Assessed type

DoS

asselstine (PoolTogether) confirmed

asselstine marked the issue as sponsor confirmed

PoolTogether mitigated:

Removed mintWithPermit. PR: https://github.com/GenerationSoftware/pt-v5-vault/pull/15

Status: Mitigation confirmed. Full details in reports from dirk_y, rvierdiiev and 0xStalin.


The original report as published on Code4rena, by KupiaSec. 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

Likely the permit signature commits to an exact asset amount that is derived from a mutable exchange rate, so any change in the rate invalidates the signature.

Impact

A user's mintWithPermit transaction could be made to revert, causing a denial of service; the text does not claim loss of funds.

What the attacker needed

Attacker can front-run transactions; exchange rate is manipulable

The fix

The function was removed as 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.

This is a smart contract function that lets someone deposit tokens using a signed permission slip (a permit) instead of a separate approval transaction. The amount in the slip is calculated from the current exchange rate, which can change before the transaction is processed, so the slip no longer matches and the deposit fails. An attacker can deliberately change the rate first, blocking the user's deposit.

What is DoS?

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.

More by KupiaSec

View all

28 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.

Denial of service

The lesson behind this report.

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.