Hacken Token
$ -- --.--

FEG (Feed Every Gorilla) exploit: analysis by Hacken

FEG (Feed Every Gorilla) has suffered an exploit in the Swap-to-Swap (S2S) functionality in the FEGtoken swap contracts on BSC and ETH. The attacker created 10 addresses and each of them was approved to spend 114 fBNB from the current address. The attacker was able to drain all the fBNB within the contract. Trading of FEG on FEGex was halted immediately after notification of unusual activity.

Date: May 15, 2022

Type of Attack: Flash Loan

Loss: $1.3m

Attack

On May 15, the hacker exploited the S2S functionality within the FEGtoken swap contracts on BSC and ETH.

There were two separate flash loan attacks on Ethereum and BNB Chain. The first flash loan attack was followed by another flash loan attack on 143 ETH ($305k). FEG lost $1.3m in total.

How the Attack Unfolded?

The first step was to borrow 915 WBNB and deposit 116 BNB to FEG Wrapped BNB(fBNB). The next step was to create ten new addresses for later. Afterward, the hacker deposited fBNB to the LP [FEGex PRO] Token contract. Then, the attacker exploited the faulty S2S functionality by inputting a fake address for the path parameter. The S2S function allowed the hacker to spend 114 fBNB belonging to the LP Token contract. The hacker had control over ten addresses. For each address, the attacker deposited 114 fBNB and used S2S functionality to get approval. The next step was to drain all FEG tokens within the contract. The hacker repeated all these steps for 13 LP Token contracts. Finally, the hacker transferred the stolen assets through Tornado Cash and repaid the flash loan.

Source of Security Vulnerability

The cause of the attack was a hacker’s exploit of the vulnerability of the S2S functionality. In particular, FEG’s code has the “swapToSwap()” function that did not have any data validation scheme when taking user input “path.” The following is the extract from the contract source code.

The “swapToSwap()” approved the path and generated a token for the address. The hacker exploited vulnerability by calling “depositInternal()” and “swapToSwap()” functions for each address. The hacker gained “uinit256 tokens”, i.e., unlimited allowance, to drain all the tokens within the contract.

Response

The FEG team suspended trading of FEGtoken after the notification of unusual activity. Trading of FEGtoken continued as usual on centralized exchanges, in addition to Pancake Swap and Uniswap.

PeckShiled, a Chinese-based security company, advised the FEG development team to remove S2S functionality from swap contracts. On May 16, the FED team disabled the S2S functionality as this security vulnerability allowed for more hacks.

The exchange has no plans to remove SmartSwap trading within a contract. S2S functionality will be limited. FEGex will disable the ability to send FEG Wrapped assets from contract to contract. Moreover, the FEG team promised new layers of security.

Implications of the Attack

FEG became the victim of a flash loan attack. This type of attack can be prevented. For example, Hacken performs smart contract audits for all major blockchains. In the case of FEG, our security experts would have performed a smart contract audit for BNB Chain. The audit would have revealed that the function responsible for the S2S feature is programmed to accept the untrusted “path” parameter and approve spending. A smart contract audit by Hacken can protect from this type of flash loan.

Tell us about your project

  • This field is required
  • This field is required
    • whatsapp icon WhatsApp
    • telegram icon Telegram
    • wechat icon WeChat
    • signal icon Signal
  • This field is required
  • This field is required
  • This field is required
  • This field is required
This field is required
departure icon

Thank you for your request

Get security score on

  • certified logo
  • coingeco logo
  • coin market cap logo

800+ projects with $250B protected MarketCap

companies logos

Apply for partnership

  • This field is required
  • This field is required
  • This field is required
  • This field is required
    • Foundation
    • VC
    • Angel investments
    • IDO or IEO platform
    • Protocol
    • Blockchain
    • Legal
    • Insurance
    • Development
    • Marketing
    • Influencer
    • Other
This field is required
This field is required
departure icon

Thank you for your request

Get security score on

  • certified logo
  • coingeco logo
  • coin market cap logo

800+ projects with $250B protected MarketCap

companies logos

Get in touch

  • This field is required
  • This field is required
  • This field is required
  • This field is required
This field is required
By submitting this form you agree to the Privacy Policy and information beeing used to contact you
departure icon

Thank you for your request

Get security score on

  • certified logo
  • coingeco logo
  • coin market cap logo
hackenproof logo

The world trusted Bug Bounty Platform. Run custom-tailored Bug Bounty Programs to secure your business and assets.

hackenproof logo

The world trusted Bug Bounty Platform. Run custom-tailored Bug Bounty Programs to secure your business and assets.

hackenproof logo

The world trusted Bug Bounty Platform. Run custom-tailored Bug Bounty Programs to secure your business and assets.