BlockThreat - Week 16, 2024

Hedgey | Grand Base | Chainge | Hackathon | Mars | SATX | GFA

Greetings!

This was not a good week for DeFi projects out there. $48M were stolen across 7 hacks, mass phishing campaigns, $33M rugpulls, and 0days targeting essential tools. We have a lot to cover, but first a note from our sponsor Cyfrin! A whole generation of security auditors got their first bounty thanks to their hard work building free classes, tools and projects. Their contributions to the blockchain security community are immense so I hope you will consider them for your next audit, bug bounty program, or just an ever growing resource of excellent content.


Cyfrin is dedicated to helping scale smart contract security. Protocols looking for a private audit should reach out, but additionally, the team works on tools and platforms to scale security throughout the industry. 

Cyfrin Updraft has the most watched smart contract development and security curriculum on earth. Cyfrin CodeHawks is the competitive audit platform for web3, for everyone from the started security researchers to the top bug hunting masters. Solodit is the audit report aggregator to help you learn the top attack vectors being reported today. Aderyn is the open-sourced rust-based static analyzer to help automatically detect bugs in your solidity codebase. 


Let’s start with DeFi compromises. There was a really unfortunate exploit on Ethereum and Arbitrum chains of Hedgey Finance. An attacker was able to trick vulnerable contracts into approving the transfer of $44.7M worth of assets by injecting malicious parameters into an overly trusting method. Below is the vulnerable snippet:

function createLockedCampaign(
bytes16 id,
Campaign memory campaign,
ClaimLockup memory claimLockup,
Donation memory donation
) external nonReentrant {

[..snip..]

// deposit tokens TransferHelper.transferTokens(campaign.token, msg.sender, address(this), campaign.amount + donation.amount);

[..snip..]

// withdrawal approval SafeERC20.safeIncreaseAllowance(IERC20(campaign.token), donation.tokenLocker, donation.amount);

In the above snippet, callers have complete control over campaign, claimLockup, and donation structs so they can set campaign.token and donation.tokenLocker to arbitrary values (e.g. USDC, attacker controlled contract). While calling the above method the attacker transfers some amount of tokens to Hedgey which also generates an approval for the donation.amount to an arbitrary address. In one exploit transaction, the attacker borrowed $1.3M from Balancer, deposited it to Hedgey, and in return got a $1.3M approval to an address they control.

The next part is what enabled the exploit. When cancelling the campaign, the contract withdraws deposited tokens, but never revokes the approval!

function cancelCampaign(bytes16 campaignId) external nonReentrant {
Campaign memory campaign = campaigns[campaignId];
require(campaign.manager == msg.sender, '!manager');
delete campaigns[campaignId];
delete claimLockups[campaignId];

// withdraw tokens
TransferHelper.withdrawTokens(campaign.token, msg.sender, campaign.amount);
emit CampaignCancelled(campaignId);
}

The attacker simply followed up with another transaction to withdraw $1.3M held by the contract prior to the exploit. Insufficient function parameter validation exploits are painful, but have an important lesson for developers:

Assume all user controlled input is tainted and designed to disable or steal assets from your protocol. It is hot lava that will burn you without proper care!

More phishing campaigns peddling credential and private key stealers by tricking folks who are interviewing or providing advisory services.

PSA: Never download and run executables on a non-isolated machines presented to your during job interviews, business or other calls. Consider using Virtual Machines and external file scanners like VirusTotal.


Another conviction this week of a DeFi attacker - Avi Eisenberg, a 28 year old crypto trader responsible for the Mango Markets hack. A few takeaways:

Attackers expecting no legal repercussions by negotiating a “bounty” with just the DeFi project should also reach out to every single user to make a similar agreement. Oh and also convince SEC, CFTC, and DoJ that your actions were legal. Worst case you could prepare an expensive legal defense with five lawyers for the 12 randomly selected jurors who will sleep through your arguments and convict you anyway. Good luck!


News were going around all week about iMessenger, WhatsApp, etc. 0days for sale. This created a lot of fear in folks ready to throw away their phones while locking themselves in an RF proof safe room. The reality is that 0days are available for sale at all times. Gray markets exist that actively research and acquire exploits to unpatched vulnerabilities to be sold to interested parties (mostly government and LE entities). As vulnerabilities get patched, bounties go out to make sure there is always one available in the arsenal. Below is a sample offering from one such company where iMessenger exploits can collect $2M+ and resold to buyers for even greater amounts:

What got everyone really scared is that the iMessenger exploit was made available for purchase on a dark market by entities beyond the usual pro-Western government and LE actors.

Some questions to think of when assessing the risk of someone using an 0day on you is the likelihood. Are you really that important that someone will burn a $2.5M exploit? Is there a cheaper way to compromise you or your org with SIM swapping, spear phishing or just embedding a malicious insider? Do you really believe the dark market ad is real when there are “gray” markets ready to bid on the exploit?

If you still think that you may be the target then you should focus on building resilient security controls such as using hardware wallets, multisigs, Yubikeys, etc. A single compromised phone should not ruin your organization.


The premium version of the newsletter includes additional coverage, PoCs, indicators for the hacks mentioned above as well as Grand Base, Hackathon, Mars, and others.

To gain access to comprehensive vulnerability write-ups, post-mortems, exploit proof of concepts (PoCs), attacker addresses, and additional data regarding this week’s compromises, please subscribe to the premium plan below.

Let’s dive into the news!

Events

News

Crime

Policy

Phishing

Scams

Malware

Media

Research

Tools

  • Aderyn - Rust-based Solidity static analyzer by Cyfrin. Check out the announcement blog for additional details.
  • tx-coverage - Reveal unused code of a live smart contract by collecting coverage from historical transactions by Decurity.
  • BugBounty Companion by tintinweb. The BugBounty companion lets you quickly check out source-code from bug bounty programs from various platforms.
  • cargo-unmaintained - Find unmaintained packages in Rust projects by Trail of Bits.

Hacks

GFA Token

Date: April 14, 2024
Attack Vector: Insufficient Function Access Control
Impact: $15,500
Chain: BSC

https://twitter.com/0xNickLFranklin/status/1779782276198682993

Hackathon

Date: April 14, 2024
Attack Vector: Reward Manipulation
Impact: $40,000
Chain: BSC

https://twitter.com/EXVULSEC/status/1779519508375613827

Chainge Finance

Date: April 15, 2024
Attack Vector: Arbitrary External Calls
Impact: $710,000
Chain: BSC

https://twitter.com/CertiKAlert/status/1779863821122691519

Grand Base

Date: April 15, 2024
Attack Vector: Stolen Private Keys
Impact: $2,500,000
Chain: Base

https://t.me/grandbase_fi/15354

SATX

Date: April 16, 2024
Attack Vector: Logic Error
Impact: $27,000
Chain: BSC

https://twitter.com/bbbb/status/1780341239801393479

Mars

Date: April 16, 2024
Attack Vector: Reward Manipulation
Impact: $100,000
Chain: BSC

https://twitter.com/Mars_DeFi412/status/1780154384107946332

Hedgey Finance

Date: April 19, 2024
Attack Vector: Function Parameter Validation
Impact: $44,700,000
Chain: Ethereum, Arbitrum

https://twitter.com/peckshield/status/1781221419088851370