Decoding Palmswap’s $900k Exploit

Updated at: June 5, 20244 Mins Read

Author: QuillAudits Team


On the 25th of July 2023, the Palmswap on the Binance Smart Chain was attacked. The attack was made possible by a Price Manipulation vulnerability. And around $900k was stolen by the exploiter from the exploit.

About Project

Palmswap is a decentralized leverage trading platform. To learn more about them, check out their documentation.

Vulnerability Analysis & Impact

On-Chain Details

Attacker Address: 0xF84efA8a9F7E68855CF17EAaC9c2f97A9d131366

Victim Contract: 0x55252A6D50BFAd0E5F1009541284c783686F7f25

Attack Transaction: 0x62dba55054fa628845fecded658ff5b1ec1c5823f1a5e0118601aa455a30eac9

The Root Cause

  • The root cause of the exploit was the mishandling of calculations when adding or removing liquidity from the pool. It was present in the exchange rate between USDP(Palm Usd) and PLP(Palm Lp).
  • The process of calculation of PLP price when we remove liquidity is handled by getAum() function.
process of calculation of PLP price
  • Now take a look at buyUSDP(). As you can see, the highlighted functions are called to increase the price of PLP when buying USDP.
  • Increase in the value of PoolAmount while buying USDP affects getAum() function since it is dependent on PoolAmount for calculation.
  • This allowed the hacker to remove liquidity on a higher exchange rate used when adding liquidity
  • Buying Exchange Rate – 1:1
Buying Exchange Rate – 1:1
  • Selling Exchange Rate – 1:1.9
Selling Exchange Rate – 1:1.9

Attack Process

  • First, the attacker took a FlashLoan of 3 Million.
FlashLoan of 3 Million
  • Purchase PLP token worth 1 Million by calling purchasePlp() function.
purchasePlp() function
  • This purchasePlp() function will call 2 functions.
purchasePlp() function1


  • This function will add liquidity in the pool
  • buy USDP
  • and mint plp in 1:1 ratio.


  • This function will deposit the staking amount.
  • Now the attacker used the remaining 2 Million to buy USDP by calling buyUSDP() function. This will inflate the exchange rate.

  • Now the attacker unstaked the previously staked amount by calling unstakeAndRedeemPlp() function. This will send USDP to the attacker’s address at an inflated price.

  • Now the attacker called sellUSDP() function to sell all the staked amount. This includes

2 Million USDP

USDP that the attacker received after inflating the price from the previous step

  • Finally, the attacker repaid the FlashLoan of 3 million and gets the remaining $900k profit.

Flow of Funds

Here is the fund flow during and after the exploit. You can see more details here.

Flow of Funds

Attacker’s Wallets

Currently, all the funds reside in this address – 0x0fe7457f5909778b15d8e46768678abbf0c98329

Here is a snippet of the wallet address

 snippet of the wallet address

After the Exploit

The Project acknowledged the hack via their Twitter.

Incident Timelines

Jul-24-2023 (05:23:38 PM +UTC) – A suspicious transaction was spotted on PalmSwap’s Contracts.

Jul-24-2023 (06:33:31 PM +UTC) – Exploiter was successfully able to steal $900k BUsd.

Jul-24-2023 (06:33:31 PM +UTC) – The exploiter transferred the funds to this address.

How could they have prevented the Exploit?

  • When dealing with business logic where processes like staking and unstaking are happening, it is crucial to write comprehensive Test Cases.
  • It is recommended to make sure to check that all the invariants hold true or not before deployment. Implement fuzzing wherever necessary.

Why QuillAudits For Web3 Security?

  • QuillAudits is well-equipped with tools and expertise to provide cybersecurity solutions saving the loss of hundreds of protocols in funds.
  • Our team of highly skilled auditors have secured over 1M lines of code and $30B in amount.
  • Over the course of multiple years, QuillAudits has been proven to be one of the top choices for protocols to get their codebases audited.

Partner with QuillAudits

  • OG Program (Opportunities for Listing Managers, KOLs, Top Advisors and Investors with access to early stage Web3 projects)
  • WAGSI Program(Claim audit credits to avail exclusive discounts on our auditing package, and additional credits for our automated web3 security infra- QuillShield)

Subscribe to our Newsletter

Your weekly dose of Web3 innovation and security, featuring blockchain updates, developer insights, curated knowledge, security resources, and hack alerts. Stay ahead in Web3!