Skip to content
Access control Write-up Advanced

[web3] Critical bug in Deri found by riptide

The finishLiquidate function in Deri's Gateway contract lacks the nonce check present in other finish functions, allowing an attacker to reuse a signed remove-margin request to force a liquidation. This lets the attacker steal funds from the victim's margin vault and corrupt the protocol's cumulative PnL state.

mirror.xyz

Published on mirror.xyz

I recently discovered a critical vulnerability in Deri which allows an attacker to forcefully liquidate a trader’s position and steal his precious computer coins from his margin vault.

The author, on mirror.xyz

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the finishLiquidate function does not verify or increment a request nonce, and it decodes event data using a struct with a different field order than the one used for remove-margin requests, causing a margin amount to be misinterpreted as a profit value.

Impact

An attacker could force-liquidate a trader's position and steal up to about $91k USDC per attempt, with total user funds at risk estimated at $500k to $1.5mm across chains, and corrupt the protocol's cumulative PnL state.

What the attacker needed

A signed remove-margin request from any user; ability to call finishLiquidate directly; no whitelisted liquidator role needed

How it was found

  1. Obtain a valid signed eventData and signature from a legitimate requestRemoveMargin call.
  2. Call finishLiquidate directly with that eventData and signature, bypassing the whitelisted liquidator requirement.
  3. The function decodes the data incorrectly, treating requiredMargin as cumulativePnlOnEngine.
  4. The inflated PnL leads to a large liquidation reward being transferred to the attacker.
  5. The victim's position NFT is burned and their margin is lost.

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 write-up has not been written yet. The Original tab links to the source.

A user asked to remove some of their money, and the system signed a message approving that request. The attacker took that same signed message and fed it to a different function that performs liquidations, which did not check if the message had already been used. Because the data was interpreted differently, the attacker triggered a fake liquidation and walked away with a large reward.

What is Access control?

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.

Similar reports

View all

Same bug class and techniques, clearest first.

Broken access control

The lesson behind this report.

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.