Cointime

Download App
iOS & Android

Decoding Sentiment Protocol’s $1 Million Exploit | QuillAudits

Validated Project

Summary:

On April 4th, the Sentiment Protocol on the Arbitrum Chain experienced an attack due to a read-only reentrancy vulnerability. The attackers exploited this vulnerability, stealing approximately $1 million. Fortunately, the attacker returned around 90% of the stolen funds.

About Sentiment:

Sentiment is a liquidity protocol on the Arbitrum Chain that allows for on-chain, permissionless, undercollateralized borrowing. Similar to existing DeFi lending markets, Sentiment lenders supply capital, which is then loaned to borrowers as debt.

Vulnerability Analysis & Impact:

On-Chain Details:

Attacker Address: 0xdd0cdb4c3b887bc533957bc32463977e432e49c3 Attacker Contract: 0x9f626f5941fafe0a5b839907d77fbbd5d0dea9d0 Victim Contract: 62c5aa8277e49b3ead43dc67453ec91dc6826403

Attack Transaction: 0xa9ff2b587e2741575daf893864710a5cbb44bb64ccdc487a100fa20741e0f74d

The Root Cause:

The root cause is a view-only reentrancy bug exposed in balancer pools when removing liquidity with one of the return tokens being ETH. Since the entry point is a non-mutating view call it cannot be protected by a reentrancy guard, allowing the caller to take control of execution and run arbitrary code. The attacker was able to execute a malicious contract before updating the pool balances. This allowed them to steal funds by using overpriced collateral.

Full Resolution Image

Attack Steps:

Attack Process:

  • The attacker began by taking out a flash loan of 606 WBTC, 10,130 WETH, and 18 million USDC tokens from the sentiment lending pool.
  • The attacker initiates the attack by calling the joinPool() function of the Balancer Vault to make a deposit. After this, they call exitPool() to withdraw their funds. During the withdrawal process, the Balancer Vault triggers the fallback function of the attack contract.
  • In the fallback function, the attacker calls the borrow function of the 0x62c5 Proxy contract. This function calculates the price based on the return data from Balancer Vault.getPoolTokens(). As a result, the total supply of LP tokens decreases, but the recorded balances of the tokens in the pool are not updated. This causes the token prices to become imbalanced, allowing the attacker to borrow multiple assets at a lower price.
  • Finally, the attacker returned the borrowed funds, along with premiums, and made a profit of approximately $1 million. The attacker bridged the funds from Arbitrum Chain to Ethereum. 

The flow of Funds:

The hacker returned $900,000 (90%) to the protocol and kept the rest as a bounty. They transferred the bounty to Tornado Cash.

Incident Timelines

05.04.2023: The sentiment team announced the hack through a tweet. The contract was paused to prevent further losses. They also announced that they are working with authorities and security firms to secure funds, recover stolen assets, and investigate the exploit.

05-04-2023: The team offered a $95K reward to the hacker if they returned the assets by 8 AM UTC on April 6. Otherwise, the reward will be given to anyone with relevant information about the hacker.

06-04-2023: The Sentiment team announced that they successfully negotiated with the exploiter to return 90% of the hacked funds. A few hours later, they released a statement saying that they had recovered $900,000 from the exploit.

07-04-2023: Sherlock paid out $50K, which is 75% of the remaining losses after the hacker returned 90% of the funds. They further stated that they would claim the last 25% of the loss with their partner, NexusMutual.

8–04–2023: The Sentiment team announced that they had recovered 100% of the funds from the exploit.

11–04–2023: They released a brief summary of the exploit and how they overcame it, restoring the protocol to 100% solvency and full capacity.

How they could have prevented the Exploit?

When developing smart contracts, it is crucial to consider integrations and security solutions that are relevant to the project. To mitigate this issue, it is recommended to use Balancer’s VaultReentrancyLib. By calling ensureNotInVaultContext(vault), a noop call to the vault is performed, which will fail if an attacker attempts a read-only reentrancy attack.

Reproducing the hack:

We will be using the Foundry framework for POC.(Add the Arbitrum Mainnet RPC URL in foundry.toml file and run the test using the command forge test -vvv)

The exploit PoC link can be found here.

Read more: https://quillaudits.medium.com/decoding-sentiment-protocols-1-million-exploit-quillaudits-f36bee77d376

Comments

All Comments

Recommended for you

  • The Philippine central bank has approved the PHPC, a stablecoin pegged to the peso

    The Central Bank of the Philippines has approved a stablecoin called PHPC, which is pegged to the Philippine peso and aims to promote cost-effective remittances. It is backed by cash and equivalents held by Philippine banks and will initially be launched on the Coins.ph platform, with plans to expand to other platforms. PHPC will be the first retail stablecoin backed by the peso and will offer real-time trading 24/7.

  • GBTC has seen a cumulative net outflow of over US$17.6 billion since the launch of the Bitcoin spot ETF

    On May 12th, according to Farside Investors data, the cumulative net outflow of GBTC since the launch of Bitcoin spot ETF reached 17.6329 billion US dollars. According to Coinglass data, GBTC's asset management scale has decreased to 17.647 billion US dollars.

  • The Ethereum network has currently destroyed more than 4.29 million ETH

    According to Ultrasound data, as of now, the Ethereum network has destroyed a total of 4,290,622.06 ETH. Note: Since the introduction of EIP-1559 in the Ethereum London upgrade, the Ethereum network will dynamically adjust the BaseFee of each transaction based on transaction demand and block size, and this portion of the fee will be directly burned and destroyed.

  • Türkiye prepares new encryption law to align with international standards

    Turkey is preparing to submit a new law to regulate cryptocurrency assets to the parliament. The law aims to align with international standards, reduce risks associated with cryptocurrency transactions, and implement strict regulation of cryptocurrency trading platforms by the Capital Markets Board. It will also ensure the safekeeping of assets, establish transparent platforms and customer relationships, and clearly define sanctions for non-compliant behavior. The legislative proposal is expected to be submitted to the parliament within a week.

  • Ripple CEO: The US government’s next target is Tether

    Ripple CEO Brad Garlinghouse recently stated in an interview that the next target of the US government is Tether, the stablecoin company responsible for the circulation of USDT. Some experts believe that Garlinghouse's statement is a very big insider report, and if it really happens, there will be a huge selling pressure in the USDT stablecoin market. In this case, the value of USDT will experience a significant decline.

  • Cointime May 12 News Express

    1.The number of Bittensor subnets for the AI ​​project will increase to 64, and 1024 subnets will be achieved this year2.Trader predicts Bitcoin price will reach $350,0003.vladilena.eth redeemed 1930 weETH from Zircult, suspected of selling4.Solana’s on-chain DEX transaction volume yesterday exceeded the sum of five chains including Ethereum, BSC, and Arbitrum5.RSS3 VSL locked-in amount surged in the past two days and is close to 200 million US dollars 6.The transaction volume of Club Key on friend.tech platform exceeded 1 million7.Lido has paid out more than 516,000 ETH in staking rewards, equivalent to approximately $1.51 billion8.1,000 BTC transferred from TronDAO to an unknown new wallet9.Report: Justin Sun deposited 120,000 eETH into Swell L2, worth $376 million10.1707.36 BTC have flowed out of Binance in the past 7 days

  • Xinjiang launches special campaign to combat illegal fundraising, with key areas including virtual currency, blockchain, etc.

    According to Chang'an Xinjiang Public Account, Xinjiang Autonomous Region and Corps have launched a joint special action to crack down on illegal fund-raising, with key areas including third-party wealth management, fake private equity, fake gold exchange and other traditional fields, as well as emerging fields such as virtual currency, blockchain, cultural tourism, film and television investment, and debt resolution services. It is reported that key cases include cases involving more than 100 million yuan and cases that have been criminally filed for more than five years.

  • A British court has postponed the final sentencing of Wen Jian, a British-Chinese national involved in the country's largest Bitcoin money laundering case, until May 24.

    On May 11th, it was reported that Jian Wen, a 42-year-old British Chinese citizen, was found guilty of "participating in arranging money laundering" in the UK's largest Bitcoin money laundering case. He could be sentenced to up to 14 years in prison. Jian Wen's defense lawyer, Mark Harries, stated that due to the judge's busy schedule, the UK court has postponed Jian Wen's final sentencing, which was originally scheduled for May 10th, to May 24th.

  • Web3 startup Star Nest completes $6 million in Pre-A round of financing

    Hong Kong Web3 music startup Star Nest announced that it has completed a $6 million Pre-A round of financing, led by Chuangqi International Limited, a wholly-owned subsidiary of Hong Kong Stock Exchange-listed company Guofu Innovation. Star Nest will collaborate with Armonia Meta Chain to develop the Star Nest SpaceStar metaverse game, which includes music, role-playing, and social features.In addition, Star Nest plans to launch its NEST project in the third quarter of 2024. Nest will receive 2.1 billion NEST tokens tailored for the project, and Star Nest will use the NEST token to build a more complete music industry token economic system. The NEST token will be widely used for purchasing performance tickets, chain game cooperation, metaverse consumption, governance voting, and other activities.

  • Over $594 million worth of PYTH is staked

    According to Dune data,  there are currently 1,201,167,362 PYTH tokens in the staked state, with a total staked value exceeding $594 million. The number of PYTH stakers has reached 151,211.