Seneca Exploit - Post Mortem

TL:DR

On Wednesday, 28th of February, Seneca's Chamber contracts, previously audited by Halborn Security, were affected by a bug approval and users' funds were compromised. In the attack, Seneca’s Chamber.sol contract was implicated. The attacker exploited Chamber's performOperations() function, allowing calls to functions in other contracts, and directed a call to .transferFrom(), using the Chamber contracts to send tokens to their address.

$6,4m were stolen during the attack, and 80% of funds (~$5.3m) were recovered through a Whitehat request, while keeping 20% (~$1.04m) as bounty. The breach didn't affect funds directly deposited into Seneca (Seneca's TVL + Staking), but rather targeted assets held in users' wallets.

Exploit - Overview

Attackers exploited the Chamber contract using the PerformOperations function, which involved:

  • An external call specifically targeting the _call function.

  • This triggered transfer functions on approved collaterals that had approvals exceeding the amount of collateral deposited.

Users had granted max_uint approval to specific Chambers, allowing them:

  • Infinite spending of their collateral from their wallets, despite intentions to deposit even just 1 token.

The attacker’s actions included:

  • Checking allowances, noticing the deposited X amount had an infinite spend approval.

  • Executing a collateral transfer through the Chamber (as the spender) using the _call function.

  • Designating themselves as the receiver, directly from the user's wallet.

Note: This did not affect the collateral already deposited on the Seneca dApp.

The Seneca team took immediate security measures by blacklisting all Chamber contracts. This action prevented the hacker from transferring any more funds from users' wallets that approved amounts exceeding the collateral deposited.

Stolen Funds Recovery Process

After careful analysis, we initiated a Whitehat request for the hacker to return 80% of the stolen funds while allowing them to keep 20% as a bounty. This approach aims to prevent the involvement of law enforcement and any further legal actions against the attacker.

On-chain Whitehat request: https://etherscan.io/tx/0x6e81e21ae6345279060de5c2c27378e2dca4c27a83615c8d835d218c4f66ffbd

Unexpectedly, the hacker returned 1,537 $ETH (approximately $5.3 million) to the provided address and transferred 300 $ETH (around $1.04 million) to two new addresses.The recovered funds are held in a multi-sig wallet: https://etherscan.io/address/0xb7af0aa318706d94469d8d851015f9aa12d9c53a

Sherlock Canceled Contest

Regarding the Sherlock contest speculation, the Seneca team would like to provide clarification:

  • The contest was canceled at Sherlock's request, and Seneca complied with their decision.

  • Seneca did not initiate the request to cancel the contest in any way.

  • When we asked Sherlock to share their findings, they explained that they couldn't do so because the contest was canceled, despite the fact that Sherlock kept a contest pot to honor the Watsons that found bugs during the week the contest was live.

  • Sherlock has not issued a public statement explaining the reasons behind the contest cancellation and decided to partially refund Seneca, keeping enough to honor the payments for the time of the contest being live.

  • Seneca made a public announcement of the contest's cancellation which was followed by the Watsons reaching out to Seneca with their discoveries. Subsequently, we engaged in private discussions with various individuals to address their concerns before proceeding with the next audit.

Halborn Audit

In response to the Sherlock incidents, Seneca engaged Halborn Security to conduct an audit of the Chamber contracts. The audit was successfully executed, and the public report is available below.

It's important to emphasize that while an audit serves as a significant security measure, it does not ensure absolute safety. Seneca's decision to collaborate with a reputable auditing firm underscores its commitment to bolstering the security of the Chamber contract.

The audit can be accessed in the Halborn repository below: https://github.com/HalbornSecurity/PublicReports/blob/master/Solidity Smart Contract Audits/Seneca_SenecaDefi_Smart_Contract_Security_Assessment_Report_Halborn_Final.pdf

The Halborn Security audit was apparently not sufficient to highlight the potential security issues of the exploited section of the code.

Outcome

We want to emphasize that the attack did not impact funds directly deposited into Seneca, or staking.

To ensure users can repay their debt and withdraw their collateral securely from the dApp, the collaterals contracts have been now blacklisted from the Chambers. This means that it’s no longer possible to proceed with backdoor calling of the Chambers to perform arbitrary transfers of funds.

The lack of input validation on the contract is still present, but through the blacklist blockage of _transferFrom functions of deposits assets it is now possible to repay debt and withdraw collateral.

Refunding Process

Through the Whitehat request, we have successfully recovered 80% of the stolen funds. Currently, we are actively engaged in elaborating a plan for the refunding process and will soon release a second article with comprehensive details.

We express our gratitude to all parties who supported us during this incident and offer our sincere apologies to our community for the attack. At Seneca, security has always been a paramount concern, and despite the discovered vulnerability, we are dedicated to resolving it.

Upon the completion of the refunding process, we will implement the required measures to safeguard Seneca's vision.

Subscribe to Seneca Protocol
Receive the latest updates directly to your inbox.
Mint this entry as an NFT to add it to your collection.
Verification
This entry has been permanently stored onchain and signed by its creator.