Skip to content
Smart contracts Write-up Advanced

Harvest Finance Uninitialized Proxies Bug Fix Review 200k Bounty

Three uninitialized implementation contracts behind Harvest Finance proxies could be initialized by anyone, allowing an attacker to set a malicious hard-worker contract and trigger self-destruction of the implementation, rendering the proxies useless and putting $6.4M at risk.

immunefi.com

Published on immunefi.com

Software development is an iterative process, and mistakes can happen at any time. That’s why, in the practice of developing software, there is usually a team of QA Engineers — who act as a second pair of eyes for developers.

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 implementation contracts were left uninitialized, so an attacker could call the initializer to become owner and then set a malicious hard-worker contract that executes SELFDESTRUCT via DELEGATECALL.

Impact

The implementation contract could be destroyed, making the proxy contracts useless and putting $6.4M in Uniswap V3 positions at risk; the text does not state that funds were actually stolen.

What the attacker needed

Uninitialized implementation contract; ability to call the initializer; ability to set the hard-worker field

The fix

The proxies were repointed to implementation contracts that cannot be self-destructed by untrusted callers.

How it was found

  1. Call the initializer on the implementation contract to become its owner.
  2. Deploy a malicious contract that calls SELFDESTRUCT.
  3. Set the hard-worker storage field to that malicious contract.
  4. Call doHardWork() to trigger the delegatecall and destroy the implementation.

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.

Smart contracts on a blockchain cannot normally be changed, so developers use a 'proxy' contract that forwards calls to a separate 'implementation' contract that can be swapped out. If that implementation contract is left uninitialized, anyone can become its owner and point it at a malicious contract that destroys it, breaking the proxy for everyone.

What is Smart contracts?

Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.

Similar reports

View all

Same bug class and techniques, clearest first.

Smart contract vulnerabilities

The lesson behind this report.

Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.