Skip to content
DoS Audit finding Intermediate

Using permit inside the function can lead to Do

The contract's internal token-taking function calls an ERC2612 permit, which is permissionless, so an attacker can front-run the transaction by submitting the same signature directly. This makes the original transaction revert, causing a denial of service that could temporarily or permanently freeze funds.

Stiglitz Follow

Originally disclosed on Immunefi

Informational View original
  • Disclosed after under an hour

29244 - [SC - Insight] Using permit inside the function can lead to Do...

Submitted on Mar 11th 2024 at 22:47:53 UTC by @stiglitz for Boost | ZeroLend

Report ID: #29244

Report type: Smart Contract

Report severity: Insight

Target: https://github.com/zerolend/governance

Impacts:

  • Temporary freezing of funds for at least 1 hour
  • Permanent freezing of funds
  • Griefing (e.g. no profit motive for an attacker, but damage to the users or the protocol)

Description

Brief/Intro

The abstract contract BaseLPVault implements the function _takeTokens.

Solidity
function _takeTokens(uint256 amount, PermitData memory permit) internal {
    if (permit.deadline > 0) {
        IERC2612(address(zero)).permit(
            msg.sender,
            address(this),
            permit.value,
            permit.deadline,
            permit.v,
            permit.r,
            permit.s
        );
    }
    zero.transferFrom(msg.sender, address(this), amount);
}

The function is not used anywhere because the codebase is not fully and completely implemented. However, if this function is called with permit.deadline > 0, the call can be front-runned by an attacker calling the permit function directly and causing DoS.

Vulnerability Details

ERC2612 permit function is a permissionless function. Front-running direct permit calls is not a problem because the action of the function will be the same no matter who is the msg.sender

The problem is when the permit function is used as a part of another function. In this scenario, an attacker can monitor the mempool and if he spots the call that will execute the functions which contain permit call, he will extract signature data and call the permit function directly.

Now, because the signature is already used, it will revert the original transaction, and the code following .permit call won't be executed.

Impact Details

DoS, which can be temporary or longer lasting if there is no walk-around for the specicif execution flow.

References

It is exactly the scenario described by Trust: https://www.trust-security.xyz/post/permission-denied

Proof of Concept

As it is a known issue, I believe the blog post from Trust Security (https://www.trust-security.xyz/post/permission-denied) is sufficient proof of the existence of the vulnerability. In case it is not I can provide PoC

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

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 contract relies on a one-time-use permit signature inside a multi-step function without protecting against front-running, so an attacker can consume the signature first.

Impact

An attacker could cause a denial of service that temporarily or permanently freezes funds, depending on whether there is a workaround for the specific execution flow.

What the attacker needed

Victim submits a transaction using permit; attacker can see pending transactions

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 move your tokens without you sending a separate approval transaction. Here the contract uses a permit inside a larger function, but because anyone can submit that signed message, an attacker can submit it first. When the real user's transaction arrives, the signature is already used up, so it fails and the intended action never happens.

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 Stiglitz

View all

5 more disclosed reports, best first.

More from ZeroLend

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.