Pickle Incident: Root Cause Analysis



The Pickle Hack Walk-through

  • Step 1: Query current asset balance: The query via StrategyCmpdDaiV2.getSuppliedUnleveraged() returns the asset balance of 19.72M DAIs
  • Step 2: Exploit input validation bug to withdraw all DAIs from StrategyCmpdDaiV2 to Pickle-Jar: This bug is present in the ControllerV4.swapExactJarForJar() with two given fake Jars. Without validating the given Jars, this step withdraws all invested DAIs back to Pickle-Jar for next-round of deployment.
  • Step 3: Call earn() to deploy withdrawn DAIs back to StrategyCmpdDaiV2. With the internal buffer mangement, the hacker calls earn() three times, resulting in total 950,818,864.82119677 cDAIs minted to StrategyCmpdDaiV2.
  • Step 4: Exploit arbitrary code execution to withdraw all cDAIs from StrategyCmpdDaiV2 to Hacker: This step calls ControllerV4.swapExactJarForJar() but with a different set of crafted arguments to trigger external code execution in the context of ControllerV4. Specifically, the _execute() call at line 316 is triggered to delegatecall the code located at CurveProxyLogic.add_liquidity(), but with the following inputs: curve=StrategyCmpdDaiV2, curveFunctionSig=51cff8d9, curvePoolSize=1, curveUnderlyingIndex=0, underlying=0x8739c55df8ca529dce060ed43279ea2f2e122122. The first arguemnt to CurveProxyLogic.add_liquidity() is typically the curve address. However, it is miused to withdraw cDAI from StrategyCmpdDaiV2 back to ControllerV4 by calling StrategyCmpdDaiV2.withdraw(). Since it is a delegatecall, the StrategyCmpdDaiV2.withdraw() is executed with msg.sender == controller, which is unfortunate. In addition, StrategyCmpdDaiV2.withdraw() only checks want != _asset in line 142 (want is DAI here) which enables the bad actor to withdraw() cDAI. Now, the execution goes back to line 323 in ControllerV4.swapExactJarForJar(), the withdrawn cDAI is then deposited into the malicious _toJar. Inside _toJar.deposit(), all 950,818,864.8211968 cDAI are immediately transferred to the hacker address.
  • Step 5: Redeem cDAIs and walk away with all 19.759M DAIs

The Stolen Funds

About Us




A Blockchain Security Company (https://peckshield.com)

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Sovryn Loan Vulnerability Bugfix Review

Manage File Detection and Use Antimalware Tool in Webroot.com/safe

{UPDATE} Darkness Survival Hack Free Resources Generator

Mobile Money — Replacement for Cash?

Multigaming 145,000ZQB Token Airdrop

Life On Mars’ Tokenomics

Ready to ask the right questions to determine how secure the centralized exchange you trade with is?

Future of Bug Bounties (completely personal opinion)

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store


A Blockchain Security Company (https://peckshield.com)

More from Medium

Introducing Blockpour — Discover your Alpha

Lendefi x Chainlink AMA RECAP

Introducing SafeFarming Option

Introducing MorganDAO, A Decentralised Reserve Currency Protocol