Toutes les vulnérabilités
CRITICALWeb3

WEB3-HEDGEY-2024

Web3 · Ethereum · Hedgey Finance

Résumé

On April 19, 2024, Hedgey Finance was drained of about $44.7 million (notional) across Arbitrum (~$42.6 million, mostly BONUS tokens) and Ethereum (~$2.1 million in USDC, ETH and other tokens). The root cause was an unvalidated attacker-controlled address combined with a stale token allowance in the ClaimCampaigns contract. createLockedCampaign granted an ERC-20 allowance via SafeERC20.safeIncreaseAllowance(IERC20(campaign.token), claimLockup.tokenLocker, campaign.amount) without validating that the caller-supplied tokenLocker was a legitimate Hedgey vesting contract, so the attacker passed their own address and obtained spend approval. cancelCampaign then refunded the deposited tokens but never called safeDecreaseAllowance, leaving the dangling allowance live after capital was returned. Funding the deposit with a Balancer flash loan, the attacker looped create-then-cancel to accumulate approvals, then called the token's transferFrom directly to drain funds belonging to other campaigns out of the contract.

Comment l’éviter dans votre code

  • Validate any caller-supplied address (e.g. tokenLocker) against a whitelist of trusted contracts before granting approvals.
  • Revoke allowances on cancel/refund paths with safeDecreaseAllowance to eliminate dangling approvals.
  • Prefer exact-amount, single-use approvals over standing allowances; reset to zero after use.
  • Audit pairs of individually-safe functions for unsafe interactions (create grants, cancel must revoke).
  • Account funds per-campaign so one campaign's transferFrom cannot reach another's deposited balance.

Références

Vulnérabilités liées

Tout Web3 →