Authority control method and device, electronic equipment, storage medium and program product
By introducing a blacklist mechanism into dbus, permission verification is only performed when permission control attributes are configured, which solves the problem of resource and performance waste under the SELinux whitelist mechanism and improves system performance and security.
Patent Information
- Application Number
- CN202410573895.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-10
- Publication Date
- 2024-10-18
- Estimated Expiration
- 2044-05-10
AI Technical Summary
In the existing technology, when dbus performs permission control through SELinux, all terminals need to be tagged based on the whitelist mechanism, resulting in a waste of resources and performance, especially for terminals that do not require permission control, causing system performance degradation.
Propose a permission control method. By receiving the client's API call request, the server queries the first permission control attribute of the target service. If it is not found, it directly routes the request to the target service; if it is found, it performs permission verification. . This method introduces a blacklist mechanism and only performs verification when permission control attributes are configured to avoid labeling services and terminals that do not require permission control.
It reduces the waste of resources and performance, improves system performance, and only configures permission attributes for services that require permission control, avoiding unnecessary labeling and improving the efficiency and security of permission control.
Smart Images

Figure CN118797610A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of security management and control technology, and in particular to a permission management method, device, electronic device, storage medium and program product. Background Art
[0002] In the operating system, dbus (inter-process communication mechanism optimized for desktop environment) provides powerful and flexible cross-process communication functions. Among them, for some security-related services, the API provided by the service needs to be called by authorized clients, so it is necessary to control the permissions of API call requests.
[0003] dbus itself provides a set of security control solutions, which controls the client's calls to related APIs by setting corresponding service permissions in the configuration file. The configuration file provided by dbus can control whether the user can start the service, send messages to the service, or send messages to an interface under the service. However, the user-mode configuration file can be modified, thereby bypassing the security control of service calls, which brings certain security risks.
[0004] At present, in order to prevent the configuration in the configuration file from being modified, dbus has further adapted SELinux (Security-Enhanced Linux). By modifying the internal code of dbus, it supports SELinux to control whether the service can be started based on a certain service name, and can also control the message sending from process A to process B, putting the permission check in the kernel state, and also avoiding the possibility of user state configuration files being modified. However, SELinux performs permission control based on the whitelist mechanism. Only client objects included in the whitelist have permission to access, that is, only those that meet the configuration requirements have permission to access. Based on this, all terminals need to be labeled for permission control of the whitelist mechanism, while some terminals do not have permission control requirements, resulting in the introduction of additional labels, which in turn causes waste of resources and performance, resulting in reduced system performance. Summary of the invention
[0005] The present invention provides a permission management method, device, electronic device, storage medium and program product, which are used to solve the defects of the prior art that cause waste of resources and performance, and realize a high-performance permission management mode.
[0006] The present invention provides a permission control method, which is applied to a server, and the method comprises:
[0007] Receive an API call request sent by a client, and determine a target service to be accessed based on the API call request;
[0008] Querying the first permission control attribute of the server for the target service;
[0009] If the first permission control attribute is not found, routing the API call request to the target service;
[0010] If the first permission control attribute is queried, a permission check is performed on the API call request of the client.
[0011] According to a permission control method provided by the present invention, the permission verification of the API call request of the client includes:
[0012] Querying a second permission control attribute of the client for the target service;
[0013] If the second permission control attribute is found, based on the first permission control attribute and the second permission control attribute, the API call request is subjected to permission verification to obtain a permission verification result;
[0014] If the permission check result is that the user has permission, the API call request is routed to the target service.
[0015] According to a permission control method provided by the present invention, the querying of the second permission control attribute of the client for the target service includes:
[0016] Based on the first socket sent by the client, query the second permission control attribute of the client for the target service;
[0017] There is a reference between the first Socket and the second Socket of the client itself, the first Socket stores the first permission control attribute, and the second Socket stores the second permission control attribute, so that the server can query the second permission control attribute based on the first Socket.
[0018] According to a permission control method provided by the present invention, the first permission control attribute is generated based on the following method:
[0019] Obtaining extended attributes configured on a file corresponding to the target service;
[0020] Based on the extended attribute, determining a first keyword for searching a hash table;
[0021] If the first keyword is found in the hash table based on the first keyword, the position of the first keyword in the hash table is determined as the first permission control attribute;
[0022] If the first keyword is not found in the hash table based on the first keyword, the first keyword is inserted into the hash table, and the insertion position of the first keyword in the hash table is determined as the first permission management attribute.
[0023] According to a permission control method provided by the present invention, the step of determining a first keyword for searching a hash table based on the extended attribute includes:
[0024] Splitting the extended attribute according to type to obtain multiple attributes;
[0025] Using the multiple attributes as second keywords for searching the hash table respectively;
[0026] Searching the hash table based on each of the second keywords to determine a target position of each of the second keywords in the hash table;
[0027] The first keyword is determined based on the integer value of each of the target positions.
[0028] The present invention also provides a permission management method, which is applied to a client, and the method includes:
[0029] Sending an API call request to a server, so that the server can perform permission verification on the API call request;
[0030] The server verifies the API call request based on the following method:
[0031] Determine the target service to be accessed based on the API call request;
[0032] Querying the first permission control attribute of the server for the target service;
[0033] If the first permission control attribute is not found, routing the API call request to the target service;
[0034] If the first permission control attribute is queried, a permission check is performed on the API call request of the client.
[0035] According to a permission control method provided by the present invention, if the server queries the first permission control attribute, the sending of the API call request to the server further includes:
[0036] Based on the second Socket of the client itself, sending the second permission control attribute of the client to the server;
[0037] There is a reference between the second Socket and the first Socket of the server, the first Socket stores the first permission control attribute, and the second Socket stores the second permission control attribute, so that the client can send the second permission control attribute to the server based on the second Socket;
[0038] The first Socket is created by the client and sent to the server.
[0039] The present invention also provides a permission control device, which is deployed on a server, and the device includes:
[0040] A request receiving module, used to receive an API call request sent by a client, and determine a target service to be accessed based on the API call request;
[0041] An attribute query module, used to query the first permission control attribute of the server for the target service;
[0042] A request routing module, configured to route the API call request to the target service if the first permission control attribute is not found;
[0043] The permission verification module is used to perform permission verification on the API call request of the client if the first permission management attribute is queried.
[0044] The present invention also provides a permission control device, which is deployed on a client, and the device includes:
[0045] A request sending module, used to send an API call request to a server, so that the server can perform permission verification on the API call request;
[0046] The server verifies the API call request based on the following method:
[0047] Determine the target service to be accessed based on the API call request;
[0048] Querying the first permission control attribute of the server for the target service;
[0049] If the first permission control attribute is not found, routing the API call request to the target service;
[0050] If the first permission control attribute is queried, a permission check is performed on the API call request of the client.
[0051] The present invention also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the permission management method described above is implemented.
[0052] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the permission management method described in any one of the above is implemented.
[0053] The present invention also provides a computer program product, including a computer program, wherein when the computer program is executed by a processor, the permission management method described above is implemented.
[0054] The permission management method, device, electronic device, storage medium and program product provided by the present invention receive an API call request sent by a client, determine the target service to be accessed based on the API call request, query the server for a first permission management attribute for the target service, and if the first permission management attribute is not queried, route the API call request to the target service, thereby confirming that the server has not performed permission management on the target service without configuring the first permission management attribute, and can directly route the API call request to the target service, that is, if there is no configuration, there is no permission management by default, and only when the first permission management attribute is queried, the client's API call request is permission checked, that is, only when the first permission management attribute is configured, it is confirmed that the server has performed permission management on the target service, and then the client's API call request needs to be permission checked, so that all terminals and services do not need to be labeled, and it is only necessary to configure the first permission management attribute for the service that requires permission management, thereby reducing waste of resources and performance and improving system performance. BRIEF DESCRIPTION OF THE DRAWINGS
[0055] In order to more clearly illustrate the technical solutions in the present invention or the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0056] Figure 1 One of the flowcharts of the permission control method provided by the present invention;
[0057] Figure 2 The second flowchart of the permission control method provided by the present invention;
[0058] Figure 3 A schematic diagram of the structure of the permission control device provided by the present invention;
[0059] Figure 4This is a schematic structural diagram of an electronic device provided by the present invention. DETAILED DESCRIPTION
[0060] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the drawings of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0061] In the operating system, dbus provides a powerful and flexible cross-process communication function. For some security-related services, the API provided by the service needs to be called by authorized clients, so permission control is required for API call requests.
[0062] dbus itself provides a set of security control solutions, which controls the client's calls to related APIs by setting corresponding service permissions in the configuration file. The configuration file provided by dbus can control whether the user can start the service, whether the user can send messages to the service or an interface under the service. However, the user-mode configuration file can be modified, thereby bypassing the security control of service calls and bringing certain security risks. For example, due to the special permissions of some special accounts in the operating system (such as the root account), the configuration in the configuration file can also be modified directly, that is, the root account can be used to directly modify the configuration in the configuration file.
[0063] For ease of understanding, take the service configuration as an example, the corresponding dbus configuration file is as follows:
[0064]
[0065] Among them, configuration 1 means that ordinary users cannot start the service. It uses deny to deny the start of any service name. Configuration 2 means that the root user can start the service, but can only start the service with the service name "Rose.LocalPropertyRepository". It first denies all services through deny, and then uses allow to start the service with the service name "Rose.LocalPropertyRepository". Configuration 3 means that messages can only be sent to the "Rose.LocalPropertyRepository.Internal" interface under the "Rose.LocalPropertyRepository" service, and messages cannot be sent to other interfaces under the service. Configuration 4 means that SELinux is used to control the permission to start the service and the permission to send messages. Whether it can be started based on the "Rose.LocalPropertyRepository" service name is determined by the "service_own_name_t" label.
[0066] At present, in order to ensure that the configuration in the configuration file is not modified, dbus has further adapted SELinux (Security-Enhanced Linux). By modifying the internal code of dbus, it supports SELinux to control whether a service can be started based on a certain service name, and it can also control the message sending from process A to process B, putting the permission check in the kernel state, and also avoiding the possibility of user state configuration files being modified. For example, taking the example of sending a message to a certain interface under the service, based on the SELinux "pre-labeling + bool variable control" mechanism, the overall message sending from process A to process B can be controlled, that is, either all messages can be sent or all messages cannot be sent. However, SELinux performs permission control based on the whitelist mechanism. Only client objects included in the whitelist have permission to access, that is, only those that meet the configuration requirements have permission to access. Based on this, although SELinux can achieve control of client calls to services without modifying the dbus configuration file, all terminals need to be labeled for permission control of the whitelist mechanism, and some terminals do not have permission control requirements, resulting in the introduction of additional labels, which in turn causes waste of resources and performance, resulting in system performance degradation. For example, sending a message to process B requires authorization, and only process A can send messages to process B. In this case, process A can be labeled with the authorized "blksec_clt_send_t" label. Due to the introduction of SELinux, the entire system must be labeled, but the entire system actually has no other control requirements. Although labels that release default permissions can be used, these additional labels are also a waste of resources and performance.
[0067] In view of the above problems, the present invention proposes the following embodiments. Figure 1 One of the flow charts of the permission control method provided by the present invention is as follows: Figure 1 As shown, the permission control method applied to the server includes:
[0068] Step 110: Receive an API call request sent by a client, and determine a target service to be accessed based on the API call request.
[0069] Here, the API call request is used to call the API of the target service being accessed. In one embodiment, the client sends the API call request to the target service service of the server; first, the API call request is sent to the service daemon, and then routed to the target service service.
[0070] Step 120: query the server for a first permission control attribute of the target service.
[0071] If there is permission control for the target service, the first permission control attribute is configured for the target service, so that the first permission control attribute can be queried; if there is no permission control for the target service, the first permission control attribute is not configured for the target service, so that the first permission control attribute cannot be queried.
[0072] In one embodiment, the first permission control attribute is configured on the file corresponding to the target service, that is, it is configured on the process file corresponding to the target service, that is, the first permission control attribute is an extended attribute on the file, thereby realizing dynamic configuration of the first permission control attribute, that is, realizing dynamic labeling. Compared with static labels, dynamic labeling can be performed on the target service.
[0073] In one embodiment, based on the first Socket sent by the client, the server is queried for the first permission control attribute of the target service. There is a reference between the first Socket and the second Socket of the client itself, and the first Socket stores the first permission control attribute, so the first permission control attribute can be queried based on the first Socket sent by the client.
[0074] Step 130: If the first permission management attribute is not found, the API call request is routed to the target service.
[0075] Specifically, if the first permission control attribute is not found, it means that the server does not perform permission control on the target service, so the API call request can be directly routed to the target service for the target service to respond to the API call request.
[0076] Step 140: If the first permission control attribute is found, a permission check is performed on the API call request of the client.
[0077] Specifically, if the first permission control attribute is queried, it means that the server needs to perform permission control on the target service, so the server performs permission check on the client's API call request to determine whether to route the API call request to the target service.
[0078] It should be understood that through the above method, the idea of a blacklist mechanism is introduced on the basis of the original whitelist mechanism, that is, there is no permission control by default, and permission control is available only after configuration, which can effectively solve the resource waste problem of SELinux implementing "dynamic" permission control based on bool variables.
[0079] The permission management method provided by the embodiment of the present invention receives an API call request sent by a client, determines the target service to be accessed based on the API call request, queries the server for a first permission management attribute for the target service, and routes the API call request to the target service if the first permission management attribute is not queried. Thus, in the case where the first permission management attribute is not configured, it is confirmed that the server does not perform permission management on the target service, and the API call request can be directly routed to the target service, that is, there is no permission management by default if there is no configuration, and only when the first permission management attribute is queried, the permission check is performed on the API call request of the client, that is, only when the first permission management attribute is configured, it is confirmed that the server performs permission management on the target service, and then the permission check is performed on the API call request of the client, so that all terminals and services do not need to be labeled, and it is only necessary to configure the first permission management attribute for the service that requires permission management, thereby reducing waste of resources and performance and improving system performance.
[0080] Based on any of the above embodiments, Figure 2 The second flowchart of the permission control method provided by the present invention is as follows: Figure 2 As shown, in the above step 140, the permission check is performed on the API call request of the client, including:
[0081] Step 141: If the first permission control attribute is found, query the second permission control attribute of the client for the target service.
[0082] If the client does not have permission to access the target service, the client will not be configured with the second permission control attribute for the target service, so that if the second permission control attribute cannot be queried, the API call request will be refused to be routed to the target service; if the client has permission to access the target service, the client will be configured with the second permission control attribute for the target service, so that if the second permission control attribute is queried, the API call request will be checked for permission based on the first permission control attribute and the second permission control attribute to determine whether the client has permission to access the target service.
[0083] In one embodiment, the second permission control attribute is configured on the corresponding process file in the client, that is, the second permission control attribute is an extended attribute on the file, thereby realizing dynamic configuration of the second permission control attribute, that is, realizing dynamic labeling, which can dynamically label the target service compared to static labels.
[0084] Step 142: If the second permission control attribute is found, a permission check is performed on the API call request based on the first permission control attribute and the second permission control attribute to obtain a permission check result.
[0085] It should be understood that if the second permission control attribute is queried, it means that the second permission control attribute is obtained from the client.
[0086] Specifically, the permission check of API call request is performed based on kernel state, that is, the permission check itself must fall into kernel state, and the permission check result is returned by kernel state. It should be understood that the permission control of cross-process communication is implemented based on the MAC (Mandatory Access Control) mechanism, so that the permission check of client application calling service is completed in kernel state, which solves the possibility of user state configuration files being modified, avoids potential problems such as bypassing the security control mechanism through special permission accounts, and improves the security of permission control.
[0087] Step 143: If the permission check result is that the user has permission, the API call request is routed to the target service.
[0088] If the permission check result is authorized, the API call request can be routed to the target service for the target service to respond to the API call request; if the permission check result is unauthorized, the API call request is refused to be routed to the target service, that is, the API call request is refused to be responded to.
[0089] The permission management method provided in the embodiment of the present invention queries the second permission management attribute of the client for the target service only if the first permission management attribute is queried, so as to confirm that the server needs to perform permission management on the target service, and then queries the second permission management attribute of the client for the target service, thereby improving system performance; if the second permission management attribute is queried, the API call request is subjected to permission verification based on the first permission management attribute and the second permission management attribute to obtain a permission verification result, thereby reducing waste of resources and performance and improving system performance.
[0090] Based on any of the above embodiments, in the method, the above step 141 includes:
[0091] Based on the first socket sent by the client, query the second permission control attribute of the client for the target service;
[0092] There is a reference between the first Socket and the second Socket of the client itself, the first Socket stores the first permission control attribute, and the second Socket stores the second permission control attribute, so that the server can query the second permission control attribute based on the first Socket.
[0093] Specifically, the process usually communicates based on Socket. In order to control the permissions of the socket, the first permission control attribute or the second permission control attribute stored in the socket can directly inherit the first permission control attribute or the second permission control attribute of the process. That is, the first permission control attribute or the second permission control attribute is directly saved to the security member variable of the socket.
[0094] In a specific embodiment, when the process file is opened to create an inode, the first permission control attribute or the second permission control attribute is saved to the security member variable of the inode; when the process is started, the first permission control attribute or the second permission control attribute of the inode is saved to the process context; a Socket is created inside the process, and the first permission control attribute or the second permission control attribute of the process context is saved to the Socket. The above can be processed by a security hook function. Among them, since the process has a process context, many controls are based on the process. In order to facilitate indexing, the first permission control attribute or the second permission control attribute of the inode is saved to the process context.
[0095] Considering that the above only completes the inheritance of the first permission control attribute or the second permission control attribute of the process to Socekt, but the communication between Sockets is mutual communication, and the control itself also requires two objects, the subject and the object, so the two sides of the Socket are just the relationship between the subject and the object. Based on this, in order to improve the communication performance of the Socket, a reference is set between the first Socket and the second Socket of the client itself, thereby improving the query efficiency of the first permission control attribute or the second permission control attribute, and then improving the efficiency and performance of permission control.
[0096] It should be noted that in order to enable the permission control attributes of both parties of permission control (i.e., the client and the server) to be immediately found from their own Socket data structure, and in addition to knowing their own permission control attributes, they also need to know the other party's permission control attributes. Therefore, a reference is set between the first Socket and the client's own second Socket to improve the query efficiency of the permission control attributes, thereby improving the efficiency and performance of permission control.
[0097] The server performs Socket communication with the client through the first Socket sent by the client.
[0098] In a specific embodiment, the client actively connects to the server through a Socket, that is, the user state triggers the call connect, and the server user state triggers the call accept to receive the connection; when the client connects, the previous Socket (cltsock) is searched out according to fd (FileDescriptor, file descriptor), and the second permission control attribute is obtained from cltsock for security, and the client needs to create a brand new first Socket (newsk), which is to complete point-to-point communication with the server. A client can create multiple point-to-points with the server, so multiple newsks will be created; newsk will eventually be sent to the server, and the final communication after the connection is successful occurs between cltsock->sk and newsk, so there is a reference between the first Socket and the second Socket of the client itself, for example, through peer reference, sk->peer=newsk, newsk->peer=sk; sk (second Socket) and newsk (first Socket) can access each other, which also enables them to communicate directly with each other, and the permission verification information before communication is also saved in sk and newsk. Based on this, after completing the mutual reference, both the client and the server can complete the permission verification. To make it easier to understand the references, they are as follows:
[0099] sk->blksec_id = blksec_id of the client process (second permission control attribute);
[0100] newsk->blksec_id = blksec_id of the server process (the first permission control attribute);
[0101] sk->peer_blksec_id=newsk->blksec_id;
[0102] newsk->peer_blksec_id=sk->blksec_id.
[0103] In addition, it should be noted that the second Socket can be found in the client process through the client's fd, and the server process can eventually find the first Socket through the newly created fd, so the user state can complete mutual communication based on fd, and can also complete mutual permission control.
[0104] It should be understood that the first Socket and the second Socket point to each other, so that each can quickly obtain the permission control attributes of the other, thereby improving the query efficiency of the permission control attributes, and thus improving the efficiency and performance of permission control.
[0105] It should be understood that since the first permission control attribute and the second permission control attribute are permission control attributes of two processes, verifying the permissions between Socket communications is actually verifying whether Socket communication can be performed between the two processes.
[0106] The permission management method provided in the embodiment of the present invention queries the second permission management attribute of the client for the target service based on the first Socket sent by the client, and there is a reference between the first Socket and the second Socket of the client itself, so that the second permission management attribute of the other party can be quickly queried, thereby improving the query efficiency of the second permission management attribute, thereby improving the efficiency and performance of permission management.
[0107] Based on any of the above embodiments, in this method, the first permission control attribute is generated based on the following method:
[0108] Obtaining extended attributes configured on a file corresponding to the target service;
[0109] Based on the extended attribute, determining a first keyword for searching a hash table;
[0110] If the first keyword is found in the hash table based on the first keyword, the position of the first keyword in the hash table is determined as the first permission control attribute;
[0111] If the first keyword is not found in the hash table based on the first keyword, the first keyword is inserted into the hash table, and the insertion position of the first keyword in the hash table is determined as the first permission management attribute.
[0112] Considering that in the prior art, SELinux is statically labeled, that is, it must set application labels in advance, and cannot do dynamic labeling, that is, it cannot flexibly solve the problem of dynamically setting permission control. For example, it is impossible to know in advance how many clients send messages to process B. Since SELinux must statically label in advance, it can only define the number of labels in advance, such as 128; and dynamic control needs to be implemented based on bool variables. Due to limited label resources, these labels can only be statically planned according to the existing applications in the system, such as application 1 is labeled 1, application 2 is labeled 2, and application 128 is labeled 128. During the operation, the value of the bool variable is modified to control their permission to send messages to process B. However, there are far more than 128 applications, and there is a problem of insufficient number of labels. These 128 applications do not necessarily call the service to send messages to process B. Such a whitelist static planning label mechanism will cause huge waste of resources. Based on this, the extended attributes configured on the file corresponding to the target service are obtained to implement dynamic labeling, that is, dynamically configure the extended attributes on the file according to actual needs, that is, realize the function of dynamically labeling the application, and flexibly solve the problem of insufficient number of labels and difficulty in effective planning. Correspondingly, the kernel also needs to dynamically add extended attributes, that is, the kernel needs to support the mechanism of dynamically adding extended attributes and parsing these attributes according to needs, and the newly added permissions can only be given to specific security service processes.
[0113] Specifically, the extended attributes configured on the process file corresponding to the target service are obtained. In a specific embodiment, when the process file is loaded, that is, when the target service (process) is started, the file system supports reading and writing extended attributes; when the process is opened, the system function is called to call the corresponding security hook function, that is, the execution process will call the kernel's do_filp_open function, and finally call the security opening hook function, which only needs to register its own security hook based on the kernel's LSM (Linux Security Module, Linux Security Module) mechanism; the security hook function reads the extended attribute; if this extended attribute exists, it means that permission control is required, and the value of the extended attribute is read.
[0114] Exemplarily, if the extended attribute is "system_u:object_r:blksec_srv_1_t:s0", the extended attribute is used as the first keyword for searching the hash table.
[0115] Furthermore, the first permission control attribute is saved in the security member variable of the inode. Since the parsing of the extended attribute occurs when the process file is first loaded, this is also the moment when the inode node of the file is created. Therefore, the parsed extended attribute value is saved in the data structure corresponding to the inode node. Since it is saved in the data structure corresponding to the inode node, it only needs to be parsed once, ensuring performance. In other words, no matter how many times the file is opened, only one unique inode will be created, and the extended attribute only needs to be parsed once. Therefore, the permission control attribute is parsed from the extended attribute and saved in the security member variable in the inode.
[0116] Furthermore, since the target service is a process, the first permission control attribute is further saved to the security member variable of the process context when the kernel initializes the process, so that the first permission control attribute can be retrieved when the process performs socket communication as a subject.
[0117] Furthermore, the security hook function is only a hook function in the entire opening process when the process is opened. After the security hook function is called, it needs to return to the function that called it. In any case, it returns OK, because the extended attributes are not necessary. The basic principle of this security module is to control only when they are set.
[0118] It should be noted that the generation method of the second permission control attribute is basically the same as the generation method of the first permission control attribute, which will not be repeated here.
[0119] The permission management method provided in the embodiment of the present invention obtains the extended attributes configured on the file corresponding to the target service to realize dynamic labeling, that is, dynamically configures the extended attributes on the file according to actual needs, that is, realizes the function of dynamically labeling the application, and flexibly solves the problem of insufficient number of labels and difficulty in effective planning; based on the extended attributes, determines the first keyword for searching the hash table, if the first keyword is found in the hash table based on the first keyword, the position of the first keyword in the hash table is determined as the first permission management attribute, if the first keyword is not found in the hash table based on the first keyword, the first keyword is inserted into the hash table, and the insertion position of the first keyword in the hash table is determined as the first permission management attribute, so that the extended attribute is converted into the first permission management attribute of an integer value through the hash table, the query efficiency of the first permission management attribute is improved, and then the efficiency and performance of permission management are improved.
[0120] Based on any of the above embodiments, in the method, determining the first keyword for searching the hash table based on the extended attribute includes:
[0121] Splitting the extended attribute according to type to obtain multiple attributes;
[0122] Using the multiple attributes as second keywords for searching the hash table respectively;
[0123] Searching the hash table based on each of the second keywords to determine a target position of each of the second keywords in the hash table;
[0124] The first keyword is determined based on the integer value of each of the target positions.
[0125] Exemplarily, the extended attribute is "system_u:object_r:blksec_srv_1_t:s0", and the extended attribute is split according to the types user, role, type, and class to obtain multiple attributes system_u, object_r, blksec_srv_1_t, and s0; the multiple attributes system_u, object_r, blksec_srv_1_t, and s0 are respectively used as the second keyword key, and their positions are found in the hash table, and the target position of each second keyword in the hash table is their corresponding integer value; the integer value of each target position is encapsulated into a security context, which includes the integer value of each target position, and the security context is used as the first keyword.
[0126] The permission management method provided by the embodiment of the present invention, through the above-mentioned method, only needs to maintain multiple attributes divided by type in the hash table, so that more first keywords can be obtained by combining multiple attributes. Compared with directly maintaining all first keywords in the hash table, the embodiment of the present invention can reduce the number of hash table configurations, thereby reducing the cost of permission management.
[0127] Based on any of the above embodiments, the present invention further provides a permission control method applied to a client, and the permission control method applied to a client includes:
[0128] Send an API call request to the server so that the server can perform permission verification on the API call request.
[0129] The server verifies the API call request based on the following method:
[0130] Determine the target service to be accessed based on the API call request; query the server for a first permission management attribute for the target service; if the first permission management attribute is not found, route the API call request to the target service; if the first permission management attribute is found, perform a permission check on the API call request of the client.
[0131] Here, the steps of the server performing permission verification on the API call request can refer to the above embodiments, which will not be repeated here. It should be understood that the client can also act as a server and execute the steps of the server.
[0132] The permission management method provided in the embodiment of the present invention sends an API call request to the server, so that the server determines the target service to be accessed based on the API call request, queries the server for the first permission management attribute for the target service, and if the first permission management attribute is not queried, routes the API call request to the target service, thereby confirming that the server has not performed permission management on the target service without configuring the first permission management attribute, and can directly route the API call request to the target service, that is, if there is no configuration, there is no permission management by default, and only after the first permission management attribute is queried, the client's API call request is permission checked, that is, only when the first permission management attribute is configured, it is confirmed that the server has performed permission management on the target service, and then the client's API call request needs to be permission checked, so that all terminals and services do not need to be labeled, and it is only necessary to configure the first permission management attribute for the service that requires permission management, thereby reducing waste of resources and performance and improving system performance.
[0133] Based on any of the above embodiments, in the method, if the server queries the first permission control attribute, the sending of the API call request to the server further includes:
[0134] Based on the second Socket of the client itself, sending the second permission control attribute of the client to the server;
[0135] There is a reference between the second Socket and the first Socket of the server, the first Socket stores the first permission control attribute, and the second Socket stores the second permission control attribute, so that the client can send the second permission control attribute to the server based on the second Socket; the first Socket is created by the client and sent to the server.
[0136] Specifically, the process usually communicates based on Socket. In order to control the permissions of the socket, the first permission control attribute or the second permission control attribute stored in the socket can directly inherit the first permission control attribute or the second permission control attribute of the process. That is, the first permission control attribute or the second permission control attribute is directly saved to the security member variable of the socket.
[0137] Considering that the above only completes the inheritance of the first permission control attribute or the second permission control attribute of the process to Socekt, but the communication between Sockets is mutual communication, and the control itself also requires two objects, the subject and the object, so the two sides of the Socket are just the relationship between the subject and the object. Based on this, in order to improve the communication performance of the Socket, a reference is set between the first Socket and the second Socket of the client itself, thereby improving the query efficiency of the first permission control attribute or the second permission control attribute, and then improving the efficiency and performance of permission control.
[0138] It should be noted that in order to enable the permission control attributes of both parties of permission control (i.e., the client and the server) to be immediately found from their own Socket data structure, and in addition to knowing their own permission control attributes, they also need to know the other party's permission control attributes. Therefore, a reference is set between the first Socket and the client's own second Socket to improve the query efficiency of the permission control attributes, thereby improving the efficiency and performance of permission control.
[0139] The server performs Socket communication with the client through the first Socket sent by the client.
[0140] In a specific embodiment, the client actively connects to the server through a Socket, that is, the user state triggers the call connect, and the server user state triggers the call accept to receive the connection; when the client connects, the previous Socket (cltsock) is searched out according to fd (FileDescriptor, file descriptor), and the second permission control attribute is obtained from cltsock for security, and the client needs to create a brand new first Socket (newsk), which is to complete point-to-point communication with the server. A client can create multiple point-to-points with the server, so multiple newsks will be created; newsk will eventually be sent to the server, and the final communication after the connection is successful occurs between cltsock->sk and newsk, so there is a reference between the first Socket and the second Socket of the client itself, for example, through peer reference, sk->peer=newsk, newsk->peer=sk; sk (second Socket) and newsk (first Socket) can access each other, which also enables them to communicate directly with each other, and the permission verification information before communication is also saved in sk and newsk. Based on this, after completing the mutual reference, both the client and the server can complete the permission verification. To make it easier to understand the references, they are as follows:
[0141] sk->blksec_id = blksec_id of the client process (second permission control attribute);
[0142] newsk->blksec_id = blksec_id of the server process (the first permission control attribute);
[0143] sk->peer_blksec_id=newsk->blksec_id;
[0144] newsk->peer_blksec_id=sk->blksec_id.
[0145] In addition, it should be noted that the second Socket can be found in the client process through the client's fd, and the server process can eventually find the first Socket through the newly created fd, so the user state can complete mutual communication based on fd, and can also complete mutual permission control.
[0146] It should be understood that the first Socket and the second Socket point to each other, so that each can quickly obtain the permission control attributes of the other, thereby improving the query efficiency of the permission control attributes, and thus improving the efficiency and performance of permission control.
[0147] It should be understood that since the first permission control attribute and the second permission control attribute are permission control attributes of two processes, verifying the permissions between Socket communications is actually verifying whether Socket communication can be performed between the two processes.
[0148] The permission management method provided in the embodiment of the present invention sends the second permission management attribute of the client to the server based on the second Socket of the client itself, and there is a reference between the first Socket and the second Socket of the client itself, so that the second permission management attribute can be sent quickly, thereby improving the query efficiency of the second permission management attribute, thereby improving the efficiency and performance of permission management.
[0149] The permission control device provided by the present invention is described below. The permission control device described below and the permission control method described above can be referenced to each other.
[0150] Figure 3 A schematic diagram of the structure of the permission control device provided by the present invention is shown in FIG. Figure 3 As shown, the permission control device deployed on the server side includes:
[0151] The request receiving module 310 is used to receive an API call request sent by a client, and determine a target service to be accessed based on the API call request;
[0152] An attribute query module 320 is used to query the first permission control attribute of the server for the target service;
[0153] A request routing module 330, configured to route the API call request to the target service if the first permission control attribute is not found;
[0154] The permission verification module 340 is used to perform permission verification on the API call request of the client if the first permission management attribute is queried.
[0155] The permission management device provided by the embodiment of the present invention receives an API call request sent by a client, determines the target service to be accessed based on the API call request, queries the server for the first permission management attribute for the target service, and routes the API call request to the target service if the first permission management attribute is not queried. Thus, in the case where the first permission management attribute is not configured, it is confirmed that the server has not performed permission management on the target service, and the API call request can be directly routed to the target service, that is, there is no permission management by default if there is no configuration, and only when the first permission management attribute is queried, the permission check is performed on the API call request of the client, that is, only when the first permission management attribute is configured, it is confirmed that the server has performed permission management on the target service, and then the permission check is performed on the API call request of the client, so that all terminals and services do not need to be labeled, and it is only necessary to configure the first permission management attribute for the service that requires permission management, thereby reducing waste of resources and performance and improving system performance.
[0156] The permission control device deployed on the client includes:
[0157] A request sending module, used to send an API call request to a server, so that the server can perform permission verification on the API call request;
[0158] The server verifies the API call request based on the following method:
[0159] Determine the target service to be accessed based on the API call request;
[0160] Querying the first permission control attribute of the server for the target service;
[0161] If the first permission control attribute is not found, routing the API call request to the target service;
[0162] If the first permission control attribute is queried, a permission check is performed on the API call request of the client.
[0163] Figure 4An example of a physical structure diagram of an electronic device is shown in FIG. Figure 4 As shown, the electronic device may include: a processor (processor) 410, a communication interface (CommunicationsInterface) 420, a memory (memory) 430 and a communication bus 440, wherein the processor 410, the communication interface 420, and the memory 430 communicate with each other through the communication bus 440. The processor 410 can call the logic instructions in the memory 430 to execute the permission control method applied to the server, the method comprising: receiving an API call request sent by a client, determining the target service to be accessed based on the API call request; querying the first permission control attribute of the server for the target service; if the first permission control attribute is not queried, routing the API call request to the target service; if the first permission control attribute is queried, performing permission verification on the API call request of the client. Or execute a permission management method applied to a client, the method comprising: sending an API call request to a server, so that the server performs permission verification on the API call request; wherein the server performs permission verification on the API call request in the following manner: determining the target service to be accessed based on the API call request; querying the server for a first permission management attribute for the target service; if the first permission management attribute is not queried, routing the API call request to the target service; if the first permission management attribute is queried, performing permission verification on the API call request of the client.
[0164] In addition, the logic instructions in the above-mentioned memory 430 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on such an understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art or the part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk and other media that can store program codes.
[0165] On the other hand, the present invention also provides a computer program product, which includes a computer program, which can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can execute the permission management method applied to the server provided by the above methods, and the method includes: receiving an API call request sent by a client, and determining the target service to be accessed based on the API call request; querying the server for a first permission management attribute for the target service; if the first permission management attribute is not queried, routing the API call request to the target service; if the first permission management attribute is queried, performing a permission check on the API call request of the client. Alternatively, the computer is capable of executing the permission management method applied to the client provided by the above methods, the method comprising: sending an API call request to a server, so that the server performs permission verification on the API call request; wherein the server performs permission verification on the API call request in the following manner: determining the target service to be accessed based on the API call request; querying the server for a first permission management attribute for the target service; if the first permission management attribute is not queried, routing the API call request to the target service; if the first permission management attribute is queried, performing permission verification on the API call request of the client.
[0166] On the other hand, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, it is implemented to execute the permission management method applied to the server provided by the above-mentioned methods. The method includes: receiving an API call request sent by a client, and determining the target service to be accessed based on the API call request; querying the server for a first permission management attribute for the target service; if the first permission management attribute is not queried, routing the API call request to the target service; if the first permission management attribute is queried, performing a permission check on the API call request of the client. Or the computer program is implemented when executed by the processor to execute the permission management method applied to the client provided by the above methods, the method comprising: sending an API call request to the server, so that the server performs permission verification on the API call request; wherein the server performs permission verification on the API call request based on the following method: determining the target service to be accessed based on the API call request; querying the server for a first permission management attribute for the target service; if the first permission management attribute is not queried, routing the API call request to the target service; if the first permission management attribute is queried, performing permission verification on the API call request of the client.
[0167] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.
[0168] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.
[0169] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A permission control method, It is characterized in that Applied to the server, the method includes: Receive an API call request sent by a client, and determine a target service to be accessed based on the API call request; Querying the first permission control attribute of the server for the target service; If the first permission control attribute is not found, routing the API call request to the target service; If the first permission control attribute is queried, a permission check is performed on the API call request of the client.
2. According to the permission management method of claim 1, It is characterized in that The performing permission verification on the API call request of the client includes: Querying a second permission control attribute of the client for the target service; If the second permission control attribute is found, based on the first permission control attribute and the second permission control attribute, the API call request is subjected to permission verification to obtain a permission verification result; If the permission check result is that the user has permission, the API call request is routed to the target service.
3. According to the permission control method of claim 2, It is characterized in that The querying the second permission control attribute of the client for the target service includes: Based on the first socket sent by the client, query the second permission control attribute of the client for the target service; There is a reference between the first Socket and the second Socket of the client itself, the first Socket stores the first permission control attribute, and the second Socket stores the second permission control attribute, so that the server can query the second permission control attribute based on the first Socket.
4. The permission control method according to claim 1, It is characterized in that The first permission control attribute is generated based on the following method: Obtaining extended attributes configured on the file corresponding to the target service; Based on the extended attribute, determining a first keyword for searching a hash table; If the first keyword is found in the hash table based on the first keyword, the position of the first keyword in the hash table is determined as the first permission control attribute; If the first keyword is not found in the hash table based on the first keyword, the first keyword is inserted into the hash table, and the insertion position of the first keyword in the hash table is determined as the first permission management attribute.
5. According to the permission control method of claim 4, It is characterized in that The step of determining a first keyword for searching a hash table based on the extended attribute includes: Splitting the extended attribute according to type to obtain multiple attributes; Using the multiple attributes as second keywords for searching the hash table respectively; Searching the hash table based on each of the second keywords to determine a target position of each of the second keywords in the hash table; The first keyword is determined based on the integer value of each of the target positions.
6. A permission control method, It is characterized in that Applied to a client, the method comprises: Sending an API call request to a server, so that the server can perform permission verification on the API call request; The server verifies the API call request based on the following method: Determine the target service to be accessed based on the API call request; Querying the first permission control attribute of the server for the target service; If the first permission control attribute is not found, routing the API call request to the target service; If the first permission control attribute is queried, a permission check is performed on the API call request of the client.
7. The permission control method according to claim 6, It is characterized in that If the server finds the first permission control attribute, the sending of the API call request to the server further includes: Based on the second Socket of the client itself, sending the second permission control attribute of the client to the server; There is a reference between the second Socket and the first Socket of the server, the first Socket stores the first permission control attribute, and the second Socket stores the second permission control attribute, so that the client can send the second permission control attribute to the server based on the second Socket; The first Socket is created by the client and sent to the server.
8. A permission control device, It is characterized in that Deployed on the server, the device includes: A request receiving module, used to receive an API call request sent by a client, and determine a target service to be accessed based on the API call request; An attribute query module, used to query the first permission control attribute of the server for the target service; A request routing module, configured to route the API call request to the target service if the first permission management attribute is not found; The permission verification module is used to perform permission verification on the API call request of the client if the first permission management attribute is queried.
9. A permission control device, It is characterized in that Deployed on the client, the device includes: A request sending module, used to send an API call request to a server, so that the server can perform permission verification on the API call request; The server verifies the API call request based on the following method: Determine the target service to be accessed based on the API call request; Querying the first permission control attribute of the server for the target service; If the first permission control attribute is not found, routing the API call request to the target service; If the first permission control attribute is queried, a permission check is performed on the API call request of the client.
10. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, It is characterized in that When the processor executes the program, the permission management method as described in any one of claims 1 to 7 is implemented.
11. A non-transitory computer-readable storage medium having a computer program stored thereon, It is characterized in that When the computer program is executed by a processor, the permission management method as described in any one of claims 1 to 7 is implemented.
12. A computer program product comprising a computer program, It is characterized in that When the computer program is executed by a processor, the permission management method as described in any one of claims 1 to 7 is implemented.
Citation Information
Patent Citations
Access control method and related device
CN114912103A
Malicious process detection method and device, electronic equipment and storage medium
CN115023699A
Core system strategy management and control platform authority control method, system, equipment and medium
CN116861381A
Permission verification method and device and electronic equipment
CN117749432A
Tracing task execution across services in microkernel-based operating systems
US10990439B1
