# US 2025/0148471 A1 · Security detection method and apparatus for decentralized finance of blockchain

> Agents: this data is available as JSON from the patentgrep API and MCP server — see https://patentgrep.com/llms.txt

- Number: US 2025/0148471 A1
- Document ID: US20250148471A1
- Status: Published application
- Kind: A1
- Application number: 18/798,294
- Filed: 2024-08-08
- Published: 2025-05-08
- Earliest claimed: 2023-11-02
- Assignees: Hainan University
- Applicants: Hainan University
- Inventors: Xiaoqi LI; Wenkai LI; Zongwei LI
- Web page: https://patentgrep.com/patent/US20250148471A1

## CPC

- G06Q 20/4016: {involving fraud or risk level assessment in transaction processing}
- G06Q 20/389: {Keeping log of transactions for guaranteeing non-repudiation of a transaction}
- G06Q: INFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR

## Abstract

A security detection method and apparatus for decentralized finance of a blockchain. The security detection method includes the following steps: step S1, acquiring a malicious transaction call flow and collecting related smart contracts; step S2, constructing a control flowchart of the related smart contracts and simulating a call relation to connect an association graph; step S3, collecting data flow paths in the association graph and verifying path accessibility; step S4, constructing a data set by the collected accessible paths and inputting the data set into a DeFiTail model for training; and step S5, monitoring whether there is a malicious behavior in a transaction through the trained DeFiTail model. When the method is used, in all blockchains compatible with an Ethereum virtual machine, smart contract attack pattern detection at a bytecode level is implemented.

## Claims

### Claim 1

A security detection method for decentralized finance of a blockchain, the method comprising:
acquiring, by an apparatus, a malicious transaction call flow by analyzing right control incidents and flash loan attack incidents of the decentralized finance in an REKT data set, to collect the malicious transaction call flow comprising attack accounts and attacked fragile contracts, and collecting smart contracts related to the malicious transaction call flow;
constructing, by the apparatus, a control flowchart of the smart contracts and simulating a call relation to connect an association graph;
collecting, by the apparatus, data paths in the association graph and verifying an accessibility of the data paths to acquire accessible data paths;
constructing, by the apparatus, a data set by the accessible data paths and inputting the data set into a model for training; and
determining, by the trained model, a malicious behavior in a transaction through the trained model;
wherein the step of verifying the accessibility of the data paths comprises:
executing a stack operation that records proceeding of data by using a symbol, and verifying whether stack elements needed for each stack operation are enough to verify each branch condition in the data, to determine whether the data paths are accessible;
wherein the step of constructing the data set comprises:
one-hot encoding data in the accessible data paths as a data path embedding vector, and using the data path embedding vector as an input to train the model;
constructing a heterogeneous graph according to a corpus constructed from the data paths and acquiring relational features between the data and the data paths in an adjacent matrix;
truncating a length of the data path embedding vector into a fixed size through a Transformer encoder structure to acquire local features of each data path;
embedding the data path features acquired in the step of truncating the length of the data path into the adjacent matrix, and obtaining global data path features by using a graph convolution neural network;
combining the global features acquired in the step of embedding the data path features and the local features acquired in the step of truncating the length of the data path to obtain final data path features; and
calculating whether the data path features acquired in the step of combining the global features are secure through a softmax layer; and
wherein the step of determining the malicious behavior in a transaction through the trained model comprises:
collecting all transaction data within a special time interval;
sequentially constructing a transaction flow direction through a timestamp attribute of the transaction, and constructing the association graph of the smart contracts by using the step of constructing the control flowchart;
collecting the data paths by using the step of collecting the data paths, and verifying the accessibility of the data paths to acquire the accessible data paths; and
one-hot encoding the data paths acquired in the step of collecting the data paths and inputting the data paths into the model to determine whether the data paths are secure.

### Claim 2

(canceled)

### Claim 3 (depends on 1)

The security detection method for decentralized finance of a blockchain according to claim 1, wherein the step of constructing the control flowchart comprises:
acquiring a control flow direction in each contract by constructing the control flowchart of the smart contracts;
simulating the transaction call flow direction to acquire data flow directions between the smart contracts; and
connecting the control flow directions and the data flow directions to form the association graph.

### Claim 4 (depends on 3)

The security detection method for decentralized finance of a blockchain according to claim 3, wherein the step of collecting the data paths comprises:
by taking a function entry of a caller contract as a starting point, collecting the data paths in the association graph.

### Claim 5 (depends on 1)

A security detection apparatus for decentralized finance of a blockchain implementing the security detection method for decentralized finance of the blockchain according to claim 1, the security detection apparatus comprising:
a first acquisition device, configured to acquire a malicious transaction call flow and collect smart contracts related to the malicious transaction call flow;
a construction device, configured to construct a control flowchart of the smart contracts collected in the first acquisition device and simulate a call relation to connect an association graph;
a second acquisition device, configured to collect data paths in the association graph simulated in the construction device and verify an accessibility of the data paths to obtain accessible data paths;
a training device, configured to construct a data set by the accessible paths in the second acquisition device and input the data set into a model for training; and
a detection device, configured to determine, by the trained model of the training device, a malicious behavior in a transaction.
