Skip to content
Access control Write-up Advanced

Alchemix Access Control Issue Bug Fix Review

The Alchemix Harvester contract's harvest function was callable by anyone through Gelato's permissionless Automate contract, allowing an attacker to set a minimum output of 1 and sandwich the harvest swap for profit. This could steal yield from rETH, stETH, and FraxETH pools.

immunefi.com

Published on immunefi.com

On September 23, 2023, the security researcher Koiush submitted a high vulnerability to Alchemix via Immunefi, which consisted of improper configuration of access control for harvesting of yield.

The author, on immunefi.com

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

The harvest function's access control relied on a permissionless Gelato Automate contract address instead of a dedicated sender, allowing anyone to trigger harvests with arbitrary parameters.

Impact

An attacker could steal yield generated during harvesting in rETH, stETH, and FraxETH pools; at the time of submission, only the rETH adapter was vulnerable to profitable sandwiching.

What the attacker needed

Ability to create a Gelato task; No special access required

The fix

The contracts were redeployed with an Alchemix-controlled EOA set as the gelatoPoker address, replacing the generic Automate contract.

How it was found

  1. Create a Gelato task calling AlchemixHarvester.harvest with minimumAmountOut set to 1.
  2. Trigger the Gelato keeper to execute the harvest.
  3. Front-run the harvest by manipulating the Balancer pool rate up.
  4. After harvest, manipulate the Balancer rate back down to recover collateral and keep a portion of WETH.

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.

The harvest function collects yield from investments, but it could be called by anyone because the access control only checked that the caller was a generic Gelato contract that anyone can use. An attacker could set a very low minimum output and then manipulate the price before and after the harvest to profit at the expense of the protocol.

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.