Method, device, computer equipment and storage medium for preventing model parameter theft
By constructing a honeypot model library and calculating attack probability based on access frequency and sample distribution, attackers are induced to access the honeypot model, which solves the problem of model theft attacks in machine learning as a service, improves security and accuracy, and reduces computational costs. Overhead and false positive rate.
Patent Information
- Application Number
- CN202110966502.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-08-23
- Publication Date
- 2024-09-06
- Estimated Expiration
- 2041-08-23
AI Technical Summary
Model theft attacks in machine learning as a service are difficult to prevent. Existing anti-theft methods affect model accuracy or generate high computational complexity, and it is difficult to balance security and accuracy.
Build a honeypot model library, generate honeypot models with different accuracy levels through multiple rounds of training, and calculate the attack probability based on user access frequency and sample distribution, induce attackers to access the honeypot model, reduce the accuracy of the stolen model, and ensure normal operation Accuracy of user requests.
It improves the accuracy of attack determination, reduces the false alarm rate and computing overhead, reduces the efficiency of model theft attacks, and enhances model security and business robustness.
Smart Images

Figure CN113821792B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of artificial intelligence and network security technology, and in particular to a method, device, computer equipment and storage medium for preventing model parameter theft when an intelligent model or system provides network services to the outside world. Background Art
[0002] With the rapid development of deep learning represented by deep neural networks, artificial intelligence technology has been widely used in speech recognition, natural language processing (NLP), image recognition, autonomous driving and other fields. Major artificial intelligence vendors have launched a new business model of "machine learning-as-a-service" (MLaaS), which remotely hosts complex machine learning models on cloud platforms and provides customers with program programming interfaces (APIs) for using the recognition, translation, classification, prediction and other functions of intelligent models. Users pay the intelligent model providers on a pay-per-query basis. The machine learning-as-a-service approach can provide flexible, convenient and economical intelligent services for small and medium-sized companies and individuals.
[0003] Recent studies have shown that machine learning as a service is vulnerable to model theft attacks. The attacker is under harsh restrictions: only black-box query access to the model, that is, the attacker can query the model with any input and observe the output probability; the attacker has limited data and cannot access a large amount of training data representing the target model. It is still possible for the attacker to conduct a model theft attack and train a clone model whose classification accuracy can be very close to the accuracy of the target model. Since it takes a lot of time, money and manpower to develop powerful intelligent models, intelligent models are important intellectual property of machine learning as a service provider. Stolen models can be used to generate adversarial samples to deceive the classification of models, provide vulnerabilities for security-critical applications (such as malware detection), identity authentication, etc., and may also leak information about the data used to train the model, leading to data privacy leakage issues. Therefore, under the premise of ensuring normal user use, the risk of model theft is greatly reduced, and efficient model anti-theft technology is particularly important for machine learning as a service provider.
[0004] However, the existing model anti-theft methods have the following disadvantages: 1) Output obfuscation methods can easily lead to reduced model accuracy and affect the user experience of normal users; 2) User access behavior monitoring can easily generate a large number of false alarms and has high computational complexity. Summary of the invention
[0005] This invention mainly proposes solutions to the problem of anti-theft of machine learning as a service models, specifically targeting the following issues:
[0006] 1) How to control the model information leakage problem to the greatest extent possible, limit the effectiveness of attackers stealing models, and block model stealing attacks. Even if model theft occurs, it is necessary to ensure that the accuracy of the stolen model is very poor;
[0007] 2) How to balance security and accuracy? On the basis of model security, it is also necessary to ensure that normal users' use is not affected and to ensure the accuracy of the normal request model.
[0008] 3) How to reduce the computational overhead of anti-theft methods and reduce the system latency caused by attack detection without affecting the machine learning as a service business system.
[0009] The goal of model anti-theft is to reduce the accuracy of the stolen model established by the attacker, while also ensuring high classification accuracy for normal clients to ensure the functional availability of the machine learning model and increase the cost for attackers to steal the model, thereby preventing attackers from attacking. The technical solution proposed in the present invention draws on the idea of cyberspace security honeypots to construct a series of honeypot models to mislead attackers into stealing the parameters of the honeypot models.
[0010] The technical solution adopted by the present invention is as follows:
[0011] A method for preventing model parameter theft comprises the following steps:
[0012] S1. Training multiple honeypot model libraries with different precisions: Build a honeypot model set, divide the training set into multiple parts and take out each training data in order, train all honeypot models in the honeypot model set for multiple rounds, and use the test set to test the accuracy of the honeypot model in each round. If the accuracy of the honeypot model is greater than the set threshold, terminate the next round of training; after multiple rounds of iterative training, generate honeypot models with different accuracy levels;
[0013] S2. Determine whether the request is initiated by an attacker: Calculate the attack probability of each request based on the user's access frequency and the distribution of query samples to determine whether the request is an attack behavior;
[0014] S3. Induce attackers to access the honeypot model: Induce requests with different attack probabilities to the honeypot model with corresponding accuracy.
[0015] Furthermore, step S1 includes the following sub-steps:
[0016] S101. Assume that the protected model is f, the training set of the model is S, the test set of the model is T, the output of the model is y=f(x), and the accuracy of the model f in the test set T is p;
[0017] S102. Randomly divide the training set S into k parts, and the size of each part is a fixed value, then S = {s1, s2, s3…, s k};
[0018] S103. Construct n honeypot model sets F = {f1, f2, f3…, f n}, the parameters of the honeypot model are randomly initialized, and the number of honeypot models is set according to the security requirements of the model; the thresholds of different accuracy rates are arranged from small to large P = {P1, P2, P3…, P n}, where the accuracy threshold P n The accuracy of the protected model needs to be much smaller than p, so that the accuracy of the model stealing is close to P n , nor will it cause great losses to the model owner;
[0019] S104. Take out each training data from the divided training set S in order, train all honeypot models of the honeypot model set F for multiple rounds, and use the test set T to test the accuracy of the honeypot model in each round. If the honeypot model f i The accuracy p i Greater than the set threshold P i , the next round of training is terminated; after multiple rounds of iterative training, honeypot models that meet different accuracy levels are generated;
[0020] S105. The trained honeypot model set F = {f1, f2, f3..., f n}Deploy to the server where the honeypot model library is located, and map each honeypot model service to a different network port Port = {port1, port2, port3..., port n}.
[0021] Furthermore, step S2 includes the following sub-steps:
[0022] S201. Extract the access information of the current requesting user from the access log database;
[0023] S202. Calculate each new sample x i The minimum distance set D from historical samples = {d min (x1),…d min (x i )}; Calculate the standard deviation Δ of set D, and then remove the samples in set D that are greater than three times the standard deviation Δ to obtain the distance set D′;
[0024] S203. According to the Piro-Wilk normal distribution test formula Calculate the normal distribution test of the distance set D′, where the size of the statistic W reflects the degree of deviation from the distribution. The closer the value is to 1, the closer the sample distribution is to the normal distribution.
[0025] S204. Calculate the probability value of the request being a normal user based on the user's access frequency and the distribution of query samples Then the possible attack p attack =1-pbenign;
[0026] S205. The user requests the service interface to execute steps S201 to S204 every 100 times.
[0027] Furthermore, in step S201, the access information of the current requesting user extracted includes: the number of times the user has accessed within a preset time interval and the historical samples uploaded by the user.
[0028] Furthermore, step S3 includes the following sub-steps:
[0029] S301. Set different induced attack thresholds τ = {τ1, τ2, τ3..., τ n ,}, the size of the threshold τ is from high to low;
[0030] S302. Determine whether the access request is from a normal user or a malicious attack. If p attack <τ n , it is determined to be a normal user request and the protected model y = f(x) is called; if p attack >τ n , then execute step S303;
[0031] S303. If τ i <p attack <τ i-1 , then induce the attacker to access the honeypot model y i =f i (x); if p attack >τ1, then induce the attacker to access the honeypot model with the lowest accuracy y1=f1(); if p attack >0.95, the access request is directly blocked and the requesting account is added to the firewall blacklist, prohibiting it from accessing the machine learning service interface within the preset time interval.
[0032] A device for preventing model parameter theft, based on the above method for preventing model parameter theft, at least comprises:
[0033] A firewall is used to filter out invalid or unauthorized access, including target data uploaded by end users through the API interface provided by the machine learning service provider;
[0034] The attack detector is used to determine whether the access is an attack request, and guide normal users to access the protected model, while the attacker accesses the honeypot model.
[0035] A computer device comprises a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of the above-mentioned method for preventing model parameter theft when executing the computer program.
[0036] A computer-readable storage medium stores a computer program, which, when executed by a processor, implements the steps of the method for preventing model parameter theft.
[0037] According to the characteristics of model stealing attacks, the present invention calculates the probability of possible attack requests based on the frequency of interface requests and the distribution of request samples, and induces attackers to access the honeypot model based on the pre-arranged honeypot model, which greatly enhances the security of the model and the robustness of the business. Compared with the existing solutions, it has the following beneficial effects and advantages:
[0038] 1. The probability of an attack is calculated based on the frequency of access and the distribution of request samples, which greatly improves the accuracy of attack determination and reduces false positives in attack detection;
[0039] 2. The sample distribution test is calculated every 100 request pollings, without the need to calculate the distribution test of a single sample, which reduces the computational overhead of the anti-theft method and reduces the system delay caused by attack detection;
[0040] 3. Using a honeypot model that can be updated periodically can control model information leakage without interfering with normal business, reducing the possibility of model theft attacks. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] Figure 1 is a flow chart of a method for preventing model parameter theft according to Embodiment 1 of the present invention;
[0042] Figure 2 is a schematic diagram of a device for preventing model parameter theft according to Embodiment 2 of the present invention;
[0043] Figure 3 It is a functional diagram of the attack detector of embodiment 2 of the present invention. DETAILED DESCRIPTION
[0044] In order to have a clearer understanding of the technical features, purposes and effects of the present invention, the specific implementation methods of the present invention are now described. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention, that is, the embodiments described are only part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without making creative work are within the scope of protection of the present invention.
[0045] Example 1
[0046] like Figure 1 As shown, this embodiment provides a method for preventing model parameter theft. The method is based on the idea of cyberspace security honeypots, constructs a series of honeypot models, and misleads attackers to steal the parameters of the honeypot models. The method includes the following steps:
[0047] S1. Training multiple honeypot model libraries with different precisions: Build a honeypot model set, divide the training set into multiple parts and take out each training data in order, train all honeypot models in the honeypot model set for multiple rounds, and use the test set to test the accuracy of the honeypot model in each round. If the accuracy of the honeypot model is greater than the set threshold, terminate the next round of training; after multiple rounds of iterative training, generate honeypot models with different accuracy levels;
[0048] S2. Determine whether the request is initiated by an attacker: Calculate the attack probability of each request based on the user's access frequency and the distribution of query samples to determine whether the request is an attack behavior;
[0049] S3. Induce attackers to access the honeypot model: Induce requests with different attack probabilities to the honeypot model with corresponding accuracy.
[0050] In the process of machine learning as a service, if the attacker returns the results through a large number of requests, the attacker can steal the parameters of the model by training a substitute model. This embodiment pre-sets the honeypot model library to induce the attacker's substitute model to steal the attack honeypot model, thereby protecting the real model parameters. At the same time, due to the existence of honeypot models with low to high precision, it is difficult for the attacker to determine whether the stolen model parameters belong to the real model.
[0051] Preferably, the method for generating the honeypot model of this embodiment is as follows:
[0052] S101. Assume that the protected model is f, the training set of the model is S, the test set of the model is T, the output of the model is y=f(x), and the accuracy of the model f in the test set T is p;
[0053] S102. Randomly divide the training set S into k parts, and the size of each part is a fixed value, for example: 1000, then S = {s1, s2, s3..., s k};
[0054] S103. Construct n honeypot model sets F = {f1, f2, f3…, f n}, the parameters of the honeypot model are randomly initialized, and the number of honeypot models is set according to the security requirements of the model. Generally, it can be set to 3; the thresholds of different accuracy rates are arranged from small to large P = {P1, P2, P3…, P n}, where the accuracy threshold P nThe accuracy of the protected model needs to be much smaller than p, so that the accuracy of the model stealing is close to P n , nor will it cause great losses to the model owner;
[0055] S104. Take out each training data from the divided training set S in order, train all honeypot models of the honeypot model set F for multiple rounds, and use the test set T to test the accuracy of the honeypot model in each round. If the honeypot model f i The accuracy p i Greater than the set threshold P i , the next round of training is terminated; after multiple rounds of iterative training, honeypot models that meet different accuracy levels are generated;
[0056] S105. The trained honeypot model set F = {f1, f2, f3..., f n}Deploy to the server where the honeypot model library is located, and map each honeypot model service to a different network port Port = {port1, port2, port3..., port n}.
[0057] The attacker steals the model parameters by training a substitute model through a large number of request return results. Existing studies have shown that the request samples of normal users usually satisfy a certain distribution (for example, normal distribution). In order to efficiently implement model stealing attacks and reduce the number of request interfaces, attackers usually use sample generation methods to construct special query samples, and these constructed samples usually do not satisfy the normal distribution.
[0058] Therefore, this embodiment calculates the possible attack probability of each request according to the user's access frequency and the distribution of query samples, and determines whether the request is an attack behavior, which specifically includes the following steps:
[0059] S201. Extracting the access information of the current requesting user from the access log database; specifically, the access information of the current requesting user extracted includes: the number of user accesses within a preset time interval (which can be set to 10 minutes) and historical samples uploaded by the user;
[0060] S202. Calculate each new sample x i The minimum distance set D from historical samples = {d min (x1),…d min (x i )}; In order to eliminate false positives caused by abnormal samples, the standard deviation Δ of set D is calculated, and then samples in set D that are greater than three times the standard deviation Δ are removed to obtain the distance set D′;
[0061] S203. According to the Piro-Wilk normal distribution test formula Calculate the normal distribution test of the distance set D′, where the size of the statistic W reflects the degree of deviation from the distribution. The closer the value is to 1, the closer the sample distribution is to the normal distribution.
[0062] S204. Calculate the probability value of the request being a normal user based on the user's access frequency and the distribution of query samples Then the possible attack p attack =1-pbenign;
[0063] S205. The user requests the service interface to execute steps S201 to S204 every 100 times.
[0064] The preset honeypot model library can induce the attacker to steal the honeypot model. Since there is a set of honeypot models with dynamically adjustable precision from low to high, it is difficult for the attacker to determine whether it is a honeypot model. Preferably, inducing requests with different attack probabilities to honeypot models with corresponding precision includes the following sub-steps:
[0065] S301. Set different induced attack thresholds τ = {τ1, τ2, τ3..., τ n ,}, the threshold τ is from high to low; specifically, when there are three honeypot models, the threshold τ can be set to 0.85, 0.65, and 0.55; in order to target the possibility of attacks such as model theft, honeypot models with different induction attack theft differences are used to avoid attackers from discovering the existence of honeypot models;
[0066] S302. Determine whether the access request is from a normal user or a malicious attack. If p attack <τ n , it is determined to be a normal user request and the protected model y = f(x) is called; if p attack >τ n , then execute step S303;
[0067] S303. If τ i <p attack <τ i-1 , then induce the attacker to access the honeypot model y i =f i (x); if p attack >τ1, then the attacker is induced to access the honeypot model with the lowest accuracy y1=f1(x); if p attack >0.95, the access request is directly blocked and the requesting account is added to the firewall blacklist, prohibiting it from accessing the machine learning service interface within a preset time interval (usually set to 1 hour).
[0068] With the introduction of the honeypot model set, when the set is large enough, the attacker's request will be mapped to multiple honeypot models, making it impossible for the attacker to accurately steal the model parameters. At the same time, the honeypot model can be updated and retrained periodically. This can greatly reduce the effectiveness of model stealing attacks without interfering with normal business.
[0069] It should be noted that, for the sake of simplicity of description, this embodiment is described as a series of action combinations, but those skilled in the art should be aware that this application is not limited by the order of the actions described, because according to this application, some steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by this application.
[0070] Example 2
[0071] This embodiment is based on embodiment 1:
[0072] This embodiment provides a device for preventing model parameter theft, such as Figure 2 As shown in the figure, it mainly consists of seven parts: firewall, switch, attack detector, honeypot model library, protected model, and log database. They are connected to the machine learning as a service network through networking to form a complete anti-theft MLaaS system. The working principle of this embodiment is independent of the specific deployment method. Figure 2 A schematic diagram of a device for preventing model parameter theft is given to illustrate the working principle.
[0073] like Figure 2 As shown in Figure 1, the end user uploads the target data through the API interface provided by the machine learning service provider, and the firewall rules filter out invalid or unauthorized access; Figure 3 As shown, the attack detector determines whether it is an attack request, and finally guides the normal user to access the protected model, while the attacker accesses the honeypot model.
[0074] Example 3
[0075] This embodiment is based on embodiment 1:
[0076] This embodiment provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the steps of the method for preventing model parameter theft in Embodiment 1 are implemented. The computer program may be in source code form, object code form, executable file, or some intermediate form.
[0077] Example 4
[0078] This embodiment is based on embodiment 1:
[0079] This embodiment provides a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the steps of the method for preventing model parameter theft in Embodiment 1. The computer program may be in source code form, object code form, executable file, or some intermediate form, etc. The storage medium includes: any entity or device capable of carrying computer program code, recording medium, computer memory, read-only memory (ROM), random access memory (RAM), electric carrier signal, telecommunication signal, and software distribution medium, etc. It should be noted that the content contained in the storage medium may be appropriately increased or decreased according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, the storage medium does not include electric carrier signals and telecommunication signals.
Claims
1. A method for preventing model parameter theft, characterized in that: The following steps are involved: S1. Training multiple honeypot model libraries with different precisions: Build a honeypot model set, divide the training set into multiple parts and take out each training data in order, train all honeypot models in the honeypot model set for multiple rounds, and use the test set to test the accuracy of the honeypot model in each round. If the accuracy of the honeypot model is greater than the set threshold, terminate the next round of training; after multiple rounds of iterative training, generate honeypot models with different accuracy levels; S2. Determine whether the request is initiated by an attacker: Calculate the attack probability of each request based on the user's access frequency and the distribution of query samples to determine whether the request is an attack behavior; S3. Induce attackers to access the honeypot model: Induce requests with different attack probabilities to the honeypot model with corresponding accuracy; Step S1 includes the following sub-steps: S101. Assume that the protected model is , the training set of the model is , the test set of the model is The output of the model is ,in For training samples, the model In the test set The accuracy of ; S102. The training set , randomly divided into k parts, each of which has a fixed size, then ; S103. Build a set of n honeypot models with the same network structure , the parameters of the honeypot model are randomly initialized, and the number of honeypot models is set according to the security needs of the model; the thresholds of different accuracy rates are set in ascending order , where the accuracy threshold Need to be much less accurate than the protected model , so that the accuracy of model stealing is close to , nor will it cause great losses to the model owner; S104. From the divided training set Take out each training data in order, and train the honeypot model set in multiple rounds All honeypot models are tested with test set T in each round. If the honeypot model The accuracy Greater than the set threshold , the next round of training is terminated; after multiple rounds of iterative training, honeypot models that meet different accuracy levels are generated; S105. Collect the trained honeypot models Deploy to the server where the honeypot model library is located, and map each honeypot model service to a different network port ; Step S2 includes the following sub-steps: S201 extracts the current requesting user's access information from the access log database; S202. Calculate each new sample The minimum distance set from historical samples ; Calculate the set Standard Deviation , and then remove the set More than three standard deviations The samples of ; S203. According to the Piro-Wilk normal distribution test formula , calculate the distance set A normal distribution test of The size of reflects the degree of deviation of the distribution. The closer the value is to 1, the closer the sample distribution is to the normal distribution. S204. Calculate the probability value of the request being a normal user based on the user's access frequency and the distribution of query samples , then possible attacks ; S205 user request service interface every 100 times to perform step S201 ~ step S204; Step S3 includes the following sub-steps: S301. Set different induced attack thresholds according to the number of honeypot models , threshold The size is from high to low; S302. Determine whether the access request is a normal user or a malicious attack. If < , it is considered a normal user request and calls the protected model ;like Otherwise, go to step S303; S303. If < < , then induce the attacker to access the honeypot model ;like , then the attacker is induced to access the honeypot model with the lowest accuracy ;like , the access request is directly blocked and the requesting account is added to the firewall blacklist, prohibiting it from accessing the machine learning service interface within the preset time interval.
2. The method for preventing model parameter theft according to claim 1, characterized in that: In step S201, the access information of the current requesting user extracted includes: the number of times the user has accessed within a preset time interval, and the historical samples uploaded by the user.
3. A device for preventing model parameter theft, based on the method for preventing model parameter theft according to any one of claims 1 or 2, characterized in that: At least: A firewall to filter out invalid or unauthorized access, including target data uploaded by end users through the API interface provided by the machine learning as a service provider; The attack detector is used to determine whether the access is an attack request, and guide normal users to access the protected model, while the attacker accesses the honeypot model.
4. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that: When the processor executes the computer program, the steps of the method for preventing model parameter theft according to any one of claims 1 or 2 are implemented.
5. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the steps of the method for preventing model parameter theft according to any one of claims 1 or 2 are implemented.
