Database integrity protection method and device, equipment and storage medium

By adding integrity protection fields and views to the database, combined with triggers and custom functions, the problems of high upgrade and transformation costs and poor real-time performance of database integrity protection in existing technologies are solved, realizing cell-level data protection and real-time awareness of application systems without modification.

CN121365430APending Publication Date: 2026-01-20CETC CYBERSPACE SECURITY TECH CO LTD
View PDF 10 Cites 0 Cited by

Patent Information

Application Number
CN202511929219.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-12-19
Publication Date
2026-01-20

AI Technical Summary

Technical Problem

Existing database integrity protection technologies suffer from high upgrade and transformation costs, complex implementation, single point of failure risk, and inability to detect data tampering in real time. They cannot achieve fine-grained protection and real-time detection of database cells without modifying application systems.

Method used

By adding an integrity protection field to the database, creating a view with the same structure as the original table, and utilizing database triggers and user-defined functions, we can monitor data insertion, update, and deletion operations in real time, generate and verify message authentication codes, and achieve cell-level data integrity protection.

Benefits of technology

It achieves fine-grained protection at the database cell level without modifying the application system's source code, detects data tampering in real time, avoids resource waste, and reduces implementation and maintenance costs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121365430A_ABST
    Figure CN121365430A_ABST
Patent Text Reader

Abstract

The invention discloses a database integrity protection method and device, equipment and a storage medium, and relates to the technical field of information security. Comprising the following steps: selecting an original table needing integrity protection in a database, and adding an integrity protection field for storing a message authentication code to generate a target table; creating a view with the same structure as the original table to take over data access; a database trigger is created on the target table, when data is added, deleted and changed through a view, the trigger triggers and calls a user-defined function, and according to a preset access control strategy, a message authentication code in the integrity protection field is generated, updated or kept; and when the data is queried through the view, calculating a current message authentication code of the protected field, comparing the current message authentication code with a stored historical message authentication code, and performing data integrity verification according to a comparison result. By means of the data integrity protection method and device, under the condition that the application system is free of transformation, data integrity protection of the database cell level can be achieved, and the application system is prevented from using tampered data.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the field of information security technology, and in particular to a database integrity protection method, device, equipment and storage medium. BACKGROUND

[0002] GB / T 22239-2019 and GB / T 39786-2021 require that the confidentiality and integrity of important data storage of a three-level and above information system be protected by using cryptographic techniques. As a core carrier of data assets, the storage security of a database is crucial. There are currently four mainstream protection technology routes: application internal cryptographic processing, application aspect technology, database gateway technology, file transparent encryption and periodic verification technology. However, all of them have defects: the first technology route requires application modification of source code to call cryptographic capabilities, and has high upgrade, reconstruction and adaptation costs; the second technology route has complex adaptation scenarios, and has high project landing and implementation costs; the third technology route is prone to become a bottleneck for application access to databases, and has a single point of failure risk; and the fourth technology route has a coarse integrity protection granularity, cannot realize real-time perception of data tampering behavior, and also wastes database server computing resources. Therefore, how to provide a low-cost and high-efficiency database integrity protection scheme to solve the above technical problems is a problem that needs to be solved by those skilled in the art at present. SUMMARY

[0003] Therefore, the purpose of the present application is to provide a database integrity protection method, device, equipment and storage medium, which can realize application system modification-free deployment, achieve cell-level fine-grained protection, realize real-time perception of tampering behavior, and avoid performance bottlenecks and single point of failure. The specific scheme is as follows:

[0004] In a first aspect, the present application discloses a database integrity protection method, comprising: selecting an original table in a database that needs to be protected for integrity, and performing structural modification on the original table to add at least one integrity protection field, to obtain a target table; the integrity protection field is used to store a message authentication code of at least one protected field; creating a view with the same structure as the original table, and taking over data access to the original table through the view; creating a database trigger on the target table, triggering the database trigger to call a user-defined function when performing data insertion, update or deletion operations through the view, and performing generation, update or maintenance operations on the message authentication code in the integrity protection field according to a preset access control policy; When data query is performed through the view, the current message authentication code of the protected field is calculated and compared with the historical message authentication code stored in the integrity protection field, and data integrity verification is performed according to the comparison result.

[0005] Optionally, the database trigger comprises an after-insert trigger, an after-update trigger and an after-delete trigger; the database trigger can select a synchronous or asynchronous calling mode according to a database load condition; The after-insert trigger is configured to trigger calling the user-defined function and generating the message authentication code in the integrity protection field according to a first access control policy when data insertion is performed through the view. The after-update trigger is configured to trigger calling the user-defined function and updating or maintaining the message authentication code in the integrity protection field according to a second access control policy when data update is performed through the view. The after-delete trigger is configured to trigger calling the user-defined function and recording data tampering behavior according to a third access control policy when data deletion is performed through the view.

[0006] Optionally, when data insertion is performed through the view, the user-defined function is triggered to be called, and the message authentication code in the integrity protection field is generated according to a first access control policy, comprising: When data insertion is performed through the view, the user-defined function is triggered to be called to obtain first operation information of performing current access; the first operation information comprises a corresponding database account, a source address, a database schema and a database table. The legal permission of a user performing the data insertion is judged based on the first operation information. If the user is an authorized legal user, a first message authentication code of the protected field is generated, and the first message authentication code is stored in the integrity protection field. If the user is an unauthorized illegal user, a pseudo message authentication code is randomly generated, and then the pseudo message authentication code is stored in the integrity protection field, and the data insertion is recorded as a first data tampering behavior.

[0007] Optionally, when data update is performed through the view, the user-defined function is triggered to be called, and the message authentication code in the integrity protection field is updated or maintained according to a second access control policy, comprising: When data update is performed through the view, the user-defined function is triggered to be called to obtain second operation information of performing current access; the second operation information comprises a corresponding database account, a source address, a database schema and a database table. The legal permission of a user performing the data update is judged based on the second operation information. If the user is an authorized legal user, a second message authentication code of the protected field after update is generated, and the second message authentication code is used to update the integrity protection field. If the user is an unauthorized illegal user, the original message authentication code in the integrity protection field is kept unchanged, and the data update is recorded as a second data tampering behavior.

[0008] Optionally, when the data deletion is performed through the view, the user-defined function is triggered to be called, and a data tampering behavior is recorded according to a third access control policy, including: When the data deletion is performed through the view, the user-defined function is triggered to be called to obtain third operation information of the current access; the third operation information includes a corresponding database account, a source address, a database schema, and a database table. Based on the third operation information, it is determined whether the user has a legal permission to perform the data deletion. If the user is an authorized legal user, the data is directly deleted. If the user is an unauthorized illegal user, the data deletion is recorded as a third data tampering behavior.

[0009] Optionally, the database integrity protection method further includes: The database trigger is used to determine whether a data tampering behavior occurs. If the database trigger determines that the data tampering behavior does not occur, the real data of the protected field is directly returned. If the database trigger determines that the data tampering behavior occurs, when data query is performed through the view, a current message authentication code of the protected field is calculated, compared with a historical message authentication code stored in the integrity protection field, and data integrity verification is performed according to a comparison result.

[0010] Optionally, when data query is performed through the view, a current message authentication code of the protected field is calculated, compared with a historical message authentication code stored in the integrity protection field, and data integrity verification is performed according to a comparison result, including: When data query is performed through the view, a current message authentication code of the protected field is calculated, compared with a historical message authentication code stored in the integrity protection field. If the current message authentication code is the same as the historical message authentication code, it is determined that the protected field is not tampered with, and the real data of the protected field is returned. If the current message authentication code is different from the historical message authentication code, it is determined that the protected field is tampered with, and a database standard error code is returned.

[0011] In a second aspect, the application discloses a database integrity protection device, including: An original table reconstruction module is configured to select an original table in a database that needs integrity protection, and reconstruct the structure of the original table to add at least one integrity protection field to obtain a target table; the integrity protection field is configured to store a message authentication code of at least one protected field; A view creation module is configured to create a view with the same structure as the original table, and take over data access to the original table through the view; A permission processing module is configured to create a database trigger on the target table, and trigger the database trigger to call a user-defined function and perform a generation, update or maintenance operation on the message authentication code in the integrity protection field according to a preset access control policy when a data insertion, update or deletion operation is performed through the view; An integrity verification module is configured to calculate a current message authentication code of the protected field when data query is performed through the view, compare the current message authentication code with a historical message authentication code stored in the integrity protection field, and perform data integrity verification according to a comparison result.

[0012] In a third aspect, the present application discloses an electronic device, comprising a processor and a memory; wherein the memory is configured to store a computer program, and the computer program is loaded and executed by the processor to implement the database integrity protection method as described above.

[0013] In a fourth aspect, the present application discloses a computer readable storage medium configured to store a computer program; wherein the computer program is executed by a processor to implement the database integrity protection method as described above.

[0014] The present application has the following beneficial effects: first, by creating a view with the same structure as the protected table, taking over data access to the protected table, the data integrity protection does not affect the add, delete, modify and query operations of the application system, the application does not need to modify the source code, and unnecessary adaptation, verification, upgrade and modification work is avoided. Second, when data addition, deletion and modification operations occur, permission verification and message authentication code processing can be triggered in real time through a database trigger, cell-level fine-grained protection is achieved, and tampered data can be accurately located. Finally, data integrity is verified in real time during query, application system misuse of tampered data is avoided, and resource waste caused by timing tasks is avoided. It can be seen that all integrity protection logic is implemented inside the database through views, triggers and custom functions, without the need to parse database protocols or complex SQL, and without the need to additionally deploy gateways or application aspect components. The legitimate application of the database is efficiently accessed, and the implementation and maintenance costs are reduced.

[0015] In addition, the database integrity protection device, equipment and storage medium provided by the application correspond to the above-mentioned database integrity protection method, and have the same effect. BRIEF DESCRIPTION OF DRAWINGS

[0016] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the drawings needed to be used in the embodiments or prior art description will be briefly introduced as follows. Obviously, the drawings in the following description only represent some embodiments of the present application, and other drawings can be obtained by those skilled in the art without creative labor on the basis of the provided drawings.

[0017] Figure 1 A flow chart of a database integrity protection method disclosed by the present application is shown in the figure. Figure 2 A specific database integrity protection schematic diagram disclosed by the present application is shown in the figure. Figure 3 A database integrity protection device structure schematic diagram disclosed by the present application is shown in the figure. Figure 4 An electronic equipment structure diagram disclosed by the present application is shown in the figure. DETAILED DESCRIPTION

[0018] The technical solutions in the embodiments of the present application will be described clearly and completely below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments only represent some embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative labor fall within the scope of protection of the present application.

[0019] GB / T 22239-2019 "Information Security Level Protection Basic Requirements" requires that the information system of level three and above should use cryptographic technology to ensure the confidentiality of important data during storage; and should use verification technology or cryptographic technology to ensure the integrity of important data during storage. GB / T 39786-2021 "Basic Requirements for Information System Cryptographic Application" requires that the information system of level three and above should use cryptographic technology to ensure the confidentiality of important data during storage of information system application; and it is appropriate to use cryptographic technology to ensure the integrity of important data during storage of information system application.

[0020] As the core carrier of data assets, once data tampering or data leakage occurs, it will cause serious social harm and economic loss. How to protect the confidentiality and integrity of data storage is an important problem in the field of database security. At present, the confidentiality and integrity of database storage can be protected by the following four technical routes.

[0021] Technical Route 1: Apply system call cryptographic device, protect important business data in the application for confidentiality and integrity.

[0022] Technical Route 2: Based on application aspect technology, protect data stored in the database for confidentiality and integrity on the application side.

[0023] Technical Route 3: Based on database gateway technology, protect data stored in the database for confidentiality and integrity on the network layer.

[0024] Technical Route 4: Based on file transparent encryption technology, protect database files for confidentiality on the file system storage layer; through timing tasks, check the integrity of the entire table (or column) of the database regularly.

[0025] However, the above technical solutions have their own application defects.

[0026] Technical Route 1: Application system can realize data confidentiality and integrity protection according to business scenarios, and can realize database cell-level data integrity protection; but it needs to modify the source code, call cryptographic devices, and develop cryptographic technology, and the time and financial costs of application upgrade are high; if the old application system has no maintainable source code, this solution is not feasible.

[0027] Technical Route 2: Application system and data security can be decoupled, data integrity protection can be realized without modifying the application system, and database cell-level data integrity protection can be realized; but the application aspect technology has high complexity, needs to support different development languages, needs to adapt to different operating systems, needs to be compatible with different CPU architectures, needs to adapt to different application middleware, needs to adapt to different databases, and needs to parse complex database SQL, the project landing and implementation cost is high.

[0028] Technical Route 3: Can be free from the constraints of development language, operating system, CPU architecture, application middleware, etc., can realize the decoupling of data security and application system, can realize data integrity protection without modifying the application system, and can realize database cell-level data integrity protection; but the database gateway needs to parse the database protocol and complex database SQL, and the database gateway will also cause single point of failure, and even become a bottleneck for the application system to access the database.

[0029] Technical Route 4: Can avoid the shortcomings of the above three technical routes, but the granularity of database integrity protection is coarse, and only the integrity of the entire table or column data can be protected; the timing task cannot realize real-time perception of data tampering behavior, and cannot prevent the application system from using tampered data; in addition, the timing task will also waste the computing resources of the database server.

[0030] To this end, the application provides a database integrity protection scheme, which can comprehensively utilize the function mechanisms provided by a database management system such as a database view, a trigger, and a user-defined function to realize data integrity protection and verification without modifying an application system; can support specific algorithms such as SM3-MAC and SM4-MAC to guarantee the integrity of important data in a storage process. Compared with the prior art, the application does not require the application system to interface with a cryptographic device or modify source code, can realize database cell-level data integrity protection, and can prevent the application system from using tampered data.

[0031] The embodiment of the application discloses a database integrity protection method, referring to Figure 1 The method comprises the following steps: Step S11: selecting an original table in a database that needs to be subjected to integrity protection, and performing structural modification on the original table to add at least one integrity protection field to obtain a target table; the integrity protection field is used to store a message authentication code of at least one protected field.

[0032] In the embodiment of the application, the original table in the database that needs to be subjected to integrity protection is determined, a dedicated integrity protection field is configured for the protected field through the original table, and a corresponding message authentication code (MAC) is stored to achieve cell-level fine-grained protection. The following takes a physical table T as an original table and takes the integrity protection of an F1 field in the physical table T as an example for detailed description.

[0033] The specific process of performing structural modification on the physical table T can comprise: determining a modification sequence and selecting any of the following ways to perform modification on the physical table T. Way one: renaming the physical table T to T1, and then adding an integrity protection field H1 to the physical table T1; way two: adding the integrity protection field H1 to the physical table T, and then renaming the physical table T to the physical table T1. It should be noted that the H1 field is used to store the MAC value of the F1 field, denoted as H(F1); the MAC value is a fixed-length message authentication code generated based on a MAC algorithm, including but not limited to SM3-MAC based on an SM3 algorithm and SM4-MAC based on an SM4 algorithm, and meets the requirements of laws and regulations such as GB / T 22239-2019 “Basic Requirements for Information Security Level Protection” and GB / T 39786-2021 “Basic Requirements for Cryptographic Application of Information Systems”.

[0034] Step S12: creating a view with the same structure as the original table, and taking over data access to the original table through the view.

[0035] In the embodiment of the present application, the view T is created based on the modified target table (physical table T1) and has the same structure as the original table (physical table T). The view T is used to take over the access to the protected physical table T. When the application system performs the operations of adding, deleting, modifying and inquiring through the view T, the access to the physical table T1 is directly mapped. In this way, all the access operations are taken over by creating the view corresponding to the original table, the application system does not need to call the cryptographic device, does not need to modify the source code, and does not need the developer to master the cryptographic technology, so that the integrity protection function can be seamlessly connected, the function consistent with the technical route 1 is realized, and there is no cost of upgrading and modifying the application system.

[0036] Step S13: creating a database trigger on the target table, triggering the database trigger when a data insertion, update or deletion operation is performed through the view, calling a user-defined function, and generating, updating or maintaining the message authentication code in the integrity protection field according to a preset access control policy.

[0037] In a feasible implementation, three types of AFTER triggers are created on the target table, respectively associated with data insertion, update and deletion operations, and each type of trigger is configured to call a preset user-defined function (UDF) when triggered. Specifically, the database trigger includes an AFTER INSERT trigger, an AFTER UPDATE trigger and an AFTER DELETE trigger. Different triggers correspond to preset access control policies, and data operations are processed according to different access control policies to realize real-time monitoring at the cell level. It can be seen that, relying on the linkage mechanism of the AFTER trigger and the user-defined function (UDF), the permission verification and the MAC value processing can be triggered in real time when the data adding, deleting and modifying operations occur, and illegal tampering behavior can be recorded in real time.

[0038] Step S14: when data is queried through the view, the current message authentication code of the protected field is calculated and compared with the historical message authentication code stored in the integrity protection field, and data integrity verification is performed according to the comparison result.

[0039] In the embodiment of the present application, the application system performs the integrity verification process when querying data through the view. Specifically, the following steps are included: (1) when data is queried through the view, the current message authentication code of the protected field is calculated and compared with the historical message authentication code stored in the integrity protection field; (2) if the current message authentication code is the same as the historical message authentication code, it is determined that the protected field has not been tampered with, and the real data of the protected field is returned; (3) If the current message authentication code is different from the historical message authentication code, it is determined that the protected field has been tampered with, and a database standard error code is returned.

[0040] First, the real-time MAC value H(F1) of the protected field F1 is calculated, and then it is compared with the historical MAC value stored in the integrity protection field. If the real-time MAC value is consistent with the historical MAC value, it is determined that the protected field has not been tampered with, and the real value of the F1 field is returned to the application system; if the real-time MAC value is inconsistent with the historical MAC value, it is determined that the protected field has been tampered with, and a database standard error code is returned to the application system. It can be seen that the real-time check during query can directly intercept the use of tampered data (return an error code), avoid the misuse of tampered data by the application system, make the application system aware of data tampering, and at the same time, there is no need for a polling check by a timing task, solving the problem of poor real-time performance and waste of database computing resources in technical route 4.

[0041] In a feasible implementation, if the query efficiency is improved, the integrity check of the F1 field can be further optimized: first, before calculating the real-time MAC value of the protected field, the tampering behavior log of the database is queried. The log is recorded by the database trigger in step S13 to determine whether the target table data of the current query has data tampering behavior; next, the check is performed according to the scene: when it is determined that data tampering behavior has occurred, the MAC value H(F1) of the F1 field is calculated, and the MAC value is compared with the H1 field to filter out the un-tampered data and the tampered data, respectively, the real value of the un-tampered data is returned to the application system, and the database standard error code is returned to the application system. When it is determined that no data tampering behavior has occurred, the integrity check of the F1 field is simplified, for example, the MAC value is not calculated in real time, but the real data of the protected field is directly returned or only a quick check is performed, thereby reducing the consumption of computing resources and achieving a balance between real-time performance and efficiency.

[0042] It can be understood that when data is queried, part of the data in the system may be illegally modified (triggered to be recorded), but the specific field of the current query may not be touched, for example, an illegal user modifies the F2 field in the physical table T, but the F1 field is not touched, so the MAC value remains correct. When the MAC values match, it indicates that the field has not been tampered with, and it is safe to return the real data. Through the above optimization process, complete MAC calculation is avoided every time the query is performed, the database server load is reduced, and the query efficiency is improved. Moreover, the real-time record based on the trigger is simplified, rather than blindly skipping the check, so that once the tampering behavior is recorded, the system will immediately switch back to complete check, preventing the application system from using tampered data. In this way, through intelligent simplification, the long-term operation and maintenance computing cost is reduced, and the present application is more easily deployed in a resource-limited environment.

[0043] The application has the following advantages: first, by creating a view identical to the protected table structure, access to the protected table is taken over, and the data integrity protection does not affect the add, delete, modify and query operations of the application system, the source code of the application system does not need to be modified, and unnecessary adaptation, verification, upgrade and modification work is avoided. Second, when the data add, delete and modify operations occur, the authority verification and message authentication code processing can be triggered in real time through the database trigger, realizing cell-level fine-grained protection and accurately locating the tampered data. Finally, the data integrity is checked in real time during the query to avoid misuse of the tampered data by the application system, and to avoid resource waste caused by the timing task. It can be seen that all integrity protection logic is implemented inside the database through views, triggers and custom functions, without the need to parse the database protocol or complex SQL, and without the need to deploy additional gateways or application aspect components. The legitimate application system can access the database efficiently, and the implementation and maintenance costs are reduced.

[0044] In a feasible implementation, based on the above embodiments, the database trigger includes an AFTER INSERT trigger, an AFTER UPDATE trigger and an AFTER DELETE trigger. In addition, when the trigger triggers a user-defined function (UDF), a synchronous or asynchronous calling mode is supported according to the database load condition.

[0045] For example, when the current concurrent access amount of the database is lower than a preset threshold (such as CPU usage < 50%, connection number < 60% of the maximum connection number), the trigger synchronously calls the UDF, and after the UDF completes the MAC value calculation, the authority judgment and the tampering record, the trigger returns the execution result, ensuring strong consistency between the data operation and the integrity protection logic. When the current concurrent access amount of the database is higher than the preset threshold, the trigger asynchronously calls the UDF through the built-in asynchronous task queue (such as the Event Scheduler of MySQL), returns a temporary result of the data operation to the application system, and then executes the MAC value processing and tampering record logic of the UDF by the asynchronous thread.

[0046] The configuration of different data triggers and the operation process executed when triggered are described as follows: (1) The AFTER INSERT trigger is configured to trigger the calling of the user-defined function (UDF) and generate the message authentication code in the integrity protection field according to the first access control strategy when the data insertion is executed through the view. Specifically, the following operations are performed: When the data insertion is executed through the view, the user-defined function (UDF) is triggered to call to obtain the first operation information of the current access; the first operation information includes the corresponding database account, the source address, the database schema and the database table. determine the legal permission of the user performing the data insertion based on the first operation information; If the user is authorized, a first message authentication code of the protected field is generated and stored in the integrity protection field; If the user is unauthorized, a pseudo message authentication code is randomly generated and stored in the integrity protection field, and the data insertion is recorded as a first data tampering behavior.

[0047] In the embodiment, an AFTER INSERT trigger is established on the physical table T1. When the application system inserts new data through the view T, a user-defined function (UDF) is triggered and called. A first access control strategy generates a MAC value of the H1 field. Specifically, information of performing the current access is obtained, including a database account, a source address, a database schema, and a database table. The first access control strategy determines based on at least one of the database account, the source address, the database schema, and the database table. The legal permission of the current data insertion is determined according to the preset strategy, specifically including: if the user is authorized, a MAC value H(F1) of the F1 field is calculated and stored in the H1 field; if the user is unauthorized, a pseudo MAC value is randomly generated and stored in the H1 field, and the behavior of data tampering is recorded. In addition, if the performance of the inserted data is improved, the trigger can call the user-defined function (UDF) through asynchronous logic.

[0048] (2) The updated trigger is configured to trigger the user-defined function (UDF) when data update is performed through the view, and update or keep the message authentication code in the integrity protection field according to a second access control strategy. Specifically, the following operations are performed: When the data update is performed through the view, the user-defined function (UDF) is triggered to obtain second operation information of performing the current access; the second operation information includes a corresponding database account, a source address, a database schema, and a database table; determine the legal permission of the user performing the data update based on the second operation information; If the user is authorized, a second message authentication code of the protected field after the update is generated, and the second message authentication code is used to update the integrity protection field; If the user is unauthorized, the original message authentication code in the integrity protection field is kept unchanged, and the data update is recorded as a second data tampering behavior.

[0049] In the embodiments of the present application, an AFTER UPDATE trigger is established on the physical table T1, and when the application system updates data on the view T, a user-defined function (UDF) is triggered to call, and the MAC value of the H1 field is updated according to the preset second access control policy. Specifically, information of performing current access is obtained, including a database account, a source address, a database schema, and a database table; the second access control policy is based on at least one of the database account, the source address, the database schema, and the database table to make a judgment. The legal authority of the current data update is judged according to the preset policy, specifically including: if it is a legal user authorized, the MAC value H(F1) of the F1 field is calculated and updated in the H1 field; if it is an illegal user not authorized, the original MAC value is kept, that is, the value of the H1 field is not changed, and the data tampering behavior is recorded synchronously. In addition, if the performance of updating data is improved, the trigger can realize the calling of the user-defined function (UDF) through asynchronous logic.

[0050] (3) The delete-after trigger is configured to trigger the calling of the user-defined function (UDF) when data is deleted through the view, and record the data tampering behavior according to a third access control policy. Specifically, the following operations are performed: When data is deleted through the view, the user-defined function (UDF) is triggered to call to obtain third operation information of performing current access; the third operation information includes a corresponding database account, a source address, a database schema, and a database table; The legal authority of the user performing the data deletion is judged based on the third operation information; If it is an authorized legal user, the data is directly deleted; If it is an unauthorized illegal user, the data deletion is recorded as a third data tampering behavior.

[0051] In the embodiments of the present application, an AFTER DELETE trigger is established on the physical table T1, and when the application system deletes data on the view T, a user-defined function (UDF) is triggered to call. Whether the data deletion is a tampering behavior is judged according to the preset third access control policy, specifically including: information of performing current access is obtained, including a database account, a source address, a database schema, and a database table; the third access control policy is based on at least one of the database account, the source address, the database schema, and the database table to make a judgment. The legal authority of the current data deletion is judged according to the preset policy, specifically including: if it is an authorized legal user, the data deletion is not specially processed; if it is an unauthorized illegal user, the data tampering behavior is recorded. In addition, if the performance of deleting data is improved, the trigger can realize the calling of the user-defined function (UDF) through asynchronous logic.

[0052] As Figure 2 The whole flow of database integrity protection is shown as shown in the figure. On the premise of no modification of the application system, the functions and mechanisms provided by the database such as database view, trigger, user-defined function (UDF) and the like are comprehensively utilized to realize the integrity protection of data storage at the database logical layer, the data integrity protection at the database cell level can be realized, the behavior of data tampering can be perceived in real time, the application system using tampered data can be prevented, and the waste of database server computing resources can be avoided. Taking the F1 field in the fields (F1, F2, F3…Fn) of the physical table T as an example, the flow is as follows: 1. Structure adjustment: the physical table T is renamed as a physical table T1, and an H1 field is added for storing the integrity protection field (MAC value, such as generated based on the national secret algorithm SM3 / SM4) of the F1 field; 2. View takeover: a view T with the same structure as the physical table T is created, and the application system accesses data through the view T without perceiving the underlying changes; 3. Trigger monitoring: a trigger is set on the physical table T1 to monitor the increase, deletion and modification operations in real time: When inserting data, the trigger automatically calculates the MAC value of F1 and stores it in H1; if it is an illegal user, a pseudo MAC value is generated and the tampering behavior is recorded; When updating data, the legal user updates the MAC value, and the illegal user retains the original value and records the tampering behavior; When deleting data, illegal deletion will be recorded as tampering behavior; 4. Query verification: when the application system queries data, the system automatically compares the current MAC value of F1 with the H1 field; if they match, the real data is returned; if they do not match, it means that the data has been tampered with, and an error code is returned to remind the application system.

[0053] The application is based on the functional characteristics of the database itself, solves the integrity problem of data storage in the database through the database plug-in, realizes decoupling with the application system, is not limited by the running environment of the application system, is not affected by the development language, operating system, CPU architecture, application middleware and other factors of the application system, does not need to adapt to the application system and analyze the database SQL, avoids unnecessary adaptation work and reduces the implementation cost. The application utilizes the functional characteristics of the database, makes integrity protection to data storage in the database through the database plug-in, avoids the single point failure problem caused by network reasons; through the adaptive access control technology, the legal application system can realize efficient access to the database.

[0054] Correspondingly, the application also discloses a database integrity protection device, as shown in Figure 3 The device comprises: The original table reconstruction module 11 is configured to select an original table in a database that needs to be protected for integrity, and reconstruct the structure of the original table to add at least one integrity protection field to obtain a target table; the integrity protection field is configured to store a message authentication code of at least one protected field; The view creation module 12 is configured to create a view with the same structure as the original table, and take over data access to the original table through the view; The permission processing module 13 is configured to create a database trigger on the target table, and trigger the database trigger to call a user-defined function (UDF) when a data insertion, update or deletion operation is performed through the view, and perform generation, update or maintenance operations on the message authentication code in the integrity protection field according to a preset access control policy; The integrity verification module 14 is configured to calculate a current message authentication code of the protected field when data query is performed through the view, and compare the current message authentication code with a historical message authentication code stored in the integrity protection field, and perform data integrity verification according to a comparison result.

[0055] In the above embodiment, the working process of each module is more specific. The details are not repeated here.

[0056] As can be seen from the above scheme of the embodiment, first, by creating a view with the same structure as the protected table, the access to the protected table is taken over, and the data integrity protection does not affect the add, delete, modify and query operations of the application system. The application system does not need to modify the source code, and unnecessary adaptation, verification, upgrade and modification work is avoided. Second, when the data add, delete and modify operations occur, the permission verification and message authentication code processing can be triggered in real time through the database trigger, realizing the cell-level fine-grained protection, and accurately locating the tampered data. Finally, the data integrity is verified in real time during query, avoiding the misuse of tampered data by the application system, and avoiding the resource waste caused by the timing task. It can be seen that all integrity protection logic is implemented in the database through the view, trigger and custom function, without parsing the database protocol or complex SQL, and without deploying additional gateway or application aspect components. The high-efficiency access of the legal application system to the database is ensured, and the implementation and maintenance cost is reduced.

[0057] Further, the embodiment of the application also discloses an electronic device, Figure 4 The electronic device 20 is shown in the structure diagram according to an example embodiment, and the content in the diagram cannot be considered as any limitation on the use range of the application.

[0058] Figure 4A structural schematic diagram of an electronic device 20 is provided in the embodiments of the present application. The electronic device 20 can specifically include at least one processor 21, at least one memory 22, a power supply 23, a communication interface 24, an input / output interface 25 and a communication bus 26. The memory 22 is configured to store a computer program, and the processor 21 is configured to load and execute the computer program to implement the related steps in the database integrity protection method disclosed in any of the foregoing embodiments. In addition, the electronic device 20 in the embodiments of the present application can be specifically a computer.

[0059] In the embodiments of the present application, the power supply 23 is configured to provide working voltage for each hardware device on the electronic device 20; the communication interface 24 is capable of creating a data transmission channel between the electronic device 20 and external devices, and the communication protocol followed by the communication interface 24 can be any communication protocol applicable to the technical solution of the present application, which is not specifically limited here; the input / output interface 25 is configured to obtain external input data or output data to the outside, and the specific interface type can be selected according to the specific application needs, which is not specifically limited here.

[0060] In addition, the memory 22 as a carrier for resource storage can be a read-only memory, a random access memory, a magnetic disk or an optical disk, etc., and the resources stored thereon can include an operating system 221, a computer program 222 and data 223, etc., and the data 223 can include various data. The storage mode can be temporary storage or permanent storage.

[0061] The operating system 221 is configured to manage and control each hardware device on the electronic device 20 and the computer program 222, and can be Windows Server, Netware, Unix, Linux, etc. In addition to the computer program capable of completing the database integrity protection method executed by the electronic device 20 disclosed in any of the foregoing embodiments, the computer program 222 can further include a computer program capable of completing other specific work.

[0062] Further, the embodiments of the present application also disclose a computer readable storage medium, which includes a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a hard disk, a magnetic disk or an optical disk or any other form of storage medium known in the technical field. The computer program is executed by the processor to implement the foregoing database integrity protection method. The specific steps of the method can refer to the corresponding content disclosed in the foregoing embodiments, which will not be repeated here.

[0063] Further, the embodiment of the present application further provides a computer program product, comprising computer programs / instructions, which, when executed by a processor, implement any of the above-mentioned database integrity protection method.

[0064] The various embodiments described in the specification are progressive in nature, and each embodiment highlights the differences from other embodiments. The same or similar parts among the various embodiments can be mutually referred to. For the apparatus disclosed by the embodiments, since it corresponds to the method disclosed by the embodiments, the description is relatively simple, and the relevant parts can be referred to the method part.

[0065] The steps of the database integrity protection method or algorithm described in combination with the embodiments disclosed herein can be implemented directly by hardware, software modules executed by a processor, or a combination of both. The software modules can be placed in a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.

[0066] Finally, it should be noted that, in this document, the relationship terms such as first and second are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between the entities or operations. Moreover, the terms "include", "contain" or any other variants thereof are intended to cover non-exclusive inclusion, so that the process, method, article or device including a series of elements not only includes those elements, but also includes other elements not explicitly listed or inherent to such process, method, article or device. Without more limitations, the element defined by the statement "including a" does not exclude the presence of other identical elements in the process, method, article or device including the element.

[0067] The above has introduced in detail the database integrity protection method, device, equipment and storage medium provided by the present application. The principle and implementation manner of the present application have been described by applying specific examples in this document. The above embodiment description is only applicable to help understand the method of the present application and its core idea; at the same time, for those skilled in the art, according to the idea of the present application, the specific implementation manner and application range will be changed; in view of the above, the content of the specification should not be understood as a limitation of the present application.

Claims

1. A database integrity protection method, characterized in that, include: Select the original table in the database that needs to be protected for integrity, and modify the structure of the original table to add at least one integrity protection field to obtain the target table; The integrity protection field is used to store the message authentication code of at least one protected field; Create a view with the same structure as the original table, and take over data access to the original table through the view; A database trigger is created on the target table. When data insertion, update, or deletion operations are performed through the view, the database trigger is triggered to call a user-defined function and generate, update, or maintain the message authentication code in the integrity protection field according to the preset access control policy. When data is queried through the view, the current message authentication code of the protected field is calculated and compared with the historical message authentication codes stored in the integrity protection field, and the integrity of the data is verified based on the comparison result.

2. The database integrity protection method according to claim 1, characterized in that, The database triggers include insert triggers, update triggers, and delete triggers; the database triggers can select synchronous or asynchronous invocation methods according to the database load. The post-insertion trigger is configured to: when data insertion is performed through the view, trigger the call to the user-defined function and generate the message authentication code in the integrity protection field according to the first access control policy; The updated trigger is configured to: when data updates are performed through the view, trigger the invocation of the user-defined function, and update or maintain the message authentication code in the integrity protection field according to the second access control policy; The deletion trigger is configured to: when data deletion is performed through the view, trigger the call to the user-defined function and record the data tampering behavior according to the third access control policy.

3. The database integrity protection method according to claim 2, characterized in that, When data insertion is performed through the view, the user-defined function is invoked, and a message authentication code in the integrity protection field is generated according to the first access control policy, including: When data insertion is performed through the view, the user-defined function is invoked to obtain the first operation information for the current access; the first operation information includes the corresponding database account, source address, database mode, and database table; Based on the first operation information, determine the legitimate permissions of the user who performs the data insertion; If the user is an authorized and legitimate user, a first message authentication code is generated for the protected field, and the first message authentication code is stored in the integrity protection field. If the user is an unauthorized user, a fake message authentication code is randomly generated, and then the fake message authentication code is stored in the integrity protection field. The data insertion is recorded as the first data tampering behavior.

4. The database integrity protection method according to claim 2, characterized in that, When data updates are performed through the view, the user-defined function is invoked, and the message authentication code in the integrity protection field is updated or maintained according to the second access control policy, including: When data updates are performed through the view, the user-defined function is invoked to obtain second operation information for the current access; the second operation information includes the corresponding database account, source address, database mode, and database table. Based on the second operation information, determine the legitimate permissions of the user who performs the data update; If the user is an authorized and legitimate user, a second message authentication code is generated for the updated protected field, and the integrity protection field is updated using the second message authentication code. If the user is an unauthorized user, the original message authentication code in the integrity protection field remains unchanged, and the data is recorded as a second data tampering behavior.

5. The database integrity protection method according to claim 2, characterized in that, When data deletion is performed through the view, the user-defined function is invoked, and the data tampering behavior is recorded according to the third access control policy, including: When data deletion is performed through the view, the user-defined function is invoked to obtain third operation information for the current access; the third operation information includes the corresponding database account, source address, database mode, and database table. Based on the third operation information, determine the user's legitimate permissions to perform the data deletion; If the user is an authorized and legitimate user, the data will be deleted directly. If the user is an unauthorized or illegal user, the deletion of the data is recorded as a third-party data tampering act.

6. The database integrity protection method according to claim 1, characterized in that, Also includes: The database trigger is used to determine whether data tampering has occurred. If the database trigger determines that no data tampering has occurred, then the actual data of the protected field is returned directly. If the database trigger determines that the data tampering has occurred, when querying data through the view, the current message authentication code of the protected field is calculated and compared with the historical message authentication code stored in the integrity protection field, and data integrity verification is performed based on the comparison result.

7. The database integrity protection method according to any one of claims 1 to 6, characterized in that, When data is queried through the view, the current message authentication code of the protected field is calculated and compared with the historical message authentication codes stored in the integrity protection field. Data integrity verification is then performed based on the comparison result, including: When data is queried through the view, the current message authentication code of the protected field is calculated and compared with the historical message authentication codes stored in the integrity protection field; If the current message authentication code is the same as the historical message authentication code, it is determined that the protected field has not been tampered with, and the real data of the protected field is returned; If the current message authentication code is different from the historical message authentication code, it is determined that the protected field has been tampered with, and a database standard error code is returned.

8. A database integrity protection device, characterized in that, include: The original table modification module is used to select the original table in the database that needs to be protected for integrity, and modify the structure of the original table to add at least one integrity protection field to obtain the target table. The integrity protection field is used to store the message authentication code of at least one protected field; The view creation module is used to create a view with the same structure as the original table, and to take over data access to the original table through the view. The permission processing module is used to create a database trigger on the target table. When data insertion, update or deletion operations are performed through the view, the database trigger is triggered to call a user-defined function and generate, update or maintain the message authentication code in the integrity protection field according to the preset access control policy. The integrity verification module is used to calculate the current message authentication code of the protected field when data is queried through the view, compare it with the historical message authentication code stored in the integrity protection field, and perform data integrity verification based on the comparison result.

9. An electronic device, characterized in that, The electronic device includes a processor and a memory; wherein the memory is used to store a computer program, which is loaded and executed by the processor to implement the database integrity protection method as described in any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that, Used to store computer programs; wherein the computer programs, when executed by a processor, implement the database integrity protection method as described in any one of claims 1 to 7.

Citation Information

Patent Citations

  • Data processing, encrypting and integrity verification method, identity authentication method and system

    CN106790250A

  • Relational database information security enhancement method and system, terminal and storage medium

    CN113065151A

  • Verification method and device for data storage integrity, electronic equipment and storage medium

    CN115828322A

  • Transparent encryption method and system based on domestic database

    CN117113365A

  • Spatial data query method and system and electronic equipment

    CN117972235A