Web end input tamper-proof method and system
By adding a change listener event `orderAccountChangeEvent` to the input field on the web application page, checking the value of the `event.isTrusted` property and saving it to Redis, the problem of user input values being tampered with is solved, and the authenticity and security of input values are guaranteed.
Patent Information
- Application Number
- CN202410633568.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-21
- Publication Date
- 2024-09-06
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
In web applications, user input values may be modified by browser plugins or malicious scripts, causing the values sent to the backend to be inconsistent with the actual values entered by the user, thus affecting the user experience.
By adding a change listener event `orderAccountChangeEvent` to the input field on the web application page, the value of the `event.isTrusted` property is checked. If it is true, the input value is saved to the Redis database; otherwise, no processing is performed. Before submitting to the server, the consistency between the value on the web and the value in Redis is checked to ensure the integrity of the actual input value.
It effectively prevents user input values from being tampered with, ensures that the values stored in the Redis database are consistent with the values that the user expects to submit to the server, and ensures the authenticity and security of user input.
Smart Images

Figure CN118606933A
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of Web-side input tamper-proofing, and in particular to a Web-side input tamper-proofing method and system. Background Art
[0002] In existing Web applications, after users enter a value in the input box of the application page, it will be sent to the backend server for further processing, such as verification, storage, or execution of certain operations. However, this common user input mechanism faces a variety of security risks. One of the important issues is that the value entered by the user may be changed by browser plug-ins or malicious scripts, resulting in the value passed to the backend being inconsistent with the value actually entered by the user, thus affecting the user experience. Summary of the invention
[0003] In view of the above defects, the present invention proposes a method and system for preventing Web-side input tampering, aiming to solve the problem that in a common user input mechanism, the value input by the user may be changed by a browser plug-in or a malicious script, resulting in the value passed to the backend being inconsistent with the value actually input by the user.
[0004] To achieve this object, the present invention adopts the following technical solutions:
[0005] A method for preventing tampering of web input includes the following steps:
[0006] Step S1: Obtain the value inputValue entered by the user on the Web end and the user's identity number userId, and build a database Redis;
[0007] Step S2: Add the change listening event orderAccountChangeEvent;
[0008] Step S3: In orderAccountChangeEvent, determine whether the value of the event.isTrusted attribute is true. If so, save the field 'order'+'_account'+'userId' as the key and inputValue as the value in the database Redis. If not, do not process it.
[0009] Step S4: Get inputValue in the database Redis according to the fields 'order'+'_account'+'userId';
[0010] Step S5: Obtain the value that the user wants to submit to the server on the Web side, and determine whether the value that the user wants to submit to the server on the Web side is consistent with the inputValue in the database Redis. If they are consistent, it proves that the value that the user wants to submit to the server on the Web side is the value actually entered by the user; if they are inconsistent, it proves that the value actually entered by the user has been tampered with, and based on the tampered value, the event.isTrusted attribute value is obtained in orderAccountChangeEvent as false, then the tampered value will not be saved in the database Redis, to ensure that the value that the user wants to submit to the server on the Web side is the value actually entered by the user.
[0011] Preferably, in step S3, when the event.isTrusted attribute value in orderAccountChangeEvent is judged to be true, the field 'order'+'_account'+'userId' is saved as the key and inputValue as the value in the database Redis, and the following steps are also included: setting the saving time to 30 minutes.
[0012] Preferably, in step S5, when the value actually input by the user is tampered with, the change monitoring event orderAccountChangeEvent is dispatched through EventTarget.dispatchEvent().
[0013] Another aspect of the present application provides a system for preventing tampering of web-side input, the system comprising:
[0014] The first acquisition module is used to obtain the value inputValue entered by the user on the Web end and the user's identity number userId;
[0015] Building modules for building database Redis;
[0016] Add a module to add the change listener event orderAccountChangeEvent;
[0017] The first judgment module is used to judge whether the event.isTrusted attribute value is true in orderAccountChangeEvent. If so, the field 'order'+'_account'+'userId' is used as the key and the inputValue is used as the value to save it in the database Redis. If not, no processing is performed;
[0018] The second acquisition module is used to obtain the inputValue in the database Redis according to the fields 'order'+'_account'+'userId';
[0019] The third acquisition module is used to obtain the value that the user wants to submit to the server on the Web side;
[0020] The second judgment module is used to judge whether the value that the user wants to submit to the server on the Web side is consistent with the inputValue in the database Redis. If they are consistent, it proves that the value that the user wants to submit to the server on the Web side is the value actually entered by the user; if they are inconsistent, it proves that the value actually entered by the user has been tampered with, and based on the tampered value, the event.isTrusted attribute value is false in orderAccountChangeEvent, and the tampered value will not be saved in the database Redis to ensure that the value that the user wants to submit to the server on the Web side is the value actually entered by the user.
[0021] Preferably, it also includes: a time setting module, used to set the storage time to 30 minutes.
[0022] Preferably, in the second judgment module, when the value actually input by the user is tampered with, the change monitoring event orderAccountChangeEvent is dispatched through EventTarget.dispatchEvent().
[0023] The technical solution provided by the embodiments of the present application may have the following beneficial effects:
[0024] This solution adds a change listening event orderAccountChangeEvent to the input box of the Web application page. When the value entered by the user in the input box is tampered with by a browser plug-in or a malicious script, the event.isTrusted property value is false in orderAccountChangeEvent, and the tampered value will not be saved in the database Redis, ensuring that the value saved in the database Redis is consistent with the original value that the user expects to submit to the server, thereby ensuring that the value entered by the user in the input box is the actual value entered by the user, thereby preventing the value entered by the user in the input box from being tampered with. BRIEF DESCRIPTION OF THE DRAWINGS
[0025] Figure 1 The invention is a flowchart of the steps of a method for preventing tampering of web-side input. DETAILED DESCRIPTION
[0026] The embodiments of the present invention are described in detail below, and examples of the embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals represent the same or similar elements or elements having the same or similar functions from beginning to end. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present invention, and cannot be understood as limiting the present invention.
[0027] A method for preventing tampering of web input includes the following steps:
[0028] Step S1: Obtain the value inputValue entered by the user on the Web end and the user's identity number userId, and build a database Redis;
[0029] Step S2: Add the change listening event orderAccountChangeEvent;
[0030] Step S3: In orderAccountChangeEvent, determine whether the value of the event.isTrusted attribute is true. If so, save the field 'order'+'_account'+'userId' as the key and inputValue as the value in the database Redis. If not, do not process it.
[0031] Step S4: Get inputValue in the database Redis according to the fields 'order'+'_account'+'userId';
[0032] Step S5: Obtain the value that the user wants to submit to the server on the Web side, and determine whether the value that the user wants to submit to the server on the Web side is consistent with the inputValue in the database Redis. If they are consistent, it proves that the value that the user wants to submit to the server on the Web side is the value actually entered by the user; if they are inconsistent, it proves that the value actually entered by the user has been tampered with, and based on the tampered value, the event.isTrusted attribute value is obtained in orderAccountChangeEvent as false, then the tampered value will not be saved in the database Redis, to ensure that the value that the user wants to submit to the server on the Web side is the value actually entered by the user.
[0033] A method of anti-tampering of Web input in this solution, such as Figure 1As shown, the first step is to obtain the value inputValue entered by the user on the Web side and the user's identity number userId, and to build the database Redis. In one embodiment, the value entered by the user in the input box of the Web application page is 8888, and the identity number registered by the user on the Web application page is aa, then inputValue=8888, userId=aa. By building the database Redis, it is convenient to save the value entered by the user to Redis later. Redis is an open source, in-memory data structure storage system, which can be used as a database, cache and message agent. The second step is to add a change listening event orderAccountChangeEvent. In this embodiment, by adding a change listening event orderAccountChangeEvent in the input box, the change listening event can monitor changes in the input. When the input value of the input box changes, the event will be triggered. The third step is to determine whether the event.isTrusted attribute value is true in orderAccountChangeEvent. If so, the field 'order'+'_account'+'userId' is saved as the key and inputValue as the value in the database Redis. If not, no processing is performed. In one embodiment, if inputValue=8888, userId=aa, 8888 is the actual input of the user. Therefore, in the change monitoring event orderAccountChangeEvent, the event.isTrusted attribute value is true, and the field 'order_accountaa' is saved as the key and 8888 as the value in the database Redis. This is conducive to storing the values entered by different users. The fourth step is to obtain the inputValue in the database Redis according to the field 'order'+'_account'+'userId'. In this embodiment, when the key is "order_accountaa", the corresponding value 8888 is obtained from the database Redis.The fifth step is to obtain the value that the user wants to submit to the server on the Web side, and determine whether the value that the user wants to submit to the server on the Web side is consistent with the inputValue in the database Redis. If they are consistent, it proves that the value that the user wants to submit to the server on the Web side is the value actually entered by the user; if they are inconsistent, it proves that the value actually entered by the user has been tampered with, and according to the tampered value, the event.isTrusted attribute value is false obtained by judging in orderAccountChangeEvent, then the tampered value will not be saved in the database Redis to ensure that the value that the user wants to submit to the server on the Web side is the value actually entered by the user. In this embodiment, when the value that the user wants to submit to the server on the Web side is 8888, the inputValue saved in the database Redis is 8888. The two are compared. Since the two are consistent, it proves that the value that the user wants to submit to the server on the Web side is the value actually entered by the user. When the value that the user wants to submit to the server on the Web is 8886, and the inputValue saved in the database Redis is 8888, the two are compared. Since the two are inconsistent, it proves that the value that the user wants to submit to the server on the Web is not the value that the user actually inputs, and the value that the user actually inputs has been tampered with by the browser plug-in or malicious script. At this time, since the value 8886 that the user wants to submit to the server on the Web is a tampered value, it means that 8886 may not be directly triggered by the user. Therefore, in orderAccountChangeEvent, the event.isTrusted attribute value is false, and 8886 will not be saved in the database Redis, ensuring that the value that the user wants to submit to the server on the Web is inconsistent with the value saved in the database Redis, that is, ensuring that the value saved in the database Redis is consistent with the original value that the user expects to submit to the server.
[0034] This solution adds a change listening event orderAccountChangeEvent to the input box of the Web application page. When the value entered by the user in the input box is tampered with by a browser plug-in or a malicious script, the event.isTrusted property value is false in orderAccountChangeEvent, and the tampered value will not be saved in the database Redis, ensuring that the value saved in the database Redis is consistent with the original value that the user expects to submit to the server, thereby ensuring that the value entered by the user in the input box is the actual value entered by the user, thereby preventing the value entered by the user in the input box from being tampered with.
[0035] Preferably, in step S3, when the value of event.isTrusted attribute in orderAccountChangeEvent is true, the field 'order'+'_account'+'userId' is saved as the key and inputValue is saved as the value in the database Redis, and the following steps are also included: the saving time is set to 30 minutes. In this embodiment, when the fields 'order'+'_account'+'userId' and inputValue saved in the database Redis exceed 30 minutes, these values will be cleared, which is conducive to reducing the occupancy rate of the database Redis.
[0036] Preferably, in step S5, when the value actually input by the user is tampered with, the change listening event orderAccountChangeEvent is dispatched through EventTarget.dispatchEvent(). In this embodiment, EventTarget.dispatchEvent() is a method in the Web API. When the value actually input by the user is tampered with, and the change listening event orderAccountChangeEvent is dispatched through EventTarget.dispatchEvent(), it means that a part in the application is simulating the user input or value change, rather than being actually triggered by user interaction.
[0037] Another aspect of the present application provides a system for preventing tampering of web-side input, the system comprising:
[0038] The first acquisition module is used to obtain the value inputValue entered by the user on the Web end and the user's identity number userId;
[0039] Building modules for building database Redis;
[0040] Add a module to add the change listener event orderAccountChangeEvent;
[0041] The first judgment module is used to judge whether the event.isTrusted attribute value is true in orderAccountChangeEvent. If so, the field 'order'+'_account'+'userId' is used as the key and the inputValue is used as the value to save it in the database Redis. If not, no processing is performed;
[0042] The second acquisition module is used to obtain the inputValue in the database Redis according to the fields 'order'+'_account'+'userId';
[0043] The third acquisition module is used to obtain the value that the user wants to submit to the server on the Web side;
[0044] The second judgment module is used to judge whether the value that the user wants to submit to the server on the Web side is consistent with the inputValue in the database Redis. If they are consistent, it proves that the value that the user wants to submit to the server on the Web side is the value actually entered by the user; if they are inconsistent, it proves that the value actually entered by the user has been tampered with, and based on the tampered value, the event.isTrusted attribute value is false in orderAccountChangeEvent, and the tampered value will not be saved in the database Redis to ensure that the value that the user wants to submit to the server on the Web side is the value actually entered by the user.
[0045] The present solution provides a system for preventing tampering of Web-side input, which cooperates with each other through a first acquisition module, a construction module, an addition module, a first judgment module, a second acquisition module, a third acquisition module and a second judgment module, specifically by adding a change listening event orderAccountChangeEvent in the input box of the Web-side application page. When the value entered by the user in the input box is tampered with by a browser plug-in or a malicious script, the event.isTrusted property value is false as determined in orderAccountChangeEvent, and the tampered value will not be saved in the database Redis, thereby ensuring that the value saved in the database Redis is consistent with the original value that the user expects to submit to the server, thereby ensuring that the value entered by the user in the input box is the value actually entered by the user, thereby preventing the value entered by the user in the input box from being tampered with.
[0046] Preferably, it also includes: a time setting module for setting the storage time to 30 minutes. In this embodiment, by setting the time setting module, when the fields 'order'+'_account'+'userId' and inputValue stored in the database Redis exceed 30 minutes, these values will be cleared, which is conducive to reducing the occupancy rate of the database Redis.
[0047] Preferably, in the second judgment module, when the value actually input by the user is tampered with, the change monitoring event orderAccountChangeEvent is dispatched through EventTarget.dispatchEvent(). In this embodiment, when the value actually input by the user is tampered with, and the change monitoring event orderAccountChangeEvent is dispatched through EventTarget.dispatchEvent(), this means that a certain part in the application is simulating the user input or value change, rather than being actually triggered by user interaction.
[0048] In addition, each functional unit in each embodiment of the present invention may be integrated into a processing module, or each unit may exist physically separately, or two or more units may be integrated into one module. The above-mentioned integrated module may be implemented in the form of hardware or in the form of a software functional module. If the integrated module is implemented in the form of a software functional module and sold or used as an independent product, it may also be stored in a computer-readable storage medium.
[0049] Although the embodiments of the present invention have been shown and described above, it is to be understood that the above embodiments are exemplary and are not to be construed as limitations of the present invention. A person skilled in the art may change, modify, replace and vary the above embodiments within the scope of the present invention.
Claims
1. A method for preventing tampering of Web-side input, characterized in that: The following steps are involved: Step S1: Obtain the value inputValue entered by the user on the Web end and the user's identity number userId, and build a database Redis; Step S2: Add the change listening event orderAccountChangeEvent; Step S3: In orderAccountChangeEvent, determine whether the value of the event.isTrusted attribute is true. If so, save the field 'order'+'_account'+'userId' as the key and inputValue as the value in the database Redis. If not, do not process it. Step S4: Get inputValue in the database Redis according to the fields 'order'+'_account'+'userId'; Step S5: Obtain the value that the user wants to submit to the server on the Web side, and determine whether the value that the user wants to submit to the server on the Web side is consistent with the inputValue in the database Redis. If they are consistent, it proves that the value that the user wants to submit to the server on the Web side is the value actually entered by the user; if they are inconsistent, it proves that the value actually entered by the user has been tampered with, and based on the tampered value, the event.isTrusted attribute value is obtained in orderAccountChangeEvent as false, then the tampered value will not be saved in the database Redis, to ensure that the value that the user wants to submit to the server on the Web side is the value actually entered by the user.
2. A method for preventing tampering of Web-side input according to claim 1, characterized in that: In step S3, when the event.isTrusted attribute value in orderAccountChangeEvent is true, the field 'order'+'_account'+'userId' is saved as the key and inputValue as the value in the database Redis, and the following steps are also included: the saving time is set to 30 minutes.
3. A method for preventing tampering of Web input according to claim 1, characterized in that: In step S5, when the value actually input by the user is tampered with, the change monitoring event orderAccountChangeEvent is dispatched through EventTarget.dispatchEvent().
4. A system for preventing tampering of web-based input, characterized in that: Using the method for preventing Web-side input tampering as described in any one of claims 1 to 3, the system includes: The first acquisition module is used to obtain the value inputValue entered by the user on the Web end and the user's identity number userId; Building modules for building database Redis; Add a module to add the change listener event orderAccountChangeEvent; The first judgment module is used to judge whether the event.isTrusted attribute value is true in orderAccountChangeEvent. If so, the field 'order'+'_account'+'userId' is used as the key and the inputValue is used as the value to save it in the database Redis. If not, no processing is performed; The second acquisition module is used to obtain the inputValue in the database Redis according to the fields 'order'+'_account'+'userId'; The third acquisition module is used to obtain the value that the user wants to submit to the server on the Web side; The second judgment module is used to judge whether the value that the user wants to submit to the server on the Web side is consistent with the inputValue in the database Redis. If they are consistent, it proves that the value that the user wants to submit to the server on the Web side is the value actually entered by the user; if they are inconsistent, it proves that the value actually entered by the user has been tampered with, and based on the tampered value, the event.isTrusted attribute value is false in orderAccountChangeEvent, and the tampered value will not be saved in the database Redis to ensure that the value that the user wants to submit to the server on the Web side is the value actually entered by the user.
5. According to claim 4, a system for preventing tampering of web-side input, characterized in that: Also includes: The time setting module is used to set the saving time to 30 minutes.
6. According to claim 4, a system for preventing tampering of web-side input, characterized in that: In the second judgment module, when the value actually input by the user is tampered with, the change monitoring event orderAccountChangeEvent is dispatched through EventTarget.dispatchEvent().
Citation Information
Patent Citations
SDK (Software Development Kit)-based tamper-proofing method and system
CN107463855A
Webpage tamper prevention method, device and system
CN108073828A
Data verification method and device
CN115473668A
