March 04, 2024

Lack of function checking - Analysis of SenecaUSD security incident


On February 28, 2024, according to Beosin trace, there was a vulnerability in the contract of SenecaUSD. The attacker used carefully constructed calldata parameters to call transferfrom() to transfer the tokens authorized to the contract to the attacker's address. At present, the hacker has returned 80% of the funds, and the remaining 20% is used as a white hat reward. The following is Beosin's analysis of the attack.


Vulnerability Analysis

There is a performOperations() in the Seneca project contract, which uses the parameters passed in to choose to execute different function logic.

 

It can be seen that when the user specifies action as 30, the function will choose to call the _call function and pass in the user-specified calling parameters.

 

The _call function only checks the blacklist of the calling address, and then directly calls the specified function at the user-specified address without any restrictive checks on the caller and calling parameters.

 

If the caller constructs illegal call data here, it may lead to attacks.


Attack Process

In this incident, the attacker used the same attack method many times. Here we take the transaction 0x23fcf9d4517f7cc39815b09b0a80c023ab2c8196c826c93b4100f2e26b701286 as an example. Let’s take a look at how the attacker constructed the call data and carried out the attack.

 

1. The attacker directly calls the performOperations function and constructs the following parameters. Actions is passed in the above 30, and the _call function is called.

2. Datas data is:

0x000000000000000000000000b05cabcd99cf9a73b19805edefc5f67ca5d1895e

0000000000000000000000000000000000000000000000000000000000000a0

000000000000000000000000000000000000000000000000000000000000000

000000000000000000000000000000000000000000000000000000000000000

000000000000000000000000000000000000000000000000000000000000000

000000000000000000000000000000000000000000000000000000000000064

23b872dd0000000000000000000000009cbf099ff424979439dfba03f00b5961

784c06ce0000000000000000000000094641c01a4937f2c8ef930580cf39614

2a2942dc0000000000000000000000000000000000000000000004b180b8661

8eddc3ab000000000000000 00000000000000000000000000000000000000000

 

According to the parsing rules, the first 32 bytes are callee=0xb05cabcd99cf9a73b19805edefc5f67ca5d1895e.

 

The second callData is at a0, 100 (0x64) bytes

3. Query the function selector. According to the callData data, callData specifies the transferFrom function.

4. Since in the previous transaction, 0x9cbf099ff424979439dfba03f00b5961784c06ce authorized the maximum value to the address 0x65c210c59b43eb68112b7a4f75c8393c36491f06, so here the attacker directly transfers 0x9cbf099ff424979 through the transferFrom function. More than 1385 PT-rsETH-27JUN2024 (0xb05cabcd99cf9a73b19805edefc5f67ca5d1895e) tokens of 439dfba03f00b5961784c06ce were transferred to his own address .

5. The attacker then exchanged the PT-rsETH-27JUN2024 tokens for ETH.

 

Funds Tracing

After being attacked, the Seneca deployer shouted to the attacker, asking the attacker to return the funds, and said that he could keep 20% of the funds as a white hat reward.

 

According to the Beosin trace fund tracking platform, as of press time, the attacker has returned 1,537 ETH (80%) of the more than 1,900 stolen ETH to the address specified by the deployer, and the remaining 370 ETH (20%) are scattered among the attackers. on the address.


Related Project

Related Project Secure Score

Guess you like
Learn More
  • Blockchain Security and Regulation Monthly Recap of February: $422M lost in attacks

    March 01, 2024

  • Another Price Manipulation - Analysis of the attack on the WooPPV2 contract on the Arbitrum

    March 07, 2024

  • Nibiru is about to launch its mainnet. What are its technical characteristics and security development practices.

    March 12, 2024

  • From SBF to CZ, why crypto trading institutions are always accused of money laundering

    March 22, 2024

Join the community to discuss.