Skip to content
Business logic Audit finding Intermediate

Ability to deny users from repaying and supplyi

The pool's repayWithPermit and supplyWithPermit functions forward a user's ERC20 permit signature to the token contract, so an attacker who sees the signature in the mempool can submit it first. The attacker's call consumes the nonce, making the victim's repay or supply transaction revert.

OceanAndThunders Follow

Originally disclosed on Immunefi

  • Disclosed after under an hour

29069 - [SC - Medium] Ability to deny users from repaying and supplyi...

Submitted on Mar 6th 2024 at 14:21:15 UTC by @OceanAndThunders for Boost | ZeroLend

Report ID: #29069

Report type: Smart Contract

Report severity: Medium

Target: https://explorer.zksync.io/address/0x54d6F91bE4509826559ad12E1Ca6CA3A6C3811e0

Impacts:

  • Griefing (e.g. no profit motive for an attacker, but damage to the users or the protocol)

Description

Hello team,

Brief/Intro

The repayWithPermit and supplyWithPermit functions on pool contract "0x54d6F91bE4509826559ad12E1Ca6CA3A6C3811e0" uses the permit function for external ERC20 contract, an attacker can front run the permit function , thus the pool.repayWithPermit and pool.supplyWithPermit will automatically reverts, allows a chain call/transaction all be griefed

Vulnerability Details

The pool contract "0x54d6F91bE4509826559ad12E1Ca6CA3A6C3811e0" allows the user to supply with permit to external contract by providing the permit hash to pool.repayWithPermit, this later will call external token with the given permit bytes, the functions repayWithPermit and supplyWithPermit will revert if the attacker front runs the token.permit with the victim's bytes, the first call will succeed and consumes the nonce, thus the pool.repayWithPermit (the original call) will revert then, the call/transaction will be reverted all the way

Impact Details

Denying users from using the pool.repayWithPermit and pool.supplyWithPermit properly

References

Example explanation of the issue : https://www.trust-security.xyz/post/permission-denied

Proof of concept :

In this test "https://github.com/zerolend/core-contracts/blob/146f7bc50b8b9850cf9048989cd734e51c400b48/test-suites/pool-l2.spec.ts#L382" include this line at 411 (as the attacker called the permit before the protocols call usdc.permit) :

// extracteting v, r, s from the mempool and calling the usdc.permit before pool.repayWithPermit
//the usedc.permit call should succeed, thus it will rsults for the pool.repayWithPermit call failure
await usdc.permit(deployer.address,l2Pool.address,amount.toString(),highDeadline,v,r,s);

This will makes the function reverts !

Regards,

Adam

The original report as published on Immunefi, by OceanAndThunders. 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 pool forwards the user's permit signature to the token contract without protecting against front-running, so whoever submits it first consumes the nonce.

Impact

Users can be prevented from repaying or supplying through the permit-based functions, causing griefing with no profit for the attacker.

What the attacker needed

Attacker can see pending transactions; victim uses repayWithPermit or supplyWithPermit

The fix

The permit-based functions should be designed so a front-run permit does not make the user's call revert, for example by handling an already-used permit gracefully or using a different flow.

How it was found

  1. Observe the victim's permit signature and parameters in the mempool.
  2. Call the token's permit function with those values before the victim's transaction.
  3. The attacker's call succeeds and uses up the nonce.
  4. The victim's repayWithPermit or supplyWithPermit then reverts.

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 a separate approval transaction. Because the signature is visible before it is used, another person can submit it first; the token then marks it as used, so your own transaction fails. This lets an attacker block repayments and deposits without gaining any money.

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 OceanAndThunders

View all

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

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.