A noise-resistant federated smart contract vulnerability detection method and system with probability label estimation
By combining probabilistic label estimation and meta-learning training algorithms, the problem of label noise in smart contract vulnerability detection is solved, improving the detection accuracy and adaptability of the model and ensuring the security of the blockchain system.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- GUANGDONG UNIVERSITY OF FOREIGN STUDIES
- Filing Date
- 2025-03-17
- Publication Date
- 2026-05-19
AI Technical Summary
Existing technologies for smart contract vulnerability detection suffer from problems such as label noise affecting model performance, limited ability to handle heterogeneous label noise, lack of effective label calibration methods, and poor adaptability to real-world industrial scenarios. In particular, in federated learning, it is difficult to effectively utilize limited resources for model training and optimization.
A probabilistic label estimation method is employed, which combines global and local vulnerability knowledge with a probabilistic label model and a meta-learning-based training algorithm to calibrate label noise and optimize model performance. This method includes probabilistic label modeling, a probabilistic label estimation network, and joint optimization. It utilizes Bayes' theorem and Markov random field models to estimate the true label probabilities and improves label calibration accuracy through iterative training steps.
It effectively handles label noise, improves model performance, enhances model adaptability, increases label calibration accuracy, significantly improves the accuracy and reliability of smart contract vulnerability detection, adapts to complex and diverse data environments, and ensures the security of blockchain systems.
Smart Images

Figure CN120337214B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to, but is not limited to, the field of smart contract vulnerability detection technology, and particularly relates to a noise-resistant federated smart contract vulnerability detection method and system with probability label estimation. Background Technology
[0002] With the development of blockchain technology, the application of smart contracts is becoming increasingly widespread. However, smart contract vulnerabilities seriously threaten the security of blockchain systems, potentially leading to financial losses and system attacks. To ensure the stable operation of blockchain systems, smart contract vulnerability detection has become a key technological area. In this field, deep learning technology, due to its powerful end-to-end feature learning capabilities, has received widespread attention and has been applied to smart contract vulnerability detection. Based on the representation learning methods used, existing methods can be broadly classified into three categories: sequence-based methods analyze program behavior by extracting execution sequence features; graph-based methods represent smart contract code as a graph to capture operational logic; and hybrid methods combine expert-defined vulnerability patterns to enrich vulnerability features. There is a significant gap between existing deep learning-based solutions and practical industrial applications. Although deep learning methods improve detection performance, they rely on supervised learning and often ignore label noise in the dataset.
[0003] Currently, most existing deep learning methods for smart contract vulnerability detection assume that the labels on the training dataset are accurate. However, ensuring the correctness of the labels faces numerous challenges. On the one hand, as smart contract logic becomes increasingly complex, accurate labeling becomes increasingly difficult; on the other hand, although expert teams can create clean datasets, the high cost forces developers to rely on automatic labeling tools. However, these automatic labeling tools have limitations when dealing with complex smart contract logic, resulting in a high error rate.
[0004] Meanwhile, federated learning techniques have also been applied in this field, addressing the data silo problem by training local models on the data owner's side and aggregating them into a global model, thus incorporating global knowledge. Recent research has used pseudo-labels from the global model to improve label accuracy. However, the varying labeling capabilities among data owners introduce different levels and types of label noise, leading to noise propagation during model aggregation.
[0005] Based on the above analysis, the urgent technical problems that need to be solved in the existing technology are:
[0006] (1) Label noise affects model performance: In existing technologies for smart contract vulnerability detection, label noise is a common problem due to the difficulty in ensuring the accuracy of training dataset labels. For example, automatic labeling tools can lead to high false negative rates and high mislabeling rates. When deep detection models are trained on noisy datasets, they learn incorrect patterns, resulting in inaccurate predictions during the inference stage. For instance, in actual detection, a smart contract with vulnerabilities may be misclassified as a normal contract, or vice versa, which greatly reduces the accuracy and reliability of the detection.
[0007] (2) Limited ability to handle heterogeneous label noise: In practical applications, the labeling capabilities of different data owners vary, resulting in different levels and types of label noise in the dataset. Existing federated learning methods are easily affected by noise propagation when aggregating local models, and cannot effectively handle this heterogeneous label noise. This limits the effectiveness of the model in real industrial scenarios, fails to fully utilize its detection capabilities in complex and diverse data environments, and is difficult to meet practical needs.
[0008] (3) Lack of effective label calibration methods: Although some federated learning methods attempt to use pseudo-labels from the global model for label calibration, the accuracy of these pseudo-labels is highly dependent on the reliability of the global task model. Given the diverse levels and types of label noise from data owners, it is difficult to ensure the reliability of the global task model, resulting in low accuracy in label calibration. For example, in the absence of comprehensive knowledge, relying solely on local data for label inference cannot accurately calibrate noisy labels, affecting the overall performance of the model.
[0009] (4) Poor adaptability to real-world industrial scenarios: In real-world industrial scenarios, privacy protection requirements limit data sharing and integration, and the number of clean samples is often limited. Existing technologies struggle to effectively utilize limited resources for model training and optimization under these circumstances, failing to fully adapt to the data characteristics and constraints in industrial scenarios. For example, under the premise of data privacy protection, it is difficult to obtain enough clean samples for accurate model training, resulting in limited model performance in practical applications and an inability to provide reliable security for smart contracts. Summary of the Invention
[0010] To address the problems existing in the prior art, this invention provides a noise-resistant federated smart contract vulnerability detection method and system with probabilistic label estimation.
[0011] This invention is implemented as follows: a method for detecting vulnerabilities in noise-resistant federated smart contracts with probabilistic label estimation, characterized in that the method specifically includes:
[0012] S1: Create a clean smart contract vulnerability dataset containing Reentrancy and Timestamp vulnerabilities;
[0013] S2: Construct a noise dataset with two types of labeled noise: symmetric labeled noise and false negative labeled noise;
[0014] S3: The dataset is divided into training set, validation set and test set according to the proportions;
[0015] S4: Distribute the training set equally among multiple data owners. Each data owner randomly selects smart contracts from its local training set as a clean validation set for training the probabilistic label model. The remaining smart contracts in the local training set are used to generate a noisy training set.
[0016] S5: Set the maximum noise level for two types of noise. Each smart contract in the training set is randomly flipped with different probabilities of symmetric label noise level to generate a dataset with symmetric label noise. For false negative label noise, contracts marked as having vulnerabilities are randomly flipped with different probabilities of false negative label noise level.
[0017] S6: Establish a deep learning model, initialize the global deep learning model parameters in the data center, and broadcast them to all data owners participating in the federated learning;
[0018] S7: In federated learning, each data owner uses a probability label estimation model to calibrate their local noisy dataset;
[0019] S8: In federated learning, each data owner updates its local model using the calibrated dataset and the parameters of the received global model;
[0020] S9: In federated learning, each data owner uploads the updated local model parameters to the data center, which then weights and aggregates the parameters of all local models to update the global model parameters.
[0021] S10: The subsequent global model parameters will be updated again and broadcast to the data owner. The training process will be repeated, repeating S6-S9.
[0022] S11: Use accuracy and F1 score as evaluation metrics to evaluate the performance of the invention.
[0023] Furthermore, in S2, the false negative label noise is asymmetric label noise without false positive label noise.
[0024] Furthermore, in S4, the training set is evenly distributed among multiple data owners. Multiple data owners refer to the fact that in federated learning, the data center consists of multiple data owners, each of whom owns a local dataset.
[0025] Furthermore, in S7, the local noise dataset is calibrated using the probability label estimation module. The probability label estimation model includes: probability label modeling, probability label estimation network, and optimization.
[0026] (1) Probabilistic label modeling: By modeling the relationship between local labels, pseudo labels, and true labels, the probability of the true label for each sample is estimated. Local labels and pseudo labels are considered as observation noise labels. Based on Bayes' theorem and Markov random field models, a probabilistic labeling model is derived, which is expressed as follows:
[0027]
[0028] in, To observe the noise label, This is the true label of smart contracts. Features of smart contracts This represents the prior probability that a smart contract is truly labeled as 1 (i.e., contains vulnerabilities). It is a constant estimated from the local clean verification dataset of each data owner. The probabilistic label model estimates the probabilistic label of a given smart contract by weighting and aggregating the observed noise labels according to their accuracy scores.
[0029] (2) Probability label estimation network: A deep neural network is used as the probability label estimation network. For each data owner Parametric probabilistic labeling model. Accuracy scoring function in the network. By rating network Parameterization. For any tagged smart contract First, generate pseudo tags. and one-hot representation The feature embedding of the smart contract is obtained by removing the output layer from the global model. Cleanly validate the dataset locally Estimate local vulnerability dataset Class distribution Then the rating network by and As input, the accuracy score vector for predicting observed noise labels The last layer is The transformation layer is used to normalize the accuracy score; finally, the aggregator combines the local class distribution. One-hot representation of observed noise labels and accuracy score Generate probability labels ;
[0030] (3) Optimization: The joint optimization of the probabilistic label estimation network and the local deep detection model ensures that the probabilistic labels provided by the label estimation network can improve the detection performance of the local deep detection model, thereby improving the label accuracy. The optimization objective is to minimize the loss of the detection model on the local clean validation dataset:
[0031]
[0032] in, For a clean local validation dataset, For probability label estimation network, Features of smart contracts To observe the noise label, Let be the prior probability that the smart contract is truly labeled as 1 (i.e., contains a vulnerability). For the first The local depth detection model of the data owner for smart contracts The prediction results.
[0033] Furthermore, in S8, to adapt to real industrial scenarios with limited clean samples, a meta-learning-based training algorithm is used to jointly optimize the probability label estimation network and the local deep detection model with the validation set. This algorithm works through iterative internal and external training steps:
[0034] (1) In the internal training step, the calibration labels generated by the probabilistic label estimation network are used to optimize the local depth detection model. For each smart contract Generate probability labels Simultaneously, the parameters of the global model are used to optimize the local depth detection model. Parameter initialization to generate a prediction model Calculate the training loss and update the local model parameters; local deep detection model. The update is as follows:
[0035] .
[0036] in, For internal training learning rate, For local training set Internal training loss.
[0037] (2) In the external training step, based on the updated local deep detection model In the validation dataset On the validation loss update probability label estimation network , means as follows:
[0038]
[0039] The calculation method is as follows:
[0040]
[0041] in, For external training learning rate, To indicate in the validation dataset The expected verification loss.
[0042] Furthermore, in S9, the global model parameters are updated by aggregating parameters from all data owners in the data center, as shown in the following process:
[0043]
[0044] in, For local model parameters, These are global model parameters. The number of samples owned by each data owner. The total number of data owners.
[0045] Another objective of this invention is to provide a noise-resistant federated smart contract vulnerability detection system with probabilistic label estimation, the system specifically comprising:
[0046] The dataset building module is used to build the dataset and divide it into training, validation, and test sets.
[0047] The probability label estimation module estimates the probability of the true label for each sample by modeling the relationship between local labels, pseudo labels, and real labels.
[0048] The meta-learning training module, based on the meta-learning training algorithm, enables joint optimization of the probabilistic label estimation network and the local deep detection model with the validation set.
[0049] Based on the above technical solutions and the technical problems solved, the advantages and positive effects of the technical solution to be protected by this invention are as follows:
[0050] First, effectively handling label noise and improving model performance: Addressing the issue of label noise impacting model performance in existing technologies, this invention treats pseudo-labels and local labels as observed noise labels through a probabilistic label estimation module, constructing a probabilistic label model to calculate the probability of the true label. This model effectively captures the relationship between observed noise labels and true labels, thereby more accurately assessing label reliability, performing effective label calibration, improving the accuracy and reliability of the model in smart contract vulnerability detection, and ultimately enhancing overall performance. Table 6 shows the performance of GBGRU and CGE under different noise levels.Figure 4 , Figure 5 As a result, the performance of the deep detection model remained relatively stable until the training set contained 20% symmetric label noise or 15% to 25% false negative label noise. Specifically, in the case of symmetric label noise, the average performance of CBGRU did not show a significant decrease until the noise level reached 20%.
[0051] Adapting to Heterogeneous Label Noise and Enhancing Model Adaptability: Addressing the limited ability of existing technologies to handle heterogeneous label noise, the probabilistic label model of this invention calculates the true label probability by comprehensively considering information from both global model pseudo-labels and local labels, no longer simply relying on the reliability of the global model. When facing label noise of varying levels and types from different data owners, it can effectively integrate multi-source knowledge for label calibration. In heterogeneous label noise scenarios, this invention can adapt to complex real-world industrial scenarios, effectively handling heterogeneous label noise between different data owners, enhancing the model's adaptability and effectiveness in diverse data environments. As shown in Tables 3 and 4, CBGRU and CGE demonstrate their performance in Reentrancy under heterogeneous levels of symmetric label noise and false negative label noise. This invention achieves the highest F1 scores for CBGRU and CGE on the Reentrancy dataset, at 82.34% and 83.69%, respectively, and on the Timestamp dataset, at 90.75% and 84.79%, respectively. Under heterogeneous levels of symmetric label noise and false negative label noise, this invention consistently outperforms the second-best results. As shown in Table 5, the performance of this invention under heterogeneous label noise is compared between Reentrancy and Timestamp datasets. The invention achieved the highest F1 score, recording 84.79% for CBGRU and 87.22% for CGE on the Reentrancy dataset, and 85.87% for CBGRU and 85.89% for CGE on the Timestamp dataset. These results demonstrate the effectiveness of this invention under both heterogeneous level and heterogeneous type noise labels.
[0052] Improving Label Calibration Accuracy and Optimizing Model Performance: Given the lack of effective label calibration methods in existing technologies, this invention introduces a meta-learning training algorithm to optimize the probabilistic label estimation network. In real-world industrial scenarios where clean samples are limited, this algorithm can continuously adjust the parameters of the probabilistic label estimation network through iterative internal and external training steps, utilizing feedback from the local model, thereby improving the accuracy of label calibration. The meta-learning training algorithm enables this invention to better utilize validation set information to optimize label calibration under limited clean sample conditions, thus improving the overall detection performance of the model and optimizing its performance in smart contract vulnerability detection. By introducing a probabilistic label model and a meta-learning-based training algorithm, this invention can calibrate labels more accurately. In ablation studies, probabilistic label models alone have limited effectiveness. However, when combined with a meta-learning-based training algorithm, the F1 score on the Reentrancy dataset improved from 57.7% to 63.08% under symmetric label noise, and from 72.78% to 77.62% on the Timestamp dataset. Under false negative label noise, the F1 score on the Reentrancy dataset improved from 60.43% to 80.34%, and on the Timestamp dataset from 72.93% to 85.24%. This indicates that the algorithm can effectively utilize limited clean samples, improve label calibration accuracy, and thus enhance model performance.
[0053] The comprehensive advantages bring about overall performance improvement and wide applicability: Through the aforementioned improvements in label noise processing, heterogeneous noise adaptation, and label calibration optimization, this invention demonstrates a significant improvement in overall performance across various smart contract vulnerability detection tasks. Unlike traditional federated learning-based label calibration methods, this invention generates true label probabilities by utilizing pseudo-labels from a global model and local labels provided by the data owner. This is achieved through a probabilistic label model that captures the conditional dependencies between observed noisy labels and true labels. This model is parameterized using a dedicated probabilistic label estimation network. Furthermore, this invention introduces a meta-learning-based training algorithm, enhancing its adaptability to real-world industrial scenarios where clean samples are typically limited. This invention performs exceptionally well in dealing with heterogeneous noise, regardless of its level or type. In experiments with different types of label noise, compared with other state-of-the-art methods, this invention achieved F1 scores of 84.79% and 87.22% for CBGRU and CGE on the Reentrancy dataset, respectively, and 85.87% and 85.89% for the Timestamp dataset, respectively, surpassing other methods. These results strongly demonstrate that this invention can effectively handle various complex noise conditions and exhibits an overall performance improvement in different smart contract vulnerability detection tasks. This invention promotes the development of high-performance global deep detection models for noisy and distributed datasets for a method of noise-resistant federated smart contract vulnerability detection with probabilistic label estimation. Its broad applicability can provide a reliable and efficient solution for smart contract vulnerability detection in different scenarios, effectively ensuring the security of smart contracts in blockchain systems, greatly promoting the secure application of smart contract technology in a wider range of fields, and bringing new breakthroughs to the development of smart contract vulnerability detection technology.
[0054] Secondly, the technical solution of this invention addresses a key technical challenge: due to the significant losses caused by hacker attacks, smart contract vulnerability detection is rapidly developing alongside blockchain technology. Deep learning has demonstrated significant advantages in this field due to its powerful end-to-end feature learning capabilities. However, the presence of centralized label noise in smart contract vulnerability datasets weakens the performance of deep detection models. Existing research attempts to address this challenge by leveraging comprehensive task knowledge from multiple data owners to correct noisy labels. These methods typically employ federated learning to train a global task model and utilize pseudo-labels from this model as the basis for further training. Despite these efforts, current methods are still insufficient to handle heterogeneous levels and types of label noise arising from varying labeling capabilities among data owners, limiting their effectiveness in real-world industry scenarios. Based on this, this invention proposes a noise-resistant federated smart contract vulnerability detection method with probabilistic label estimation. This method treats pseudo-labels and local labels as observed noise labels and introduces a novel probabilistic label model to calculate the probability of the true label by capturing the conditional dependencies between observed noise labels and the true label. This method effectively evaluates the reliability of global and local vulnerability knowledge in label calibration, thereby improving the accuracy of label calibration. Furthermore, this invention also implements a meta-learning-based training algorithm for probabilistic labeling models, enabling them to adapt to real-world industrial scenarios with limited clean samples.
[0055] Third, this invention effectively addresses the issue of noise labels affecting the performance of federated learning models in existing technologies by introducing a probability label estimation mechanism. In traditional federated learning, the presence of noise labels significantly reduces the model's accuracy and generalization ability. This invention, however, calibrates the local noisy dataset by combining global and local vulnerability knowledge, generating label probabilities that are closer to reality, thereby improving the model's robustness and detection performance.
[0056] Existing technologies mostly focus on handling single types of label noise (such as symmetrical noise or false negative noise), while neglecting the coexistence of multiple types of label noise in complex scenarios. This invention innovatively handles symmetrical label noise and false negative label noise simultaneously. Through a flexible noise modeling method, it significantly improves the applicability of federated learning systems in diverse noise scenarios, overcoming the limitations of existing technologies.
[0057] In traditional federated learning, the presence of noisy data not only degrades model performance but can also increase computational and communication overhead. This invention addresses this by introducing a probability label estimation module, enabling effective calibration of the local dataset and reducing unnecessary computational and transmission burdens. The weight aggregation strategy further optimizes the efficiency of global model updates, significantly improving federated learning performance in large-scale distributed scenarios.
[0058] This invention addresses the challenge of limited clean samples in industrial settings by employing a meta-learning-based joint optimization algorithm. This ensures the joint optimization of the local deep detection model and the probabilistic label estimation network while reducing direct reliance on the original data. This approach not only solves the problem of balancing privacy and performance in traditional federated learning but also significantly improves the adaptability and practicality of federated learning in industrial scenarios, particularly in terms of noise and privacy protection. Attached Figure Description
[0059] Figure 1 This is a flowchart of a noise-resistant federated smart contract vulnerability detection method with probability label estimation provided in an embodiment of the present invention;
[0060] Figure 2 This is a flowchart of the probability label estimation module provided in an embodiment of the present invention;
[0061] Figure 3 This is a diagram of a training algorithm based on meta-learning provided in an embodiment of the present invention;
[0062] Figure 4 The accuracy and F1 score of CBGRU and CGE with symmetrical label noise (0%, 5%, 10%, 15%, 20%, 20%, 25%, and 30%) provided in this embodiment of the invention on Reentrancy and Timestamp;
[0063] Figure 5 The accuracy and F1 score of CBGRU and CGE with false negative label noise (0%, 5%, 10%, 15%, 20%, 20%, 25%, and 30%) provided in this embodiment of the invention on Reentrancy and Timestamp. Detailed Implementation
[0064] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the invention.
[0065] like Figure 1 As shown in the figure, this invention provides a method for detecting vulnerabilities in noise-resistant federated smart contracts with probabilistic label estimation. The method specifically includes:
[0066] S1: Create a clean vulnerability dataset containing Reentrancy and Timestamp vulnerabilities;
[0067] S2: A noise dataset with two types of label noise was constructed: symmetric label noise and false negative label noise (asymmetric label noise has no false positive label noise);
[0068] S3: The dataset is divided into training set, validation set and test set in a 7:1:2 ratio;
[0069] S4: Distribute the training set evenly among multiple data owners. Each data owner randomly selects 60 smart contracts from their local training set as a clean validation set for training the probabilistic label model. The remaining smart contracts in the local training set are used to generate a noisy training set;
[0070] S5: Set the maximum noise level for both types of noise to 30%. For a given symmetric label noise level (5%, 10%, 15%, 20%, 25%, 30%), each smart contract in the training set is randomly flipped with a probability of (5%, 10%, 15%, 20%, 25%, 30%), generating a dataset with symmetric label noise of (5%, 10%, 15%, 20%, 25%, 30%). For different false negative label noise levels (5%, 10%, 15%, 20%, 25%, 30%), contracts marked as vulnerable are randomly flipped with a probability of (5%, 10%, 15%, 20%, 25%, 30%).
[0071] S6: Build a deep learning model and evaluate label noise. Use the sequence learning-based model CBGRU and the model CGE, which uses ensemble graph learning and expert-defined features. The data center of the federated learning initializes the global deep learning model parameters and broadcasts them to all data owners participating in the federated learning process.
[0072] S7: In federated learning, each data owner calibrates their local noisy dataset using a probabilistic label estimation model. A simple multilayer perceptron (MLP) is used as the scoring network. This network consists of a 64-dimensional hidden layer, batch normalization, and a ReLU activation function. The Adam optimizer is used to optimize the probabilistic label estimation network.
[0073] S8: In federated learning, each data owner updates its local model using the calibrated dataset and the parameters of the received global model;
[0074] S9: In federated learning, each data owner uploads the updated local model parameters to the data center, which then weights and aggregates the parameters of all local models to update the global model parameters.
[0075] S10: The subsequent global model parameters will be updated again and broadcast to the data owner, the training process will be repeated, and S6-S9 will be repeated;
[0076] S11: Use accuracy and F1 score as evaluation metrics to measure the performance of smart contract vulnerability detection.
[0077] In this method, a clean smart contract vulnerability dataset is first created. Then, to address potential labeling errors in real-world scenarios, a noisy dataset with symmetric label noise and false negative label noise is constructed. Specifically, symmetric label noise represents a certain proportion of incorrect labels randomly assigned across all categories, while false negative label noise specifically simulates "missed detections" in vulnerability detection results. By artificially adding these two types of noise to the clean dataset, a noisy dataset that more closely resembles the real-world distribution is obtained, providing a foundation of samples for subsequent noise-resistant federated learning detection.
[0078] After constructing the noisy dataset, the entire dataset is divided into training, validation, and test sets. The training set is then evenly distributed among multiple data owners based on the principle of roughly equal data volume. At this stage, the data center initializes the parameters of the global deep learning model and broadcasts the initial model parameters to all data owners, enabling each party to conduct training locally. This process ensures that in a distributed environment, each owner has the same starting model and can perform personalized training iterations on their respective local data.
[0079] During the local training phase, each data owner performs label calibration on their local noisy dataset based on a probabilistic label estimation model to correct erroneous label information as much as possible. This estimation model re-evaluates or assigns more reliable label probabilities to noisy samples in the dataset based on the known characteristics of symmetric label noise and false negative label noise. After calibration, each data owner uses the calibrated local dataset and the received global model parameters to train a local deep learning detection model, thus maintaining high model accuracy and robustness even in noisy environments.
[0080] After completing local model training, each data owner uploads the trained model parameters to the data center. The data center performs weighted aggregation of the model parameters from different owners to update the global model parameters, and then broadcasts the updated global model back to all data owners. This process is repeated according to a pre-set number of training rounds or performance thresholds until the global model meets the preset requirements on the validation or test set. Through this cycle, the federated learning system can still obtain a robust and highly accurate detection model in noisy smart contract vulnerability data environments.
[0081] In S4, the training set is evenly distributed among multiple data owners. Multiple data owners refer to the fact that in federated learning, the data center consists of multiple data owners, each of whom owns a local dataset.
[0082] In step S6, the broadcast is sent to all data owners in the federated learning process. This is intended to ensure that the data center transmits the parameters of the global deep detection model to all participating data owners, thereby ensuring that each data owner has a consistent starting model for local training.
[0083] In step S7, the local noise dataset is calibrated using the probability label estimation module. The probability label estimation model includes: probability label modeling, probability label estimation network, and optimization.
[0084] (1) Probabilistic Label Modeling. Probabilistic label modeling is a key technical step in this invention, aiming to infer the probability of the true label from noisy labels by modeling the conditional dependencies between labels. Its purpose is to estimate the probability of the true label for each sample by modeling the relationship between local labels, pseudo-labels, and true labels. Local labels and pseudo-labels are considered as observed noise labels. The probabilistic labeling model is derived based on Bayes' theorem and Markov random field models. The probabilistic labeling model is expressed as follows:
[0085]
[0086] in, To observe the noise label, This is the true label of smart contracts. Features of smart contracts This represents the prior probability that the smart contract's true label is 1 (i.e., it contains vulnerabilities).
[0087] This is a constant estimated from each data owner's local clean validation dataset. The probabilistic labeling model estimates the probabilistic label for a given smart contract by weighting and aggregating observed noisy labels based on their accuracy scores. This weighted aggregation mechanism allows the model to assign greater importance to more reliable labels, thereby estimating the true label more accurately.
[0088] (2) Probability Label Estimation Network. To optimize the accuracy of probability labels, an appropriate accuracy scoring function is used to estimate and continuously update the accuracy score of the observation noise labels in each smart contract. For example... Figure 2 As shown, a deep neural network is used as the probability label estimation network. For each data owner Parametric probabilistic labeling model. Accuracy scoring function in the network. By rating network Parameterization. For any tagged smart contract First, generate pseudo tags. and one-hot representation The feature embedding of the smart contract is obtained by removing the output layer from the global model. Furthermore, validate the dataset locally with a clean output. Estimate local vulnerability dataset Class distribution Then the rating network by and As input, the accuracy score vector for predicting observed noise labels The last layer is The transformation layer is used to normalize the accuracy score. Finally, the aggregator... Combined with local class distribution One-hot representation of observed noise labels and accuracy score Generate probability labels: .
[0089] (3) Optimization. To improve the accuracy of label calibration, the probabilistic label estimation network and the local deep detection model are jointly optimized. The optimization objective is to minimize the loss of the detection model on the local clean validation dataset. This can be expressed as:
[0090]
[0091] in, For a clean local validation dataset, For probability label estimation network, Features of smart contracts To observe the noise label, Let be the prior probability that the smart contract is truly labeled as 1 (i.e., contains a vulnerability). For the first The local depth detection model of the data owner for smart contracts The prediction results.
[0092] To develop a probabilistic label estimation network, a meta-learning-based training algorithm is used to jointly optimize the probabilistic label estimation network and the local deep detection model with the validation set. For example... Figure 3 As shown, the algorithm works through iterative internal and external training steps.
[0093] In the internal training step, calibration labels generated by a probabilistic label estimation network are used to optimize the local depth detection model. (Probabilistic label estimation network) For each smart contract Generate probability labels Using the parameters of the global model to improve the local depth detection model Parameter initialization, generating predictions Calculate the training loss and update the local model parameters. Local deep detection model. The update is as follows:
[0094] .
[0095] in, For internal training learning rate, For local training set Internal training loss.
[0096] In the external training step, based on the updated local deep detection model... In the validation dataset On the validation loss update probability label estimation network , means as follows:
[0097]
[0098] The calculation method is as follows:
[0099]
[0100] in, For external training learning rate, To indicate in the validation dataset The expected verification loss.
[0101] Furthermore, in S9, the global model parameters are updated by aggregating parameters from all data owners in the data center, as shown in the following process:
[0102]
[0103] in, For local model parameters, These are global model parameters. The number of samples owned by each data owner. The total number of data owners.
[0104] This invention provides a noise-resistant federated smart contract vulnerability detection system with probabilistic label estimation, specifically comprising:
[0105] The dataset building module is used to build the dataset and divide it into training, validation, and test sets.
[0106] The probability label estimation module estimates the probability of the true label for each sample by modeling the relationship between local labels, pseudo labels, and real labels.
[0107] The meta-learning training module, based on the meta-learning training algorithm, enables joint optimization of the probabilistic label estimation network and the local deep detection model with the validation set.
[0108] This invention is primarily applied to the field of smart contract vulnerability detection. In practical applications, it can be used for security testing of smart contracts on various blockchain platforms. For example, in blockchain applications in the financial sector, the security of smart contracts involving large-scale financial transactions is paramount. This invention can perform noise-resistant federated vulnerability detection on smart contracts from different platforms. In blockchain applications in the supply chain sector, smart contracts are used to manage aspects such as goods tracking and transactions. This invention can perform noise-resistant federated vulnerability detection on smart contracts in the supply chain, ensuring the secure and stable operation of the supply chain process and preventing problems such as lost goods and incorrect transactions caused by contract vulnerabilities.
[0109] In terms of experimental implementation, researchers constructed a smart contract dataset containing different types and levels of labeled noise, dividing it into training, validation, and test sets. Then, accuracy and F1 score were used as evaluation metrics to measure its performance in smart contract vulnerability detection tasks. Under different noise settings (homogeneous noise, heterogeneous noise levels and types), the effectiveness and technical value of this method in the field of smart contract vulnerability detection were demonstrated. It effectively addresses the problems of existing technologies in handling labeled noise and improving detection accuracy, providing strong technical support for the security of smart contracts.
[0110] This invention was compared with state-of-the-art noise label learning methods. The baseline was based on FedAvg, which was also used as an additional baseline experimental result. Comparisons at homogeneous noise levels are shown in Tables 1 and 2. Comparisons at heterogeneous noise levels are shown in Tables 3 and 4.
[0111] On two vulnerability datasets corrupted by symmetric or false negative label noise, CBGRU and CGE consistently outperform all baseline methods in terms of F1 scores. Specifically, under false negative label noise, this invention improves the F1 scores of CBGRU and CGE by 8.08% and 2.68% on the Reentrancy dataset, and by 12.31% and 2.9% on the Timestamp dataset, compared to the second-best result. Similarly, under symmetric label noise, this invention increases the F1 score of CBGRU by 4.43% on Reentrancy and by 3.47% on Timestamp. For CGE, it improves the F1 score by 16.13% on Reentrancy and by 2.43% on Timestamp. This demonstrates the effectiveness of this invention in addressing homogeneous label noise in smart contract vulnerability detection.
[0112] Table 1. Reentrancy performance of CBGRU and CGE under 30% symmetric label noise and 30% false negative label noise.
[0113]
[0114] Table 2. Timestamp performance of CBGRU and CGE under 30% symmetric tag noise and 30% false negative tag noise.
[0115]
[0116] To evaluate the performance of this invention under heterogeneous label noise levels, the label noise of the four data owners was set to 20%, while the label noise of the remaining data owners was set to 30%. This invention achieved the highest F1 scores on the Reentrancy dataset (82.34% and 83.69% for CBGRU and CGE, respectively) and on the Timestamp dataset (90.75% and 84.79%, respectively). Under heterogeneous levels of symmetric label noise and false negative label noise, this invention consistently outperformed the next best results. These results confirm the effectiveness of this invention in real-world scenarios involving heterogeneous label noise levels.
[0117] Table 3. Reentrancy performance of CBGRU and CGE under heterogeneous level symmetric tag noise and false negative tag noise.
[0118]
[0119] Table 4. Timestamp performance of CBGRU and CGE under heterogeneous levels of symmetric tag noise and false negative tag noise.
[0120]
[0121] To evaluate its effectiveness in addressing label noise with heterogeneous types, the label noise for four data owners was set to 30% symmetric label noise, while the remaining data owners were set to 30% false negative label noise. This invention achieved the highest F1 score, with 84.79% for CBGRU and 87.22% for CGE on the Reentrancy dataset, and 85.87% for CBGRU and 85.89% for CGE on the Timestamp dataset. These results demonstrate that the proposed invention effectively integrates reliable global and local vulnerability knowledge from data owners, accurately calibrating labels and mitigating the impact of heterogeneous label noise. The results are shown in Table 5.
[0122] Table 5. Comparison of Reentrancy and Timestamp performance under heterogeneous tag noise. "-" indicates no results.
[0123]
[0124] This invention evaluated its performance at different noise levels, as shown in Table 6. Regardless of the noise type, the average F1 score of both CBGRU and CGE consistently decreased with increasing label noise levels. Specifically, at 30% label noise, the average F1 score decreased by 13.76% to 24.098%. This performance decline is primarily attributed to the model's tendency to overfit noisy samples during training. Table 6 shows that the performance of the deep detection model remains relatively stable until the training set contains 20% symmetric label noise or 15% to 25% false negative label noise. Specifically, in the case of symmetric label noise, the average performance metric of CBGRU does not show a significant decrease until the noise level reaches 20%. A similar trend was observed for CGE with increasing symmetric label noise levels. The trend plots in Table 6 are shown below. Figure 4 and Figure 5 .
[0125] Table 6 shows the average performance of CBGRU and CGE at different levels of reentrancy and timestamp.
[0126]
[0127] To evaluate the contributions of the different components of this invention (i.e., the probabilistic label estimation network and the meta-learning-based training algorithm), ablation experiments were conducted under symmetric label noise and false negative label noise, as shown in Table 7. The results of this ablation study validate that the combined components of this invention work synergistically to improve the performance of deep detection models with label noise. Using the probabilistic label model alone results in a global deep detection model with limited utility. This deficiency is largely due to the lack of clean samples, which hinders effective training of the probabilistic label model. Conversely, when the meta-learning-based training algorithm is combined with the probabilistic label model, significant improvements in F1 scores are achieved: 63.08% for Reentrancy and 77.62% for Timestamp under symmetric label noise. The global deep detection model achieves F1 scores of 80.34% and 85.24% under false negative label noise, respectively. These results demonstrate that, compared to the baseline method FedAvg, the F1 scores for Reentrancy and Timestamp are improved by 5.38% and 4.84%, respectively, in symmetric label noise environments, and by 19.91% and 12.31%, respectively, in false-negative label noise environments. These findings highlight the crucial role of meta-learning-based training algorithms in improving the calibration accuracy of probabilistic label models. By leveraging the meta-learning paradigm, this algorithm effectively enhances the model's ability to correct noisy labels, even when only a limited number of clean samples are available.
[0128] Table 7. Ablation experiments under 30% symmetric label noise and 30% false negative label noise. √ indicates the corresponding section was used. “_” indicates no results.
[0129]
[0130] It should be noted that embodiments of the present invention can be implemented in hardware, software, or a combination of both. The hardware portion can be implemented using dedicated logic; the software portion can be stored in memory and executed by a suitable instruction execution system, such as a microprocessor or dedicated-design hardware. Those skilled in the art will understand that the above-described devices and methods can be implemented using computer-executable instructions and / or included in processor control code, for example, such code provided on a carrier medium such as a disk, CD, or DVD-ROM, a programmable memory such as read-only memory (firmware), or a data carrier such as an optical or electronic signal carrier. The devices and modules of the present invention can be implemented by hardware circuitry such as very large-scale integrated circuits or gate arrays, semiconductors such as logic chips, transistors, or programmable hardware devices such as field-programmable gate arrays, programmable logic devices, etc., or by software executed by various types of processors, or by a combination of the above-described hardware circuitry and software, such as firmware.
[0131] The above description is merely a specific embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any modifications, equivalent substitutions, and improvements made by those skilled in the art within the scope of the technology disclosed in the present invention, and within the spirit and principles of the present invention, should be covered within the scope of protection of the present invention.
Claims
1. A method for detecting vulnerabilities in noise-resistant federated smart contracts with probabilistic label estimation, characterized in that, The method includes the following steps: Create a dataset containing clean smart contract vulnerabilities and construct a noisy dataset with symmetric label noise and false negative label noise; The dataset is divided into a training set, a validation set, and a test set, and the training set is evenly distributed among multiple data owners; The data center initializes the global deep learning model parameters and broadcasts them to all data owners participating in the federated learning process. Calibrate a local noisy dataset using a probabilistic label estimation model; A local depth detection model is trained based on the calibrated local noise dataset and the parameters of the global receiving model. Local model parameters are uploaded to the data center, where all local model parameters are weighted and aggregated to update the global model parameters. The data center broadcasts the updated global model parameters to the data owner and repeats the training process until it is complete. The probabilistic label estimation model includes probabilistic label modeling, a probabilistic label estimation network, and an optimization step, wherein: Probabilistic label modeling models the relationship between local labels, pseudo labels, and real labels, and derives the probabilistic label model using Bayes' theorem and Markov random fields. The probabilistic label estimation network is implemented based on a deep neural network. It normalizes the accuracy score of the observation noise label and generates a probabilistic label. The probabilistic label estimation network is jointly optimized with the local deep detection model to minimize the loss on the local validation dataset.
2. The method for detecting vulnerabilities in noise-resistant federated smart contracts with probabilistic label estimation as described in claim 1, characterized in that, In the step of constructing the noise dataset, symmetric label noise is generated by randomly flipping smart contract labels with different probabilities, and false negative label noise is generated by randomly flipping smart contract labels marked as vulnerable with different probabilities.
3. The method for detecting vulnerabilities in noise-resistant federated smart contracts with probabilistic label estimation as described in claim 1, characterized in that, Meta-learning-based training algorithms include internal training steps and external training steps, wherein: In the in-training step, the calibration labels generated by the probabilistic label estimation network are used to optimize the local depth detection model; In the external training step, the network parameters are estimated by updating the probability labels using validation loss.
4. The method for detecting vulnerabilities in noise-resistant federated smart contracts with probabilistic label estimation as described in claim 1, characterized in that, The data center aggregates local model parameters based on weights, which are determined by the number of samples from each data owner. The weight aggregation process is based on the following formula: in, For local model parameters, For data owners The number of samples, This represents the total number of data owners.
5. The method for detecting vulnerabilities in noise-resistant federated smart contracts with probabilistic label estimation as described in claim 1, characterized in that, During federated learning, the global model parameter update and broadcasting steps are performed in fixed number of rounds until the global model's performance on the test set reaches the preset requirements or the number of training rounds reaches the upper limit; among them, the global training rounds of the CBGRU model are set to 50, and the global training rounds of the CGE model are set to 40.
6. A noise-resistant federated smart contract vulnerability detection system with probabilistic label estimation, applying the noise-resistant federated smart contract vulnerability detection method with probabilistic label estimation as described in any one of claims 1-5, characterized in that, The system includes: The data center is used for the initialization, parameter aggregation, and broadcasting of the global model; Multiple data owners, each of which includes a local data storage module, a model training module, a probability label estimation module, and a communication module; A communication network is used to connect data centers with multiple data owners, supporting encrypted data transmission and model parameter exchange; The data center includes: The parameter initialization unit is used to generate the initial parameters of the global deep learning model and distribute them to multiple data owners; The aggregation unit is used to receive local model parameters uploaded by multiple data owners, aggregate the model parameters based on weights, and update the global model parameters. The parameter broadcasting unit is used to distribute the updated global model parameters to multiple data owners; The data owners include: The data storage module is used to store local smart contract datasets, including training sets, validation sets, and test sets; The model training module is used to train the model based on the local dataset and global model parameters, and generate updated local model parameters. The probability label estimation module is used to calibrate the local noisy dataset, generate probability labels, and optimize the local depth detection model. The communication module is used to communicate with the data center regarding model parameters; The communication network supports data transmission based on security protocols, ensuring the integrity and security of data during local model parameter uploading and global model parameter broadcasting.