Method for detecting security of model service and related device
By detecting the lifecycle of cached information and request behavior of the model service, the security risks in the KV cache sharing process are resolved, and the security detection and analysis of the model service are realized.
Patent Information
- Application Number
- CN202411053215.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-01
- Publication Date
- 2026-01-09
- Estimated Expiration
- 2044-08-01
AI Technical Summary
In existing technologies, there are security risks when model services use key-value cache sharing. Users can infer other users' requests through the shared channel, leading to security problems.
By acquiring the cache information and lifecycle of the model service, security checks are performed on the cache sharing process. The lifecycle, request processing time, request content, and return information are monitored to determine the security of cache sharing and generate alarm information to eliminate security risks.
Effectively detect and eliminate security risks in the KV cache sharing process in model services, provide security analysis methods, and ensure the security of model services.
Smart Images

Figure CN119128895B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present disclosure relates to the technical field of artificial intelligence, and in particular, to a model service security detection method and related equipment. BACKGROUND
[0002] This section is intended to provide background or context to the embodiments of the disclosure recited in the claims. The description herein does not constitute admission that the prior art is prior art nor does it constitute an admission of any description in this section pertaining to background or context.
[0003] With the continuous development of artificial intelligence technology, model services have shown superior performance in aspects such as dialogue question answering, text generation, and language translation.
[0004] In the inference process of the model, a Key-Value Cache (KV Cache) sharing method is used to save the calculation time and calculation resources of the model inference process.
[0005] However, this method has certain security problems. SUMMARY
[0006] Therefore, the purpose of the present disclosure is to provide a model service security detection method and related equipment, which at least solves one of the technical problems in the related art to some extent.
[0007] To achieve the above purpose, a first aspect of the present disclosure provides a model service security detection method, comprising:
[0008] obtaining cache information of a first model service, the cache information being generated based on a first request sent to the first model service;
[0009] performing security detection on the first model service based on a life cycle of the cache information, to obtain a security detection result of cache sharing of the first model service.
[0010] In some embodiments, performing security detection on the first model service based on a life cycle of the cache information, to obtain a security detection result of cache sharing of the first model service, comprises:
[0011] if the life cycle of the cache information is extended based on user reasons, determining that the security detection result of cache sharing of the first model service is failed.
[0012] In some embodiments, the method further comprises: obtaining a second request sent by a user to the first model service.
[0013] The if the life cycle of the cache information is extended based on user reasons, determining that the security detection result of cache sharing of the first model service is failed, comprises:
[0014] obtaining a life cycle of the cache information;
[0015] if the life cycle of the cache information is greater than a preset life cycle threshold, determining an abnormal reason of the life cycle of the cache information;
[0016] if the abnormal reason includes that the life cycle of the cache information is prolonged based on the second request, determining that a security detection result of cache sharing of the first model service is failed.
[0017] In some embodiments, the method further includes:
[0018] in response to the abnormal reason including that the cache information is not cleared based on a preset clearing command, determining that the security detection result of cache sharing of the first model service is failed.
[0019] In some embodiments, the method further includes:
[0020] obtaining a third request sent by a user to the first model service;
[0021] performing security detection on the first model service based on return information of the third request, to obtain a security detection result.
[0022] In some embodiments, the performing security detection on the first model service based on the return information of the third request, to obtain the security detection result, includes:
[0023] obtaining a request processing time of the third request;
[0024] if a number of the third requests belonging to the same user is greater than a first preset number and the corresponding request processing time is less than a preset time threshold within a first preset time period, determining that the security detection result of cache sharing of the first model service is failed.
[0025] In some embodiments, the performing security detection on the first model service based on the return information of the third request, to obtain the security detection result, includes:
[0026] obtaining return information of the third request belonging to multiple users;
[0027] if an order of the return information of the third request of a target user in the multiple users is changed and a number of the third requests with the changed order is greater than a second preset number within a second preset time period, determining that the security detection result of cache sharing of the first model service is failed.
[0028] In some embodiments, the method further includes:
[0029] obtain a fourth request sent by a user to the first model service;
[0030] perform security detection on the first model service based on request content of the fourth request, to obtain a security detection result.
[0031] In some embodiments, performing security detection on the first model service based on request content of the fourth request, to obtain a security detection result, includes:
[0032] obtaining request content of the fourth request;
[0033] If the request content of the fourth request of the same user is the same or similar within a third preset time period, and / or the number of the fourth request is greater than a third preset number, it is determined that the security detection result of cache sharing of the first model service fails.
[0034] In some embodiments, performing security detection on the first model service based on request content of the fourth request, to obtain a security detection result, includes:
[0035] obtaining request content of the fourth request;
[0036] obtaining a user setting request parameter in the request content;
[0037] In response to the user setting request parameter satisfying a preset condition, it is determined that the security detection result of cache sharing of the first model service fails.
[0038] In some embodiments, the user setting request parameter satisfying a preset condition includes at least one of:
[0039] The length of the return information of the fourth request is less than a preset value;
[0040] The cache information generated based on the fourth request is not stored in the first model service.
[0041] Based on the same inventive concept, the second aspect of the present disclosure provides a security detection device of a model service, including:
[0042] An obtaining module is configured to obtain cache information of a first model service, the cache information being generated based on a first request sent to the first model service;
[0043] A detection module is configured to perform security detection on the first model service based on a life cycle of the cache information, to obtain a security detection result of cache sharing of the first model service.
[0044] Based on the same inventive concept, a third aspect of the present disclosure provides an electronic device comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, wherein the processor implements the method of the first aspect when executing the program.
[0045] Based on the same inventive concept, a fourth aspect of the present disclosure provides a non-transitory computer-readable storage medium storing computer instructions for causing the computer to execute the method of the first aspect.
[0046] Based on the same inventive concept, a fifth aspect of the exemplary embodiments of the present disclosure provides a computer program product comprising computer program instructions for causing a computer to execute the method of the first aspect when the computer program instructions are executed on the computer.
[0047] As can be seen from the above, the model service security detection method and related device provided by the present disclosure perform security detection on the first model service based on the life cycle of the existing cache information in the first model service, thereby obtaining a security detection result for cache sharing of the first model service, and performing security detection on the KV cache sharing process in the model service, thereby providing an effective security analysis method for the provider of the model service and eliminating security risks in the KV cache sharing process in the model service. BRIEF DESCRIPTION OF DRAWINGS
[0048] In order to more clearly illustrate the technical solutions in the present disclosure or the related art, the following will briefly introduce the drawings needed to be used in the embodiments or related art descriptions. Obviously, the drawings in the following description are only embodiments of the present disclosure, and for those skilled in the art, other drawings can also be obtained without creative labor based on these drawings.
[0049] Figure 1 An exemplary schematic diagram provided by the embodiments of the present disclosure is shown.
[0050] Figure 2 A flowchart of an exemplary method provided by the embodiments of the present disclosure is shown.
[0051] Figure 3 A schematic diagram of an exemplary device provided by the embodiments of the present disclosure is shown.
[0052] Figure 4 A hardware structure schematic diagram of an exemplary computer device provided by the embodiments of the present disclosure is shown. DETAILED DESCRIPTION
[0053] In order to make the objects, technical solutions and advantages of the present disclosure clearer, the present disclosure will be further described in detail below with reference to specific embodiments and in conjunction with the drawings.
[0054] It should be noted that, unless otherwise defined, technical terms or scientific terms used in the embodiments of the present disclosure should be understood as their common meanings to those skilled in the art to which the present disclosure pertains. The terms "first", "second", and similar terms used in the embodiments of the present disclosure do not denote any order, quantity, or importance, but are merely used to distinguish different components. The terms "include", "contain", and similar terms mean that the elements or objects before the terms encompass the elements or objects listed after the terms and their equivalents, and do not exclude other elements or objects. The terms "connect" or "connected" and similar terms do not mean physical or mechanical connections, but can include electrical connections, whether direct or indirect. The terms "upper", "lower", "left", "right", and the like are merely used to indicate relative positional relationships, and when the absolute positions of the described objects change, the relative positional relationships can also change accordingly.
[0055] It can be understood that, before using the technical solutions of the various embodiments of the present disclosure, the user will be informed of the type, scope of use, use scenario, and the like of the personal information involved in a proper manner, and the authorization of the user will be obtained.
[0056] For example, in response to receiving the active request of the user, prompt information is sent to the user to explicitly prompt the user that the operation requested to be performed will require the acquisition and use of personal information of the user. Thus, the user can voluntarily choose whether to provide personal information to the software or hardware, such as an electronic device, an application program, a server, or a storage medium, that performs the operation of the technical solutions of the present disclosure according to the prompt information.
[0057] As an optional but non-limiting implementation manner, in response to accepting the active request of the user, the manner of sending prompt information to the user may, for example, be a pop-up window manner, in which the prompt information can be presented in a textual manner. In addition, the pop-up window can also carry selection controls for the user to select "agree" or "disagree" to provide personal information to the electronic device.
[0058] It can be understood that the above notification and user authorization process is only illustrative and does not limit the implementation manners of the present disclosure, and other manners that meet the relevant laws and regulations can also be applied to the implementation manners of the present disclosure.
[0059] In the inference process of the model service, when a series of input tokens are given, the model service will generate the output tokens step by step through autoregressive manner. The inference process includes two stages: prefill stage and incremental decoding stage.
[0060] In the prefill phase, the model service processes all input tokens simultaneously, generating the first output token.
[0061] In the incremental decoding phase, the model service generates subsequent output tokens step by step, with each new output depending on previously generated tokens to build a complete response.
[0062] Key-Value Cache (KV Cache) is a crucial data structure generated during the model service inference process. A corresponding KV Cache is generated for each token generated in the prefill phase and the incremental decoding phase, which is used for reference when decoding subsequent tokens.
[0063] The characteristics of KV Cache include:
[0064] Computational dependency: The computation of KV Cache depends on all previous tokens, and the same token may generate different KV Caches in different contexts. For example, in the sentence "How do you do?", the two "do"s will generate different KV Caches.
[0065] Consistency: When the previous token is the same, the generated KV Cache is also the same. This can be seen in sentences like "I really enjoy coding" and "I really enjoy debugging", where "I", "really", and "enjoy" generate the same KV Cache in the same model.
[0066] Memory consumption: KV Cache is a significant bottleneck in the model service, as it consumes a large amount of memory resources.
[0067] KV Cache plays a crucial role in model service inference, but also brings challenges in computation and resource management, especially in high-concurrency multi-user scenarios.
[0068] In high-concurrency multi-user scenarios, when all previous tokens in multiple user requests are consistent, the generated KV Cache is also the same. In this case, through KV Cache sharing, subsequent requests can directly use the previously calculated KV Cache, saving time and resources for recalculation.
[0069] The key to KV Cache sharing is to ensure that the previous tokens between requests match completely. This matching ensures that KV Cache can be reused across different requests, improving computational efficiency.
[0070] However, the inventors of the present application found that although KV cache sharing improves computing efficiency and reduces memory consumption, it has a neglected security problem: the way of KV cache sharing creates a shared channel between multiple users, and users can speculate the questions of other users to the model service through this shared channel, thereby causing security problems.
[0071] As shown in Figure 1 , a first user sends a request to a model service, and the model service generates a corresponding KV cache in the model service when processing the request of the first user, and the KV cache stores the state information of the request of the first user.
[0072] A second user can carefully design and send a request to the model service, with the purpose of trying to reuse the KV cache of the first user. If the request of the second user reuses the KV cache of the first user, the return information of the second user will carry side channel information, which may include, for example, response time, power consumption, and other information of the model service. The second user can record and construct a new request based on the side channel information and send it to the model service again, and further analyze based on the side channel information carried in the return information.
[0073] The second user can determine that the word segmentation sequence input by himself is the same as or at least partially the same as the word segmentation sequence input by the first user by analyzing the side channel information, and thus can know the word segmentation sequence input by the first user, which affects the security of the model service.
[0074] Therefore, the present disclosure provides a model service security detection method to detect the security of the KV cache sharing process in the model service, provide an effective security analysis method for the provider of the model service, and eliminate the security risks in the KV cache sharing process in the model service.
[0075] As shown in Figure 2 , the model service security detection method comprises:
[0076] Step S101, obtaining cache information of a first model service, the cache information being generated based on a first request sent to the first model service.
[0077] The cache information of the first model service includes the KV cache of the first model service, and the cache information is generated based on the first request sent to the first model service.
[0078] In this embodiment, the existing cache information of the first model service can be obtained, and the security of the first model service in the KV cache sharing process is detected based on the existing cache information.
[0079] Step S103, performing security detection on the first model service based on the life cycle of the cache information, to obtain a security detection result of cache sharing of the first model service.
[0080] In this embodiment, the security detection on the first model service based on the life cycle of the existing cache information in the first model service is performed, so as to obtain the security detection result of the cache sharing of the first model service.
[0081] In this embodiment, the security detection on the first model service based on the life cycle of the existing cache information in the first model service is performed, so as to obtain the security detection result of the cache sharing of the first model service, thereby performing security detection on the KV cache sharing process in the model service, providing an effective security analysis method for the provider of the model service, and eliminating the security risks in the KV cache sharing process in the model service.
[0082] In some embodiments, the security detection on the first model service based on the life cycle of the cache information to obtain the security detection result of the cache sharing of the first model service includes: if the life cycle of the cache information is extended based on user reasons, determining that the security detection result of the cache sharing of the first model service is failed.
[0083] In this embodiment, if the life cycle of the cache information is extended based on user reasons, it means that the cache information is always trying to be reused, and such reuse behavior may be caused by user attack on the cache information, so there is a security risk. Therefore, in this case, it is determined that the security detection result of the cache sharing of the first model service is failed.
[0084] In some embodiments, the method further includes: obtaining a second request sent by a user to the first model service; and in step S103, if the life cycle of the cache information is extended based on user reasons, determining that the security detection result of the cache sharing of the first model service is failed, including:
[0085] Step S201, obtaining the life cycle of the cache information.
[0086] In this embodiment, when the life cycle of the KV cache exceeds the life cycle that it should exist, the security problem of the KV cache sharing may occur. Therefore, the potential security risk can be determined by monitoring the life cycle of the KV cache.
[0087] Step S203, if the life cycle of the cache information is greater than a preset life cycle threshold, determining an abnormal reason of the life cycle of the cache information.
[0088] In this embodiment, the life cycle threshold of the KV cache in the first model service can be pre-configured. The life cycle threshold of the KV cache in different first model services can be different. The life cycle threshold of the KV cache in the same first model service can be the same or different, which is not limited in this embodiment.
[0089] In this embodiment, the generation cycle of the KV cache corresponding to each first request can be compared with the pre-configured life cycle threshold in real time, so as to obtain the KV cache with an abnormal life cycle. When the life cycle of the KV cache is greater than the pre-configured life cycle threshold, it indicates that the life cycle of the KV cache is abnormal. At this time, it is necessary to further determine the reason for the abnormal life cycle of the KV cache.
[0090] In step S205, if the abnormal reason includes that the life cycle of the cache information is prolonged based on the second request, it is determined that the security detection result of the cache sharing of the first model service is failed.
[0091] In this embodiment, the KV cache with an abnormal life cycle is traced back to the source to determine the reason for the abnormal life cycle. If the abnormal life cycle is caused by a system reason, it can be ignored. If the abnormal life cycle is caused by a user request, for example, the KV cache is repeatedly reused and the life cycle is prolonged due to the user repeatedly sending the same or similar second request, the user may attempt to obtain the information corresponding to the KV request, and there is a security risk of KV cache sharing. Therefore, it can be determined that the security detection result of the cache sharing of the first model service is failed.
[0092] In some embodiments, the method further includes: in response to the abnormal reason including that the cache information is not cleared based on the pre-configured clearing command, determining that the security detection result of the cache sharing of the first model service is failed.
[0093] The KV cache can also be monitored whether it can be normally cleared. In the first model service, the clearing condition of the KV cache can be configured, such as timing clearing, clearing when the occupied memory exceeds a pre-configured value, etc. If the KV cache should be cleared but is not cleared, it may be that the user prevents the execution of the clearing process by some means, and there is a security risk of KV cache sharing.
[0094] In this embodiment, the log information corresponding to the KV cache with an abnormal life cycle can be queried, and it is determined from the log information whether the clearing command for the KV cache is awakened or the clearing command is awakened but the clearing command is not executed. When it is detected that the clearing command for the KV cache is not awakened or the clearing command is awakened but the clearing command is not normally executed, there is a security risk of KV cache sharing. Therefore, it can be determined that the security detection result of the cache sharing of the first model service is failed.
[0095] In some embodiments, the method further comprises: obtaining a third request sent by a user to the first model service; and performing security detection on the first model service based on return information of the third request to obtain a security detection result.
[0096] In this embodiment, the security detection on the first model service based on the return information of the third request can be performed to obtain a security detection result.
[0097] In some embodiments, the security detection on the first model service based on the return information of the third request to obtain a security detection result comprises:
[0098] In step S301, the request processing time of the third request is obtained.
[0099] In this embodiment, the request processing time can include the time between sending the third request to the first model service and returning the return information of the third request by the first model service, or the time of processing the third request by the first model service and generating the return information of the third request, which is not limited in this embodiment.
[0100] In step S303, if the number of the third requests belonging to the same user is greater than the first preset number and the corresponding request processing time is less than the preset time threshold within the first preset period, it is determined that the security detection result of the cache sharing of the first model service is failed.
[0101] In this embodiment, the return information of each third request can be analyzed in real time. If the request processing time of the third request processed by the first model service is significantly shortened, for example, less than the preset time threshold, the third request exists in the KV cache sharing situation.
[0102] If a user sends a large number of third requests within a period of time, for example, a first preset period, and the request processing time of these third requests is significantly shortened, it is possible that the user is continuously trying to reuse the KV cache, and there is a security risk of KV cache sharing, so it can be determined that the security detection result of the cache sharing of the first model service is failed.
[0103] The first preset period can be set according to the requirements of the first model service and the requirements of the user. When the first model service is a high-concurrency model service, that is, the first model service will process a large number of user requests in a short time, the first preset period can be set to a shorter time, for example, a few minutes, an hour, two hours, etc. When the first model service is a low-concurrency model service, the first preset period can be set to a longer time, for example, several hours, a day, several days, etc., which is not limited in this embodiment.
[0104] In some embodiments, the security detection of the first model service based on the return information of the third request comprises:
[0105] In step S401, the return information of the third request of a plurality of users is obtained.
[0106] In step S403, if the order of the return information of the third request of a target user in a plurality of users changes and the number of the third request whose order changes is greater than a second preset number within a second preset time period, it is determined that the security detection result of the cache sharing of the first model service fails.
[0107] In this embodiment, the return information of each third request can be analyzed in real time. If the order of the request changes when the first model service processes the third request of a plurality of users, there is a case of KV cache sharing.
[0108] For example, if users a, b and c send the third request to the first model service in order, the return information of the first model service is returned in order of a, b and c under normal circumstances.
[0109] When the order of the return information of the first model service changes, for example, the return information is returned in the order of c, a and b, it indicates that the second request sent by user c exists in the case of KV cache sharing.
[0110] If a same user, for example, user c, sends a large number of third requests within a time period, for example, a second preset time period, and the number of the third requests is greater than a second preset number, and the return information of the third request changes, it is possible that the user c continuously attempts to reuse the KV cache, and there is a security risk of KV cache sharing. Therefore, it can be determined that the security detection result of the cache sharing of the first model service fails.
[0111] The second preset time period can be set according to the requirements of the first model service and the requirements of the user. When the first model service is a high-concurrency model service, that is, the first model service processes a large number of user requests in a short time, the second preset time period can be set to a short time period, for example, a few minutes, an hour, two hours, etc. When the first model service is a low-concurrency model service, the second preset time period can be set to a long time period, for example, several hours, a day, several days, etc. This embodiment does not limit this.
[0112] In some embodiments, the method further comprises: obtaining a fourth request sent by a user to the first model service; and performing security detection on the first model service based on the request content of the fourth request to obtain a security detection result.
[0113] In this embodiment, the first model service can also be subjected to security detection based on the request content of the fourth request, so as to obtain a security detection result.
[0114] In some embodiments, the security detection of the first model service based on the request content of the fourth request comprises:
[0115] In step S501, the request content of the fourth request is obtained.
[0116] In this embodiment, the request content of each fourth request can be analyzed in real time to determine whether the user attempts to use KV cache sharing to endanger the security of the first model service.
[0117] In step S503, if the request content of the fourth request of the same user is the same or similar within a third preset time period, and / or the number of the fourth request is greater than a third preset number, it is determined that the security detection result of the cache sharing of the first model service is failed.
[0118] In this embodiment, by analyzing the request content of the fourth request sent by the user in real time, if the same user continuously sends the same or similar request within a time period, for example, a third preset time period, it is possible that the user is continuously trying to reuse the KV cache, and there is a security risk of KV cache sharing, so it can be determined that the security detection result of the cache sharing of the first model service is failed.
[0119] For example, when the request content of the fourth request of the user is "How do you do?" "How do you?" "How you do?" "What do you do?" and the like, the user may be continuously trying to reuse the corresponding KV cache, and there is a security risk of KV cache sharing.
[0120] The similarity between the request content of the plurality of fourth requests can be calculated, and when the similarity is greater than a preset threshold, it is determined that the plurality of fourth requests are similar requests.
[0121] In this embodiment, by analyzing the request content of the fourth request sent by the user in real time, if the same user sends a large number of requests within a time period, for example, a third preset time period, it is possible that the user is continuously trying to reuse the KV cache, and there is a security risk of KV cache sharing, so it can be determined that the security detection result of the cache sharing of the first model service is failed.
[0122] In this embodiment, by analyzing the request content of the fourth request sent by the user in real time, if the same user continuously sends a large number of same or similar requests within a time period, for example, a third preset time period, it is possible that the user is continuously trying to reuse the KV cache, and there is a security risk of KV cache sharing, so the security detection result of the cache sharing of the first model service is determined as failed.
[0123] The third preset time period can be set according to the requirements of the first model service and the requirements of the user. When the first model service is a high-concurrency model service, that is, the first model service will process a large number of user requests in a short time, the third preset time period can be set to a shorter time period, for example, a few minutes, an hour, two hours, etc. When the first model service is a low-concurrency model service, the third preset time period can be set to a longer time period, for example, several hours, a day, several days, etc. This embodiment does not limit this.
[0124] In some embodiments, the security detection of the first model service based on the request content of the fourth request includes:
[0125] In step S601, the request content of the fourth request is obtained.
[0126] In step S603, the user setting request parameter in the request content is obtained.
[0127] In step S605, in response to the user setting request parameter satisfying a preset condition, it is determined that the security detection result of the cache sharing of the first model service is failed.
[0128] In this embodiment, the request content of each fourth request can be analyzed in real time to determine whether there are some unreasonable, uncommon or extreme request parameter values in the request content of the fourth request. If there are unreasonable, uncommon or extreme request parameter values, it is possible that the user tries to use KV cache sharing to endanger the security of the first model service.
[0129] Therefore, in this embodiment, the user setting request parameter in the request content of the fourth request can be obtained, and the user setting request parameter is compared with a preset condition. If the preset condition is satisfied, it means that there are unreasonable, uncommon or extreme request parameter values, and there is a security risk of KV cache sharing, so the security detection result of the cache sharing of the first model service is determined as failed.
[0130] The user setting request parameter satisfying the preset condition includes at least one of the following: the length of the return information of the fourth request is less than a preset value; the cache information generated based on the fourth request is not stored in the first model service.
[0131] Generally, a user expects a model service to provide more detailed, more accurate, and more rich return information. If the request content of the request sent by the user, the user setting request parameter attached, sets the return information to be small, for example, the length of the return information of the fourth request is less than a preset value, it indicates that the user may not be a normal use of the model service, but is trying to reuse the KV cache, and there is a security risk of KV cache sharing, and therefore it can be determined that the security detection result of the cache sharing of the first model service is failed.
[0132] Generally, when a user sends a request to a model service, the user usually does not consider whether the request will generate a KV cache in the model service. If the request content of the request sent by the user, the user setting request parameter attached, sets the request not to store the corresponding KV cache in the first model service, the user may be trying to reuse the KV cache and does not want the KV cache corresponding to his request to be stored, and there is a security risk of KV cache sharing, and therefore it can be determined that the security detection result of the cache sharing of the first model service is failed.
[0133] In some embodiments, the method further comprises: generating an alarm information based on the security detection result; and the alarm information comprises at least one of the request content of the fourth request whose security detection result is failed, the return information of the third request, the user information to which the request belongs, and the alarm reason.
[0134] In this embodiment, when the security detection result is failed, an alarm information can be generated.
[0135] The alarm information can include at least one of the request content of the fourth request whose security detection result is failed, the return information of the third request, the user information to which the request belongs, and the alarm reason. The alarm reason can include that the KV cache is extended due to the user request or not properly cleared, the user repeatedly uses the KV cache for multiple times within a preset time period, the user repeatedly sends the same or similar request within a preset time period to try to reuse the KV cache, the request content includes abnormal parameters, and the like.
[0136] In this embodiment, the alarm information can provide the user with the user, content, location in the model service, and specific reason of the security risk of KV cache sharing, so that the user can further analyze and process based on the alarm information to maintain the security of the first model service.
[0137] It should be noted that the method of the embodiments of the present disclosure can be executed by a single device, such as a computer or a server, etc. The method of the embodiments can also be applied to a distributed scenario, and be completed by multiple devices cooperating with each other. In the case of such a distributed scenario, one of the multiple devices can only execute one or more steps in the method of the embodiments of the present disclosure, and the multiple devices can interact with each other to complete the method.
[0138] It should be noted that some embodiments of the present disclosure have been described above. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recited in the claims can be performed in a different order and still achieve desirable results. Additionally, the processes depicted in the figures do not necessarily require the particular order shown, or sequential order, to achieve the desired results. In certain implementations, multitasking and parallel processing can be advantageous.
[0139] Based on the same inventive concept, the present disclosure also provides a model service security detection apparatus corresponding to the method of any of the above embodiments.
[0140] Reference Figure 3 The model service security detection apparatus comprises:
[0141] The obtaining module 11 is configured to obtain cache information of a first model service, the cache information being generated based on a first request sent to the first model service;
[0142] The detection module 13 is configured to perform security detection on the first model service based on a lifetime of the cache information, to obtain a security detection result of cache sharing of the first model service.
[0143] In some embodiments, the detection module 13 is configured to determine that the security detection result of cache sharing of the first model service fails if the lifetime of the cache information is extended based on a user reason.
[0144] In some embodiments, the method further comprises: obtaining a second request sent to the first model service; and the detection module 13 is further configured to:
[0145] obtain the lifetime of the cache information;
[0146] determine an abnormal reason of the lifetime of the cache information if the lifetime of the cache information is greater than a preset lifetime threshold;
[0147] If the abnormal reason includes that the life cycle of the cache information is prolonged based on the second request, it is determined that the security detection result of the cache sharing of the first model service is failed.
[0148] In some embodiments, the apparatus is further configured to: in response to the abnormal reason including that the cache information is not cleared based on a preset clearing command, determine that the security detection result of the cache sharing of the first model service is failed.
[0149] In some embodiments, the detection module 13 is further configured to:
[0150] obtain a third request sent by a user to the first model service;
[0151] perform security detection on the first model service based on return information of the third request, to obtain a security detection result.
[0152] In some embodiments, the detection module 13 is further configured to:
[0153] obtain a request processing time of the third request;
[0154] If the number of the third requests belonging to the same user is greater than a first preset number and the corresponding request processing time is less than a preset time threshold within a first preset time period, it is determined that the security detection result of the cache sharing of the first model service is failed.
[0155] In some embodiments, the detection module 13 is further configured to:
[0156] obtain return information of the third requests belonging to multiple users;
[0157] If the order of the return information of the third requests of a target user in multiple users is changed and the number of the third requests with changed order is greater than a second preset number within a second preset time period, it is determined that the security detection result of the cache sharing of the first model service is failed.
[0158] In some embodiments, the detection module 13 is further configured to:
[0159] obtain a fourth request sent by a user to the first model service;
[0160] perform security detection on the first model service based on request content of the fourth request, to obtain a security detection result.
[0161] In some embodiments, the detection module 13 is further configured to:
[0162] obtain request content of the fourth request;
[0163] If the request contents of the fourth requests belonging to the same user are the same or similar within a third preset time period, and / or the number of the fourth requests is greater than a third preset number, it is determined that the security detection result of the cache sharing of the first model service fails.
[0164] In some embodiments, the detection module 13 is further configured to:
[0165] obtain the request content of the fourth request;
[0166] obtain a user setting request parameter in the request content;
[0167] In response to the user setting request parameter satisfying a preset condition, it is determined that the security detection result of the cache sharing of the first model service fails.
[0168] In some embodiments, the user setting request parameter satisfying the preset condition includes at least one of the following:
[0169] The length of the return information of the fourth request is less than a preset value;
[0170] The cache information generated based on the fourth request is not stored in the first model service.
[0171] For the convenience of description, the above apparatus is described in various modules in terms of functions. Of course, in the implementation of the present disclosure, the functions of each module can be implemented in one or more software and / or hardware.
[0172] The apparatus of the above embodiments is used to implement the corresponding method in any of the above embodiments, and has the beneficial effects of the corresponding method embodiment, which will not be repeated here.
[0173] Based on the same inventive concept, the present disclosure also provides an electronic device corresponding to the method of any of the above embodiments, which includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the method of any of the above embodiments when executing the program.
[0174] Figure 4 A more specific hardware structure of an electronic device is shown in the present embodiment. The device can include a processor 1010, a memory 1020, an input / output interface 1030, a communication interface 1040, and a bus 1050. The processor 1010, the memory 1020, the input / output interface 1030, and the communication interface 1040 are connected to each other through the bus 1050 for communication within the device.
[0175] The processor 1010 can be implemented by a general-purpose CPU (Central Processing Unit), a microprocessor, an ASIC (Application Specific Integrated Circuit), or one or more integrated circuits, etc., for executing relevant programs to implement the technical solutions provided by the embodiments of the present specification.
[0176] The memory 1020 can be implemented by a ROM (Read Only Memory), a RAM (Random Access Memory), a static storage device, a dynamic storage device, etc. The memory 1020 can store an operating system and other application programs, and when the technical solutions provided by the embodiments of the present specification are implemented by software or firmware, the relevant program codes are stored in the memory 1020 and called and executed by the processor 1010.
[0177] The input / output interface 1030 is configured to connect input / output modules to implement information input and output. The input / output modules can be configured as components in the device (not shown in the figure) or externally connected to the device to provide corresponding functions. The input devices can include a keyboard, a mouse, a touch screen, a microphone, various sensors, etc., and the output devices can include a display, a speaker, a vibrator, an indicator light, etc.
[0178] The communication interface 1040 is configured to connect a communication module (not shown in the figure) to implement communication interaction between the device and other devices. The communication module can realize communication through a wired manner (such as USB, network cable, etc.) or through a wireless manner (such as mobile network, WIFI, Bluetooth, etc.).
[0179] The bus 1050 includes a path for transmitting information between various components (such as the processor 1010, the memory 1020, the input / output interface 1030, and the communication interface 1040) of the device.
[0180] It should be noted that although the above device only shows the processor 1010, the memory 1020, the input / output interface 1030, the communication interface 1040, and the bus 1050, in the specific implementation process, the device can also include other components necessary for normal operation. In addition, those skilled in the art can understand that the above device can also only include components necessary to implement the solutions of the embodiments of the present specification, and does not have to include all the components shown in the figure.
[0181] The electronic device of the above embodiments is used to implement the corresponding method in any of the preceding embodiments, and has the beneficial effects of the corresponding method embodiments, which are not described here again.
[0182] Based on the same inventive concept, the disclosure also provides a non-transitory computer-readable storage medium storing computer instructions for causing a computer to perform the method of any of the above embodiments.
[0183] The computer-readable medium of the embodiments can include permanent and non-permanent, removable and non-removable media, which can be implemented by any method or technology to store information. The information can be computer-readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, magnetic cassette, magnetic tape, magnetic disk storage or other magnetic storage device, or any other non-transmission medium that can be used to store information accessible to a computing device.
[0184] The computer instructions stored in the storage medium of the above embodiments are used to cause the computer to perform the method of any of the above embodiments, and have the beneficial effects of the corresponding method embodiments, which are not repeated here.
[0185] Based on the same inventive concept, the disclosure also provides a computer program product including computer program instructions. In some embodiments, the computer program instructions can be executed by one or more processors of a computer to cause the computer and / or the processor to perform the method. Corresponding to the execution subject of each step in each embodiment of the method, the processor performing the corresponding step can belong to the corresponding execution subject.
[0186] The computer program product of the above embodiments is used to cause the computer and / or the processor to perform the method of any of the above embodiments, and has the beneficial effects of the corresponding method embodiments, which are not repeated here.
[0187] Those skilled in the art will appreciate that embodiments of the disclosure can be practiced in a variety of system environments, and that the application is not limited to any particular type of computing environment. Embodiments of the application can be implemented as a method, apparatus, or computer program product. Accordingly, the application can take the form of an entirely hardware embodiment, an entirely software embodiment (including firmware, resident software, micro-code, etc.) or an embodiment combining software and hardware aspects that can all generally be referred to herein as a "circuit," "module" or "system." Furthermore, embodiments of the application can take the form of a program product embodied in one or more computer readable medium(s) having computer readable program code embodied thereon.
[0188] Any combination of one or more computer readable medium(s) can be utilized. The computer readable medium can be a computer readable signal medium or a computer readable storage medium. A computer readable storage medium can be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. More specific examples (a non-exhaustive list) of the computer readable storage medium include the following: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or Flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In this document, the computer readable storage medium can be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device.
[0189] A computer readable signal medium can include a propagated data signal with computer readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated signal can take any of a variety of forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium can be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device.
[0190] Program code embodied on a computer readable medium can be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
[0191] Computer program code for carrying out operations of the present disclosure can be written in any combination of one or more programming languages, including an object oriented programming language such as Java, Smalltalk, C++ or the like and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code can execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the latter scenario, the remote computer can be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or the connection can be made to an external computer (for example, through the Internet using an Internet Service Provider).
[0192] It should be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general purpose computer, special purpose computer, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions / acts specified in the flowchart and / or block diagram block or blocks.
[0193] These computer program instructions can also be stored in a computer- readable medium that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable medium produce an article of manufacture including instructions which implement the functions / acts specified in the flowchart and / or block diagram block or blocks.
[0194] The computer program instructions can also be loaded onto a computer, other programmable data processing apparatus, or other device to cause a series of operational steps to be performed on the computer, other programmable apparatus or other device to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide processes for implementing the functions / acts specified in the flowchart and / or block diagram block or blocks.
[0195] Further, while operations of the present disclosure are described in a particular order in the figures, it is not necessary to perform the operations in the particular order shown, or in all of the operations shown, to achieve desirable results. Rather, the steps depicted in the flowcharts can be changed, performed in an alternative order, omitted, combined, and / or divided into additional steps.
[0196] The computer program product of the first aspect of the present application can comprise a computer readable storage medium having computer readable code embodied thereon. The computer readable storage medium can for example be a computer readable storage medium such as a floppy disk, a hard disk, a CD-ROM, a DVD, a memory stick, a memory card, a RAM, a ROM, or an optical storage.
[0197] It should be noted that although several modules or units for a device for action execution are mentioned in the above detailed description, this division is not mandatory. Indeed, according to an embodiment of the application, the features and functionalities of two or more modules or units described above can be embodied in one module or unit. Conversely, the features and functionalities of one module or unit described above can be further divided into several modules or units.
[0198] It should be understood by those of ordinary skill in the art that the above discussion of any embodiment is merely exemplary and is not intended to be limiting of the scope of the disclosure, including claims, to the particular examples described; the technical features between the above embodiments or different embodiments can also be combined, the steps can be implemented in any order, and there are many other changes to the aspects of the embodiments of the present disclosure as described above, which are not provided in detail in order to be brief. It is intended that the scope of the present disclosure, including claims, encompass such changes.
[0199] In addition, in order to simplify the description and discussion, and so as not to make the embodiments of the present disclosure difficult to understand, the well-known power / ground connections of integrated circuit (IC) chips and other components can or can not be shown in the provided drawings. In addition, the apparatus can be shown in the form of a block diagram in order to avoid making the embodiments of the present disclosure difficult to understand, and this also takes into account the fact that the details of the implementation of these block diagram apparatuses are highly dependent on the platform to be implemented (i.e., these details should be fully within the understanding of those skilled in the art). Where specific details (e.g., circuitry) are set forth in order to describe an illustrative embodiment of the present disclosure, it should be understood that the present disclosure can be practiced without these specific details or with variations to these specific details. Therefore, these descriptions should be considered as illustrative rather than limiting.
[0200] While the present disclosure has been described in connection with certain embodiments thereof, many modifications, substitutions, and variations will be apparent to those of ordinary skill in the art from the foregoing description. For example, other memory architectures (e.g., dynamic RAM (DRAM)) can use the embodiments discussed.
[0201] It is intended that the embodiments of the present disclosure encompass all such substitutions, modifications and variations as fall within the broad scope of the appended claims. Accordingly, any one or more of the features contributed by a given embodiment of the present disclosure can be combined with any one or more other features contributed by any other embodiment of the present disclosure, or indeed, by any other use or combination of features, to produce a further embodiment of the present disclosure.
Claims
1. A method for detecting key-value cache sharing security of a model service, comprising: obtaining key-value cache information of a first model service, the key-value cache information being generated based on a first request sent to the first model service; performing security detection on the first model service based on a lifetime of the key-value cache information to obtain a security detection result of key-value cache sharing of the first model service; wherein the performing security detection on the first model service based on the lifetime of the key-value cache information to obtain the security detection result of key-value cache sharing of the first model service comprises: if the lifetime of the key-value cache information is extended based on a user reason, determining that the security detection result of key-value cache sharing of the first model service fails.
2. The method of claim 1, wherein, Further comprising: obtaining a second request sent by a user to the first model service; the if the lifetime of the key-value cache information is extended based on a user reason, determining that the security detection result of key-value cache sharing of the first model service fails comprises: obtaining the lifetime of the key-value cache information; if the lifetime of the key-value cache information is greater than a preset lifetime threshold, determining an abnormal reason of the lifetime of the key-value cache information; if the abnormal reason comprises that the lifetime of the key-value cache information is extended based on the second request, determining that the security detection result of key-value cache sharing of the first model service fails.
3. The method of claim 2, further comprising: in response to the abnormal reason comprising that the key-value cache information is not cleared based on a preset clearing command, determining that the security detection result of key-value cache sharing of the first model service fails.
4. The method of claim 1, further comprising: obtaining a third request sent by a user to the first model service; performing security detection on the first model service based on return information of the third request to obtain a security detection result.
5. The method of claim 4, wherein, the performing security detection on the first model service based on the return information of the third request to obtain the security detection result comprises: obtaining a request processing time of the third request; if, within a first preset time period, the number of the third requests of the same user is greater than a first preset number and the corresponding request processing time is less than a preset time threshold, determining that the security detection result of key-value cache sharing of the first model service fails.
6. The method of claim 4, wherein, the performing security detection on the first model service based on the return information of the third request to obtain the security detection result comprises: obtaining return information of the third request of multiple users; if, within a second preset time period, the return information of the third request of a target user in multiple users changes in order and the number of the third requests that change in order is greater than a second preset number, determining that the security detection result of key-value cache sharing of the first model service fails.
7. The method of claim 1, further comprising: obtaining a fourth request sent by a user to the first model service; performing security detection on the first model service based on request content of the fourth request to obtain a security detection result.
8. The method of claim 7, wherein, The security detection of the first model service based on the request content of the fourth request obtains a security detection result, including: Obtaining the request content of the fourth request; If the request content of the fourth request of the same user is the same or similar within a third preset time period, and / or the number of the fourth request is greater than a third preset number, it is determined that the security detection result of the key-value cache sharing of the first model service is failed.
9. The method of claim 7, wherein, The security detection of the first model service based on the request content of the fourth request obtains a security detection result, including: Obtaining the request content of the fourth request; Obtaining the user setting request parameter in the request content; In response to the user setting request parameter satisfying a preset condition, it is determined that the security detection result of the key-value cache sharing of the first model service is failed.
10. The method of claim 9, wherein, The user setting request parameter satisfying a preset condition includes at least one of the following: The length of the return information of the fourth request is less than a preset value; The key-value cache information generated based on the fourth request is not stored in the first model service. 11.A model service key-value cache sharing security detection device, comprising: An obtaining module configured to obtain key-value cache information of a first model service, the key-value cache information being generated based on a first request sent to the first model service; A detection module configured to perform security detection on the first model service based on a life cycle of the key-value cache information, to obtain a security detection result of key-value cache sharing of the first model service; Wherein, the detection module is configured to determine that the security detection result of the key-value cache sharing of the first model service is failed if the life cycle of the key-value cache information is extended based on user reasons. 12.An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the method of any one of claims 1 to 10 when executing the program. 13.A non-transitory computer-readable storage medium storing computer instructions for causing the computer to execute the method of any one of claims 1 to 10. 14.A computer program product comprising computer program instructions which, when executed on a computer, cause the computer to perform the method of any one of claims 1 to 10.
Citation Information
Patent Citations
Method and system for verifying DNS request security
CN111953678A