Abstract:
The present invention relates to a solution to improve the security of applications. Particularly, the invention relates to the control of the whole lifecycle of data traffic between a client and a server applying also internal data flow system within the server only for editable data. The invention presents a method for detection of manipulation of data ( 29 ) by a client ( 11, 15, 25 ) that performs a request to a server ( 13, 17, 27 ) and detection of vulnerabilities within source code. The invention also presents an application and a system for the detection of manipulation in applications. As a particular example, the invention presents a method for detection of manipulation of web pages in HTTP.

Description:
TECHNICAL FIELD OF THE INVENTION 
       [0001]    The present invention relates to a solution to improve the security of interactions between a server and a client in client-server applications. Particularly, the invention relates to the control of the whole lifecycle of data traffic between a client and a server applying also internal data flow system within the server only for editable data. 
       BACKGROUND OF THE INVENTION 
       [0002]    In many kind of applications is necessary the information exchange between the client and the server side of the application, using usually some of the following security features:
       Authentication with a user name and its associated password or a digital certificate,   Cyphering the communication between the server and the client, using the protocol Secure Sockets Layer (SSL),       
 
         [0005]    However, even when the authentication process and the SSL (secure communications) are used, or even when the application source code is signed, it does not guaranty the integrity of the information that the client sends to the server. In other words, the client side it&#39;s the owner of the machine used by the client and it&#39;s possible the manipulation of the information existing in that machine (within memory, within files, etc.). 
         [0006]    For example, in a web application, the client uses the web application or page to make a web request, with said application the client can modify the web request changing the contract between the server and the client, said modifications could be for example:
       Modifying received parameters of the web page received from the server.   Adding new parameters in the web page.   Modifying the uniform resource locators (URL) of the web page received from the server.   Adding new URL to the web page received from the server (Performing requests on URL not received from the server).   Modifying or adding cookies to the request.   Modifying or Adding headers in the web page.       
 
         [0013]    In other words, the HTTP protocol allows making modifications at the client side so as modify all the data which are sent to the server, changing the original contract (GUI or API interactions) provided by the server. In addition, the client can try different type of attacks using legal input text fields, such as textbox fields within a form. 
         [0014]    For this reason, the requests received in the server must be validated because the reliability and the integrity of the received data are not always guaranteed. 
         [0015]    A solution provided in the state of the art is performing manual validations by software developers with the purpose of avoiding said vulnerabilities. The problem of this solution is not efficient and depends on the human factor; it would desirable an efficient and automatic solution. 
         [0016]    Another solution comprises installing an application firewall performing the validation process automatically; one example of these types of solutions is the application firewall Appshield created in 1999. This firewall is a hardware solution (an appliance) located between the client and the server and processes all the requests from the client and all the responses from the server. The firewall parses all the responses and generates a cyphered text for each link and form. When the client request reaches the firewall, the application verifies whether the request is matches the data generated at the server. The problem is that the parsing process of server responses is not efficient and it would be desirable to have an efficient method to validate all the requests from the client. At the same time this kind of solutions are not easily integrable within development environments, since an additional hardware element is necessary in order to run the solutions. In consequence, is common to find integration problems when the application is deployed within production environments where the application firewall is present. 
         [0017]    U.S. Pat. No. 8,510,827B1 relates to a method for taint tracking for security mechanism. The method “taints” the sensible information in terms of security, i.e. information that cannot be trusted and can modify the normal performance of the operating system. This method is oriented to the field of operating systems and virtualization systems. Therefore this method does not solve the lack of security in web services. 
         [0018]    In the state of the art HDIV open-source project (hdiv.org) improves the performance offered by application firewalls because HDIV does not need to parse the response of web applications, reading all the information from memory within the applications. In other words, HDIV extends the behaviour of some web frameworks (Struts 1, Struts 2, JSF, Spring MVC, Grails) controlling the information flow of the data. On the other hand, HDIV does not implement some of the functionalities implemented by the firewalls, such as stopping DOS attacks or networks attacks. At the same time, HDIV may apply blacklist and whitelist validation patterns against editable data, but does not offer a solution to detect vulnerabilities within source code to avoid risks related with editable data such as SQL injection or XSS web risks. 
         [0019]    The technical problem which is found in the state of the art is how to overcome the risks of the manipulation of applications from client side, preferably in HTTP, in an automatically and efficient way avoiding the need of modifying the source code of applications. 
         [0020]    Although some of the state of the art solutions try to control the data flow between the server and the client, existing solutions are not optimum in the implementation strategy, as it is explained herein below. 
         [0021]    Existing information flow control systems between server and client based on application firewalls, which in the present description is referred to as external implementation strategy, generate an excessive overload or performance overhead since the parsing is carried out on the HTML code coming from the server. At the same time existing JVM (Java Virtual Machine) internal data flow control systems based on compiled code transformation technique, in some cases known as instrumentation, such as HP Fortify or Contrast security products, monitors and control all the input data coming from web browsers at client&#39;s side, generating an extra work due to the monitoring of the whole set of received data. 
         [0022]    There is a need for a more efficient data flow control system controlling and understanding the information generated originally at the server. 
       STATEMENT OF THE INVENTION 
       [0023]    The present invention provides a solution for the aforementioned problem by a method for detection of manipulation of data by a client that performs a request to a server according to claim  1 , a system according to claim  9  and an application according to claim  13 . The dependent claims define preferred embodiments of the invention. All the features described in this specification (including the claims, description and drawings) and/or all the steps of the described method can be combined in any combination, with the exception of combinations of such mutually exclusive features and/or steps. 
         [0024]    In a first aspect of the invention there is provided a method for detection of manipulation of data by a client that performs a request to a server and detection of vulnerabilities within source code, implemented on a system that comprises:
       at least one client adapted to
           running requests to a server, comprising editable data and non-editable data, preferably editable data from text boxes or HTTP headers, preferably said requests are represented by data   receiving responses comprising editable and non-editable data from the server, preferably over the Hypertext Transfer Protocol (HTTP),   
           at least a server adapted to
           receiving said request from the client, and   sending said responses to the client,
 
where the method comprises the following steps:
   
           a. receiving, by either the server or an external entity, such as a firewall, a request from a client, if the request is an initial request go to step c),   b. if the request is a non-initial request,
           reading, by either the server or an external entity, such as a firewall, the request identifier from the received request,   detecting manipulation, by either the server or an external entity, such as a firewall, and finishing the method if the request identifier (STATE_ID) is different to the request identifier (STATE_ID) of a previous request that has been added to a data structure (STATE) created for each risk point of a response of a previous request in the same session, wherein a risk point is preferably predetermined resources or link or form, preferably comprising parameters,   detecting manipulation, by either the server or an external entity, such as a firewall, and finishing the method if the content received in the request is different to the content of the data structure (STATE) corresponding to the received request identifier (STATE_ID),   detecting manipulation, by either the server or an external entity, such as a firewall, and finishing the method if there is some additional parameter not included within an existing STATE,   if the request comprises at least an editable parameter which has been edited or completed by the client, storing by the server the representation of the data comprised in these fields on the server in a second type of data structure (TaintedObjects),   
           c. generating the response by the server, preferably a HTML page,   d. analysing, by server, if during the generation of the response, at least one risk point is generated, preferably URLs or link or forms,   e. if there is at least one risk point in the response,
           creating, by the server, a data structure (STATE) for each risk point, preferably resources, URLs or link or forms,   creating and associating, by the server, a request identifier (STATE_ID) to the data structure (STATE),   if the risk point comprises at least one parameter, identifying the typology, editable or non-editable, of the at least one parameter of the risk point, preferably the non-editable typology comprises one of a check box, radio button, select and editable typology comprises one of an editable field textbox or text area,   
           f. performing a predetermined action if the request comprises at least one editable parameter comprising content which is used during the generation of the response by the server, preferably in SQL queries or output writes improperly programmed known as sink point and sending, from the server, the response to the client or to an external entity,   g. receiving the response susceptible to be modified, by the client,   h. continuing in step a) if the client sends another request to the server in a same session, preferably using one of the request identifiers (STATE_ID) generated in the step e) of the current request, or a previous request inside the same session.       
 
         [0047]    The method defined in the present description is considered as a global information flow control method, since, applied on a system comprising a server and a client, the data are controlled ever since data, for example web pages, are rendered at the server and until said data are received back at the server side from a new request from the client. The global information flow control method is defined in the present invention and is carried out by implementing steps “a” to “g” referred to above. 
         [0048]    The firewalls are referred to, in the present description, as application firewall or web firewall in a wide sense, being suitable for any kind of application level protocol (7 th  OSI layer), preferably HTTP protocol. 
         [0049]    Said method is carried out applying at least one of known techniques adding an additional behaviour to a server or firewall, said behaviour being used for controlling the data flow globally within applications running on servers, but without amending original source code of said applications. These known techniques are:
       Compiled code transformation: this technique can be applied on runtime or in build process of the applications. Specifically the compiled product (for instance .class file in Java EE platform or .il files in .NET platform) is transformed to add the extra behaviour. In the build process transformation, the compiled code is transformed before the deployment of the application into the server. In other words, the deployment product (in Java environments .war, or .ear files) is already transformed before the deployment into the server. In the runtime case, the transformation is implemented when the compiled code is loaded in the memory of the server by the server. One implementation strategy for runtime transformation in Java environments is implementing through Java Instrumentation API.   APIs extension: this technique replaces the default implementation of an API or Interface used by an application running on a server (for instance Java, .NET, PHP platforms APIs, utilities libraries APIs, etc.) by other implementation provided by the invention. In order to change the implementation it is necessary to update the configuration files of the application, preferable XML files, but it is not necessary to update source code files of the application.   Additional code: especially in web environments such as (PHP, Java EE, .net) it is possible to add additional code that is executed before a request from a client is processed by a server application. This additional code or software component is known as “web filters” and allows adding an extra behaviour in a web request processing process without updating or amending the source code of the applications. An example of this software component is javax.servlet.filter. The web filter is applied within the application running on the server. In other non web environments this kind of extra behaviour may be applied using aspects (Aspect Oriented Programming) or similar software components.       
 
         [0053]    The risk points are referred to, in the present description, as the whole information contained in a link or form, as well as in other objects, such as resources, URL, parameters names, parameters values, and the like. Risk points may comprise editable or non-editable parameters. For example, risk points of the type “form”, may comprise editable parameters. 
         [0054]    The method according to the invention is carried out starting from step “a” for an initial request. The server generates the response data which is requested by the client. When processing the request, the server can “find” a risk point. 
         [0055]    At the request processing phase, for every risk point, both comprising editable parameters and non-editable parameters, a type of data structure is created, which in the present description is referred to as “STATE”. A STATE comprises:
       A string type variable for storing resources or identifiers, or preferably URL,   A string type variable for storing the state identifier, or also referred to as STATE_ID,   A map for storing parameter&#39;s names (the key of the map), and the values of the parameters (the value of the key within the map). The values are represented as an array.   A map for storing the types of parameters such as textbox, checkbox, radio button, text area, hidden, select (the key is the parameter name and the value the type of parameter).       
 
         [0060]    A STATE allows storing the content of the risk points and storing identifiers, in the present description referred to as STATE_ID, representing identification for each risk point. For a link, the STATE specifically may comprise the URL and parameter&#39;s names and values. For a form, a STATE may comprise: URL, parameter types, parameters names and parameters values. 
         [0061]    The following step is: sending the initial data requested to the client. 
         [0062]    For every request from the client the step referred to as “validation” is carried out. This is defined, in the steps of a method according to the invention in step “b” wherein validation comprises detecting manipulation if one of the options defined is verified; for this tasks, a comparison between the content of the STATE comprising the identifier (STATE_ID) and the content of the STATE corresponding to the incoming identifier (STATE_ID) is performed. In the case of the non-editable parameters or non-editable data, the comparison or validation is used in a manner such that the content the server sends to the client is stored and compared with the content of the corresponding object or field in the following request the client performs in a same session. This mechanism allows detecting a manipulation if a change in the content is noticed. Validation can be performed either in the server or in an external entity, such as an application firewall. In the last case, the STATE may be sent towards the firewall in the response from the server. Advantageously including the STATEs in a response allows having a better response time in the case where a firewall is used, since the tasks of structuring the data into data objects such as a STATE by the server allows the firewall to save time in parsing the response from the server, and thus only validating the information or data comprised in the STATE. 
         [0063]    If the client sends a new request (non-initial) within the same session to the server, the step “b” is carried out. 
         [0064]    In the present invention, if editable parameters or editable data are detected within the incoming request, step “b” comprises creating a second type of data structure, referred to as TaintedObject(s). TaintedObjects are adapted, at the receiving phase, to store the received parameter&#39;s value of the type “editable”, preferably being editable text boxes or text areas. TaintedObjects are characterised in that they comprise an array for pointers pointing at a memory location, where the value, name and identifier of the editable data are stored, wherein memory is understood as internal or external memory or a combination of both. 
         [0065]    TaintedObjects allow storing the content coming from editable data included within the request. The typology of the pointers or objects stored in this data structure are preferably text types; for example within Java programming language, String, StringBuffer, StringBuilder, CharArray. 
         [0066]    As a way of explaining example, for a non-initial request, for step “a” if the user sends a POST request including five parameters and one of them comes from editable data (param1), then in step “b” the TaintedObjects structure is created which comprises said object: 
         [0000]      TaintedObjects={param1}, 
         [0000]    where param1 in an embodiment is accountNumber. 
         [0067]    If any new TaintedObject is created or derived from the above TaintedObject list, it is included within this list. For example, if the server creates a new String from a previous tainted string, the “newString” is included within the previous list of parameters, as the example below: 
         [0000]      String SQL=“select . . . ”+accountNumber;
 
         [0000]      TaintedObjects={accountNumber, SQL} 
         [0068]    The above explained technique is referred to, in the present description, as propagation. 
         [0069]    In the state of the art, all the information coming from the client is treated as TaintedObjects in the examples above explained. In the present invention, this technique is applied only in the editable parameters or editable objects or data stored in TaintedObjects and the objects derived from said TaintedObjects. This is possible in the present invention due to a global information flow control method. 
         [0070]    In the case that no manipulation is detected, but a TaintedObject is used in some sink point during request processing, the method allows performing a predetermined action, which in a particular embodiment is to create an alert reporting, in an embodiment, the file and line number of the sink point in case this is in the form of programming code, or aborting the loading of the data, or performing proactive actions, preferably escape the string or executing secure functions. 
         [0071]    By applying the use of TaintedObjects to editable parameters or data, which is equivalent in the present invention to apply monitoring of data only on editable data, advantageously the efficiency is increased since the technique, in comparison to the state of the art, is not applied to the whole set of received data. 
         [0072]    Therefore, advantageously this method:
       avoids the lack security of the when a communication between a server and a client is susceptible of being modified, the method extracts the necessary information to identify automatically and efficiently the risk points, both editable and non-editable data, of a request sent by the client to a server, and   increases the efficiency of the data flow control method at the server, by monitoring the data coming only from editable parameters comprised in forms.       
 
         [0075]    The method guarantees the integrity of the received request automatically and efficiently. 
         [0076]    In an embodiment of a method according to the invention, if the request is received by an external entity ( 73 ), then the method further comprises
       before step c, a previous step of forwarding the request to the server,   further, for each non-initial request from the client, forwarding by the external entity towards the server the editable parameters from the first type of data structure (STATE),   in step f): sending, from the server to the external entity ( 73 ) all the data structures (STATE) created for the request along with the response,   after step f): a following step of
           forwarding, by the external entity ( 73 ), the response to the client and   storing, by the external entity ( 73 ), the STATES in the external entity ( 73 ).   
               
 
         [0083]    Further, for each non-initial request from the client, forwarding by the external entity towards the server the editable parameters from the first type of data structure (STATE). This is performed in order to taint, by the server, the data coming from editable parameters or fields. In the case where the STATE does not comprise editable parameters, this is not performed. 
         [0084]    In another embodiment of the method according the first aspect the STATES are organized, by the server, in a third type of data structure (SCREEN) and if the request is received by an external entity, then the STATES are sent to the external entity, in step f), organized in SCREENs so that the external entity stores the STATES in SCREENs. 
         [0085]    In another embodiment of the method according the first aspect, in the step for storing all STATE generated for each risk point in a SCREEN, can be performed either
       in the internal memory of a server, or   shared among the internal memory in the server plus one or more complementary servers, or   in memory of an external entity.       
 
         [0089]    Due to the screen data structure the STATES related with previous data, for example web pages or native screens within and Android native app viewed by a user in the same session, can be managed and stored together. This is especially useful to avoid an excessive memory consumption within the server, limiting the number of screens stored at server side and allowing to delete them, in an embodiment, when the maximum number of screens is reached (for instance 5 screens). 
         [0090]    In an embodiment the step for creating, by the server, a data structure (STATE) further comprises,
       storing the content of the data structure (STATE) corresponding to each risk point in a storing space, preferably internal memory in the server, or   storing the content of the data structure (STATE) corresponding to each risk point in the data which is sent to the client, and storing a hash value of said content in a storing space, preferably internal memory in the server, or   cyphering the content of the data structure (STATE) corresponding to each risk point and storing said cyphered content in the data to be sent to the client.       
 
         [0094]    Advantageously, this embodiment allows implementing bespoken solutions. For example, if there is not enough storing space on a server, the strategy of hashing can be used since less storing space is required. 
         [0095]    In another embodiment of the method the step for reading the request identifier (STATE_ID) from the received request comprises:
       checking the data structure (STATE) of the request identifier (STATE_ID) in a memory space, preferably the internal memory of the server, or   generating a second hash of the content of the received data structure (STATE) of the data received in the request, or   deciphering content of the data structure (STATE) corresponding to each risk point.       
 
         [0099]    This embodiment provides a solution for how to recover de information of the request received in the server from the client. This is an advantage because it can recover the information from the request according to one of the previous alternatives for storing the content of the data structure. 
         [0100]    In a particular embodiment the STATES are organized by the server in a third type of data structure or SCREEN and wherein, if the request is received by an external entity, then the STATES are sent to the external entity, in step f), organized in SCREENS and the external entity stores the STATES in SCREENS. 
         [0101]    Advantageously this third type of data structure allows system scalability and it further allows organizing the STATE in, for example, one SCREEN per session. Also, the response time is reduced since the SCREENS are stored in the external entity and the information to validate is organized. The resources which were employed in the state of the art for seeking information to compare against the requests sent from client side in order to validate can be now employed in other tasks. 
         [0102]    In an embodiment it is possible to store only the last screen within the server, and the other SCREENS (the oldest ones) within another external server. This advantageously allows reducing the memory consumption at the server side. The external server, for instance a memory Database such as Redis, may store big amounts of data in memory, without the performance overhead generated commonly within JVM and .NET “Common Language Runtime” environments due to garbage collection tasks. 
         [0103]    In an embodiment it is possible to store only the last screen within the JVM or .NET memory and the rest of screens within the server but outside the memory controlled by execution environments garbage collector. This technique is known as off-heap memory storage. 
         [0104]    Advantageously as a difference with the state of the art, this embodiment provides a solution for increasing the capacity of the server adding a new complementary server. 
         [0105]    Advantageously as a difference with the state the art, this embodiment provides an integration and collaboration between external entities, such as application firewalls, and the server side applications where the invention is applied. In other words, the information required by the firewall (the SCREEN data structure) is sent to the application firewall avoiding the overhead of response parsing. Thanks to this information (SCREEN data structure) the firewall can implement validation tasks as well as additional security functionalities implemented by this kind of products (DOS attacks, load balancing, etc.). This is an advantage over HDIV open-source solution because the global security solution is better that the independent solutions (application firewall and HDIV independently). 
         [0106]    In an embodiment, the method is applied to detect manipulation of web pages by a web client that performs a web request to a web server and detection of vulnerabilities within source code, implemented on a system that comprises:
       at least one web client,   at least a web server adapted to   a telecommunication network in connection to the web client and the web, through which the request and the web response are sent,
 
where the method comprises the following steps:
   a) receiving, by either the web server or an external entity, a web request from a web client, if the web request is an initial web request go to step c),   b) if the web request is a non-initial web request,
           reading, by either the web server or an external entity, such as a firewall, the request identifier (STATE_ID) from the received request represented by a string (STR),   detecting manipulation, by either the web server or an external entity, such as a firewall, and finishing the method if the request identifier (STATE_ID) is different to the request identifier (STATE_ID) of a previous request that has been added to a data structure (STATE) created for each risk point of a web page of a previous request in the same web session, wherein a risk point is preferably a predetermined link or web form, preferably comprising parameters,   detecting manipulation by either the web server or an external entity, such as a firewall, and finishing the method if the content received in the request is different to the content of the data structure (STATE) corresponding to the received request identifier (STATE_ID),   if the request comprises at least an editable parameter which has been edited or completed by the client, storing ( 36 ) the representation of the data comprised in these fields on the web server, in a second type of data structure (TaintedObjects),   
           c) generating the web response by the web server, preferably a HTML page,   d) analysing, by web server, if during the generation of the response, at least one risk point is generated, preferably link or web forms,   e) if there is at least one risk point in the response,
           creating, by the web server, a data structure (STATE) for each risk point, preferably link or web forms,   generating and associating, by the web server, a request identifier (STATE_ID) to the data structure (STATE),   if the risk point comprises at least one parameter, identifying the typology, editable or non-editable, of the at least one parameter of the risk point, preferably the non-editable typology comprises one of a check box, radio button, select and editable typology comprises one of an editable field textbox or text area,   
           f) performing a predetermined action if the request comprises at least one editable parameter comprising content which is used during the generation of the response by the server, preferably in SQL queries or output writes improperly programmed known as sink point and sending, from the web server, the web page to the web client or to an external entity,   g) receiving, from the web client, the web page susceptible to be modified by the web client or by an external entity,   h) continuing in step a) if the web client sends another web request to the web server in a same session web, preferably using one of the request identifiers (STATE_ID) generated in the step e) of the current request, or a previous request inside the same web session.       
 
         [0125]    In a second aspect of the invention there is provided a system comprising
       a server adapted to perform the method steps of a method according to the first aspect when they are referred to a server,   a client in communication to the server through a telecommunications network adapted to perform the method steps of a method according to the first aspect when they are referred to a client.       
 
         [0128]    In the present description “server” is understood as a hardware element where the server side of applications are hosted. 
         [0129]    In an embodiment the server is a web server and the client is a web client, whereas the responses generated by the web server are web pages and the requests sent by the web client are web requests. In this embodiment, the web server may be one of APACHE, IIS, or application server, such as TOMCAT, WEBSPHERE, in such manner that the method of the first aspect of the invention may be implemented in any programming environment comprising either servers—such as in APACHE—, or application servers—such as in JAVA—. In general terms, a server is the device or machine where a web application is hosted, independently of the environment it is implemented on. 
         [0130]    For example, in environments such as MICROSOFT or PHP, “server” may be interpreted as server (APACHE, IIS), and in environments such as JAVA, “server” would be interpreted as application server (TOMCAT). 
         [0131]    In a third aspect of the invention there is provided an application for detection of manipulation of applications by a client that performs a request to a server and detection of vulnerabilities within source code, the application adapted to run on a server and comprising:
       means for analysing whether at least one risk point is generated during the generation of the response,   means for creating a data structure (STATE) for each risk point,   means for associating, a request identifier (STATE_ID) to the data structure (STATE),   means for checking whether the risk point comprises at least one parameter,   means for identifying the typology of the at least one parameter of the risk point   means for reading the request identifier (STATE_ID) from the received request preferably represented by a string (STR),   means for detecting manipulation and for rejecting the request if the request identifier (STATE_ID) is different to the request identifier (STATE_ID) of a previous request that has been added to a data structure (STATE) created for each risk point of a response of a previous request in the same session,   means for detecting manipulation and for rejecting the request if the content received in the request is different to the content of the data structure (STATE) corresponding to the received request identifier (STATE_ID),   means for storing the representation of the editable data comprised in the request and received by the server in a second type of data structure (TaintedObjects),       
 
         [0141]    In an embodiment, the application further comprises:
       means for performing a predetermined action if at least some data included in the second type of data structure (TaintedObject) is used in a sink point during the generation of the response by the server or   means for using functions included within libraries in the application or solutions or functions available within the server.       
 
         [0144]    As a difference with the state of the art, this application also allows proactive actions in runtime; for example, allows escaping a TaintedObject used by the code in runtime, and also allows that the code for performing such actions is embedded in the server in libraries.
       Advantageously, an application according to this embodiment detects when a TaintedObject is used in a sink point, for example SQL queries or writes generating a response output improperly programmed,       
 
         [0146]    As a difference with the state of the art, the application and method create an alert for the server and/or performs proactive actions, preserving the security in the server. 
         [0147]    In an embodiment of the application, it is adapted to perform the relevant steps of any one of the particular embodiments of the first aspect of the invention. 
         [0148]    The security solutions in the state of the art mainly consider the entire client requests to be suspicious of being dangerous for the server, and thus the solutions of the state of the art tend to analyse the whole request. This invention, instead, once has analysed the integrity of non-editable data, only controls or monitors editable data within the request processing, because it is possible to trust the rest of the data due to the integrity checks implemented previously. This fact advantageously saves resources such as memory or CPU consumption. 
         [0149]    All the features described in this specification (including the claims, description and drawings and/or all the steps of the described method can be combined in any combination, with the exception of combinations of such mutually exclusive features and/or steps. 
     
    
     
       DESCRIPTION OF THE DRAWINGS 
         [0150]    These and other characteristics and advantages of the invention will become clearly understood in view of the detailed description of the invention which becomes apparent from preferred embodiments of the invention, given just as an example and not being limited thereto, with reference to the drawings. 
           [0151]      FIG. 1A  This figure represents an embodiment of the architecture on which a method according to the state of the art is implemented. 
           [0152]      FIG. 1B  This figure represents an embodiment of the architecture on which a method according to the invention is implemented showing a client ( 15 ) and a server ( 17 ). 
           [0153]      FIG. 2A  This figure shows an example of method steps implemented according to the invention, where a client ( 25 ), a server ( 27 ) and a web page ( 29 ) are represented. 
           [0154]      FIG. 2B  This figure shows an example of method steps implemented according to the invention, where a first type of data structure (STATE), a second type of data structure (TaintedObject) and a third type of data structure (SCREEN) are represented next to a web page ( 29 ). 
           [0155]      FIG. 3  This figure shows a flow diagram of an embodiment of a method according to the invention. 
           [0156]      FIG. 4  This figure shows a flow diagram of an embodiment of a method according to the invention which uses a build process technique for being implemented on a server. 
           [0157]      FIG. 5  This figure shows a flow diagram of an embodiment of a method according to the invention which uses a runtime technique for being implemented on a server. 
           [0158]      FIG. 6  This figure shows an exemplary scheme for illustrating the technic of propagation. 
           [0159]      FIG. 7  This figure shows an exemplary embodiment where the method is performed on a system comprising a client ( 71 ), a server ( 75 ) and a firewall ( 73 ). 
       
    
    
     DETAILED DESCRIPTION OF THE INVENTION 
       [0160]    Once the object of the invention has been outlined, specific non-limitative embodiments are described hereinafter. 
         [0161]    The method according to the invention is carried out applying known techniques in order to add an additional behaviour to the server behaviour which is used for controlling the data flow globally within, for example, web applications running on servers, but without amending original source code of said applications. In an embodiment, the method is applied performing compiled code transformation: 
         [0162]    Compiled code transformation: this technique can be applied on build process of the applications or in runtime. An example of such processes is represented in  FIG. 4  for build process and in  FIG. 5  for runtime process. Specifically the compiled product ( 41 ) or server application, for instance .class files in Java EE platform or .il files in .NET platform, are transformed to add the extra behaviour, and thus resulting in an amended version ( 43 ) of the server application. In the build process transformation ( 42 ), the compiled code is transformed before the deployment of the application into the server ( 44 ). In other words, the deployment product ( 43 ), for instance .war, or .ear files in Java environments, is already transformed before the deployment into the server ( 44 ). 
         [0163]    As a way of an example, there is shown, in  FIG. 1A , an embodiment of the architecture on which a method according to the state of the art may be implemented. In this case the client ( 11 ) exchanges ( 14 ) requests and responses with the server ( 13 ) in a web environment. 
         [0164]    To avoid the weakness of the Hypertext Transfer Protocol (HTTP), a firewall ( 12 ) is used in the state of the art, which first of all parses the HTML response and afterwards uses the extracted information in order to validate the incoming requests. 
         [0165]    In  FIG. 1B  there is an embodiment representing an embodiment of the architecture in which a method according to the invention may be implemented. The client ( 15 ) exchanges ( 16 ) requests and responses with the server ( 17 ) adapted to implement a method according to the invention. In this embodiment, the method is implemented as an application or subroutine ( 18 ) on the server ( 17 ) detecting manipulation of web requests received. 
         [0166]    As a way of an example, an embodiment of the invention is shown in  FIG. 2A , representing the method ( 28 ) steps implemented on the architecture described previously. The client ( 25 ) requests an initial web request ( 21 ) to the server ( 27 ). For example the client ( 25 ) requests “http://web.com” ( 21 ). 
         [0167]    In this case the server ( 27 ), where the method ( 28 ) is implemented, analyses whether the request ( 21 ) is an initial request. In this embodiment since the request ( 21 ) is an initial request, the server ( 27 ) loads the web page ( 29 ) and checks whether there are any risk points. The server ( 27 ) creates a first type of data structure (STATE) for each risk point, as it is represented in  FIG. 2B . Subsequently the server ( 27 ) associates a request identifier (STATE_ID) to the first type of data structure (STATE). In  FIG. 2B  a representation of three first types of data structures (STATE) is shown, first for a link, second for a form, and third for a different form. Besides, for each editable field, in this case the two text boxes, a second type of data structure is created (TaintedObject). 
         [0168]    In this embodiment, the first types of data structures (STATE) are stored in a third type of data structure (SCREEN). 
         [0169]    As the method steps in  FIG. 2A  show, the server ( 27 ), after creating the data structures (STATE) for each risk point and storing them in internal memory, allows associating an identifier (STATE_ID) for each risk point. The association is made by the web server, by modifying the response or web page, preferably adding an additional parameter to each link or URL and to each form; After associating the identifier (STATE_ID) to each risk point, the method allows sending ( 22 ) the web page ( 29 ) to the client ( 25 ), which comprises, as explained, an associated identifier (STATE_ID) for each risk point; this is represented in  FIG. 23 . 
         [0170]    The client modifies ( 23 ) the link with malware or the text boxes are edited with SQL queries in order to obtain a malicious behaviour. 
         [0171]    The client ( 25 ) sends a new request ( 24 ) comprising one of the state and states_id (STATE_ID_1, STATE_ID_2, STATE_ID_3) for each risk point shown in  FIG. 23  to the server in the same web session; the server ( 27 ) reads the new request ( 24 ) which is sent in a form of a string (STR); the server ( 27 ) checks:
       if the received State identifier (STATE_ID) is the same as any of the previous identifiers (STATE_ID_1, STATE_ID_2, STATE_ID_3) created for previous requests stored in the server, and   If the content of the request is the same as the content stored in the corresponding first type of structures (STATE1, STATE2, STATE3),   For the editable fields, or text boxes, the server checks whether the text field data is used in an unsuitable way, for example with an unsuitable programming code, or malware programming code, known as sink points, for instance a SQL query without parameterized queries or a write without escaping the data.       
 
         [0175]    For example, if the URL of the link included in the web page ( 29 ) is http://servercom?accountId=10&amp;STATE_ID=3, the user may change the value of the parameter accountId, for instance accountId=10, in order to try to watch the account data from another user. 
         [0176]    Thanks to the extra parameter added by the method to each link and form, in that case STATE_ID=3, it is possible to read at server side the STATE related to this link and implement the validation process using this information. In that case, the request is rejected due to the fact that the value is different from the original value. 
         [0177]    In this embodiment, since the client ( 25 ) has manipulated the link, the loading of the web page ( 29 ) is aborted and the session ends. 
         [0178]    If the user submit one of the web forms included in the web page ( 29 ), and the value that come from the text field is used in a sink point, the application ( 28 ) on the server ( 27 ) performs a predetermined action before the execution of the sink point, which in this embodiment is to create an alert and implement a proactive action to solve the risk such as escape the data or use a secure function instead of the original function. 
         [0179]    In an embodiment in which there is not manipulation, the server ( 27 ) accepts the request ( 24 ) and continues processing the request ( 29 ) requested by the client ( 25 ). 
         [0180]    As a way of an example, there is shown, in  FIG. 3 , a flow diagram of an embodiment of the method. In a first step a server, receives ( 31 ) a request from a client. The server checks ( 32 ) if it is an initial request, preferably searching within a predefined list or URLs defined at the server side. 
         [0181]    Case One: Initial Request: 
         [0182]    The server receives ( 31 ) a request from the client which is an initial request. 
         [0183]    The server starts generating the response ( 37 ), and analyses ( 38 ) if the response contains any risk point, in which case the server generates ( 39 ) a first data structure, or STATE, for each risk point. In order to detect the risk point the invention intercepts or extends the functions or subroutines used by the web framework or library to create links or forms. The source code is not changed or amended or updated because the extension is applied through configuration (XML or annotations) and not through updating source code. 
         [0184]    Subsequently, the method allows the server to check ( 391 ) whether any sink point is used, i.e., if an editable parameter or TaintedObject is used as input parameter of a sink point, a predetermined action is performed ( 392 ). The server sends ( 393 ) the response to the client. 
         [0185]    The client receives the response. 
         [0186]    If the client does not make any other request the session expires. 
         [0187]    If the client makes another request the process is executed again, with a non-initial request, as follows. 
         [0188]    Case Two: The Request is Not an Initial Request: 
         [0189]    The server receives ( 31 ) a request which is not an initial web request. The server reads ( 33 ) the web request received, and detects ( 34 ) if there is a parameter with the name STATE_ID which is the identifier of the request. If there is not a parameter named STATE_ID the request is rejected and the method ends ( 310 ). Otherwise the server reads the STATE data structure generated on a previous request, and analyses or validates ( 35 ) whether the non-editable parameters are the same as the values include within the corresponding STATE data structure, in order to determine that manipulation has not existed; in case of manipulation of any non-editable parameter, then manipulation is detected. Also, if there is some additional parameter not included within a STATE data structure, the request is rejected. 
         [0190]    If the validation is overcome, then it is checked ( 311 ) whether there is any editable parameter included within the request; in case that there are any editable parameters comprising some content, this content is stored ( 36 ) within TaintedObjects data structure. 
         [0191]    The server generates or renders ( 37 ) the response, and the method continues analysing ( 38 ) if the response contains any risk point, in which case the server generates ( 39 ) a first data structure, or STATE, for each risk point. 
         [0192]    If the is any point where the server generates any new content derived from the contents stores within TaintedObjects data structure, the generated content is stored ( 36 ) within TaintedObject data structure as well. This process is known as propagation. This propagation is performed thanks to the transformation of compiled classes. This transformation is performed in load time, in runtime or in the build process. An example of propagation can be seen in  FIG. 6 , where starting from having two TaintedObjects, in the  FIG. 6  represented by the name of TO1 and TO2, a new object is created by adding “data” to one of them, which is represented by the name SQL, this, a new Tainted Object represented in the figure by SQL is created. 
         [0193]    In this specification, overload or performance overhead or overhead is any combination of excess or indirect computation time, memory, bandwidth, or other resources that are required to attain a particular goal. 
         [0194]    Subsequently, the method allows the server to check ( 391 ) whether any TaintedObject is used as input parameters in a sink point. 
         [0195]    Examples of these sink points functions are:
       Database access in Java environments where there is the risk related with SQL Injection attacks:       
 
         [0000]    
       
         
               
               
             
           
               
                   
                   
               
             
             
               
                   
                 public java.sql.Statement.execute*(String); 
               
               
                   
                 public java.sql.PreparedStatement.execute( ); 
               
               
                   
                   
               
             
          
         
       
       
         
           
             Writes in the response where there is the risk related with XSS web risk: 
           
         
       
     
         [0000]    
       
         
               
               
             
           
               
                   
                   
               
             
             
               
                   
                 javax.servlet.jsp.JspWriter.print(String); 
               
               
                   
                 javax.servlet.jsp.JspWriter.write(String) 
               
               
                   
                   
               
             
          
         
       
     
         [0198]    If the use of any TaintedObject is detected ( 391 ) as input parameter of any sink function, the invention generates a log and a proactive action is performed ( 392 ) such as escaping the content in order to avoid XSS or SQL Injection attacks. In the example below there is in example of an escape function—( 392 ) String escapedString=escapeFunction(String)—added by the invention before the sink point execution. In other words, the invention does not execute the sink point until it has analysed input parameters and executed some proactive action ( 392 ). Subsequently the sink point is executed in the same way as original source code. 
         [0000]    
       
         
               
               
             
           
               
                   
                   
               
             
             
               
                   
                 (392) String escapedString= escapeFunction(String); 
               
               
                   
                 (391) Statement.execute(escapedString); 
               
               
                   
                   
               
             
          
         
       
     
         [0199]    Note that this extra behaviour is added within compiled classes and the server application or the application source code remains the same. 
         [0200]    If there is any risk point within the response (link or form renderization) the invention intercepts all the server functions that process this kind of components. The functions intercepted by the invention depend on the technology used by the server. 
         [0201]    Some examples of this type of functions using two of the most used technologies (Java, .NET) are shown below:
       Java, for instance Spring MVC web framework:       
 
         [0000]    
       
         
               
               
             
               
               
             
               
               
             
               
               
             
           
               
                   
                   
               
             
             
               
                   
                 &lt;html&gt; &lt;body&gt; 
               
               
                   
                 (38) &lt;form:form method=″post″ modelAttribute=″person″&gt; 
               
             
          
           
               
                   
                 &lt;form: input path=”name”&gt; 
               
             
          
           
               
                   
                 &lt;/form&gt; 
               
             
          
           
               
                   
                 &lt;/html&gt;&lt;/body&gt; 
               
               
                   
                   
               
             
          
         
       
     
         [0203]    The text above ( 38 ) represents the functions that in this case the form generates. The invention intercepts these functions in order to obtain the data stores within STATE data structures (url, parameters names, parameters values, etc.)
       .NET, for instance ASP MVC framework.       
 
         [0000]    
       
         
               
               
             
               
               
             
               
               
             
           
               
                   
                   
               
             
             
               
                   
                 &lt;html&gt; &lt;body&gt; 
               
               
                   
                 (38) @using (Html.BeginForm)) 
               
               
                   
                 { 
               
             
          
           
               
                   
                 @Html.TextBoxFor(model =&gt;model.Name) 
               
             
          
           
               
                   
                 } 
               
               
                   
                   
               
             
          
         
       
     
         [0205]    In order to measure the performance overhead avoided by the invention the table below the shows the necessary time for the core operations of the TaintedObjects propagation and monitoring algorithm. Basically there are two types of operations:
       Search: in every function that may use a TaintedObject is necessary to search within TaintedObject data structure to verify if the data is tainted or not. The invention intercepts any function within the program that uses as Input data String or character type parameters. The number of search operations is directly related to the number of functions that may use TaintedObjects (any programming language type that contains String type formats or similar, for instance in Java language: String, StringBuffer, StringBuilder, Char, etc.) Insert: if any of the input parameters used by a function is Tainted the resultant   Objects must be included within TaintedObject Data Structure.       
 
         [0208]    In the tables below the results obtained within a Java 7 Environment are presented. 
         [0000]    
       
         
               
               
               
               
               
             
               
               
               
               
               
             
           
               
                   
               
               
                 Search 
                 Search time 
                 Insert 
                 Insert time 
                 TOTAL 
               
               
                 operations 
                 (ms) 
                 operations 
                 (ms) 
                 overload/overhead 
               
               
                   
               
             
             
               
                   
               
             
          
           
               
                 500 
                 0.2 ms 
                 250 
                 0.1 ms 
                 0.3 ms 
               
               
                 1000 
                 0.4 ms 
                 250 
                 0.2 ms 
                 0.5 ms 
               
               
                   
               
             
          
         
       
     
         [0209]    This overload is related with the core operations of the invention but there are also additional operations that add more overload time. An average overload around 0.5 ms per request may be considered. 
         [0210]    The impact of this overload depends on the business model of the application. Within web environments in different technologies (Java, .NET, PHP), the fastest web response time in the state of the art is usually comprised in a range of 3 ms-8 ms. The overload avoided by the invention (0.5 ms per request) is between 16%-5% (0.5 ms is the 16% of 3 ms and the 5% of 8 ms) because the most important part of web request does not include any editable data. 
         [0211]    In a request including editable data this percentage is lower considering that in most of the cases web pages comprise a low number of editable fields compared to the total amount of non-editable fields; this is to say, there is, in most of the cases, about a 10% of editable parameters over the total number of parameters/fields. 
         [0212]    Regarding memory consumption generated by any possible TaintedObject propagation and monitoring system, the memory consumption is directly related with the number of TaintedObjects included within the data structure and the typology of this data. For instance in Java environments, the reference to an object uses about 4-8 bytes, depending on how many bits the operating system is based on, or the program (32 or 64 bytes). Besides, the data related with the origin of the TaintedObject data is stored (http parameter, for example, accountID, name or equivalent, etc.), thus consuming more memory space. TaintedObjects are created for a particular HTTP parameter, for example accountID; this is what is referred herein by “origin”. 
         [0000]    
       
         
               
               
               
               
             
           
               
                   
               
               
                 Number of  
                   
                   
                   
               
               
                 Tainted Objects 
                 Tainted DataStructure 
                 Size per item 
                 TOTAL SIZE 
               
               
                   
               
             
             
               
                 200 
                 20 bytes 
                 6 bytes 
                 1.3 KB 
               
               
                 500 
                 20 bytes 
                 6 
                   3 KB 
               
               
                   
               
             
          
         
       
     
         [0213]    The size per item is the memory consumption due to a single web request. A server receives commonly an average of 300 request per second, so the algorithm may generate a memory consumption of 300 KB-900 KB per second, or around 18 MB-54 MB per minute. 
         [0214]    The invention reduces the memory consumption because, unlike the state of the art solutions which only consider tainted data, the data that come from editable fields. For instance in requests that don&#39;t include editable data (usually 80-90% of the web request because links doesn&#39;t have editable data) the invention don&#39;t use memory at all. In the rest of the requests (20-10%) the amount of consumed memory is lower due to the invention only monitor editable data. 
         [0215]    As a way of example, in  FIG. 7  there is shown an scenario in which the data structures (STATE) are stored in SCREENS, said SCREENS being sent in the response towards an external entity ( 73 ), such as a firewall, and the firewall being the one performing the steps of the method corresponding to the validation of non-editable parameters, this is, some of the steps of step b of a method according to the invention. 
         [0216]    This is an embodiment wherein the method, in the step for storing all STATE generated for each risk point in a SCREEN, is performed in memory of an external entity ( 73 ). 
         [0217]    The scenario in  FIG. 7  presents:
       A client ( 71 ) sends a request ( 72 ) towards a server ( 75 ), the request being intercepted by the firewall ( 73 ),   The firewall ( 73 ) receives ( 31 ), a web request from the client ( 71 ), and forwards the request ( 74 ) towards the server ( 75 ), where other method steps are performed, namely:
           creating, by the server ( 75 ), a STATE for each risk point,   associating, by the server ( 75 ), a STATE_ID to the STATE,   if the risk point comprises at least one parameter, identifying the typology, editable or non-editable, of the at least one parameter of the risk point, preferably the non-editable typology comprises one of a check box, radio button, select and editable typology comprises one of an editable field textbox or text area   performing a predetermined action ( 392 ) if the request comprises at least one editable parameter comprising content which is used ( 391 ) during the generation of the response by the server, preferably in SQL queries or writes known as sink point,   creating a SCREEN comprising the STATES created for the current session,   
           Subsequently the server ( 75 ) sends ( 76 ) the response together with the SCREEN created for the web session to the firewall ( 73 ),   The firewall ( 73 ) filters the SCREEN and the response. The response is sent towards the client ( 71 ) whereas the SCREEN is stored in the firewall. Advantageously, this method saves internal memory in the server ( 75 ) and improves the performance of the firewall avoiding the parsing process of the response,   receiving, from the client ( 71 ), the web page susceptible to be modified by the client ( 71 ),   restarting the process if the client ( 71 ) sends another web request to the server ( 75 ) in a same session web, preferably using a request identifiers (STATE_ID) generated in the step f) of the current request, or a previous request inside the same web session.       
 
         [0229]    Subsequently, for every request within the same web session, the client ( 71 ) sends ( 72 ) requests which the firewall ( 73 ) intercepts. The firewall ( 73 ) then sends the request ( 74 ) together with the STATE or, in the case of the figure, the SCREEN which has been created for the current web session. As long as the same web session continues, the firewall ( 73 ) stores the SCREEN coming from the server ( 75 ), and checks whether the incoming requests must be rejected according to the comparison of the incoming identifiers with the STATE_ID comprised in the SCREEN. 
         [0230]    The advantages of structuring the data in the structure SCREEN and sending it to the firewall ( 73 ) embedded in the response are:
       response time is speeded up within the firewall, with respect to the state of the art where the firewall needs to parse and analyse the whole response generated at the server, preferably in HTML, XML, JSON formats, and   memory space within the server ( 75 ) is saved as neither STATE nor SCREENS need to be stored in the server ( 75 ).       
 
         [0233]    Particular Example: Native Mobile Application: 
         [0234]    In this particular example, the following steps are implemented:
       A native mobile application, for instance an Android or IOS app ( 71 ), sends a request ( 72 ) towards a server ( 75 ), the request being intercepted by the firewall ( 73 ),   The firewall ( 73 ) receives ( 31 ), the request from the client ( 71 ), and forwards the request ( 74 ) towards the server ( 75 ), where other method steps are performed, namely:
           creating, by the server ( 75 ), a data structure (STATE) for each risk point, preferably link or web forms,   associating, by the server ( 75 ), a request identifier (STATE_ID) to the data structure (STATE),   if the risk point comprises at least one parameter, identifying the typology of the at least one parameter of the risk point wherein the risk point is preferably a of non-editable field, more preferably a check box, radio button, select and an editable field textbox or text area   performing a predetermined action ( 392 ) if the request comprises at least one editable parameter comprising content which is used ( 391 ) during the generation of the response by the server, preferably in SQL queries or writes known as sink point,   creating a SCREEN comprising the STATES created for the current session.   
           Subsequently the server ( 75 ) sends ( 76 ) the response together with the SCREEN created for the session to the firewall ( 73 ),   The firewall ( 73 ) filters the SCREEN and the response. The response is sent towards the client ( 71 ) whereas the SCREEN is stored in the firewall. Advantageously, this method saves internal memory in the server ( 75 ) and improves the response time of the firewall avoiding the parsing time of the whole response,   receiving, from the client ( 71 ), the data susceptible to be modified by the client ( 71 ),   continuing the process if the client ( 71 ) sends another request to the server ( 75 ) in a same session, using one of the request identifiers (STATE_ID) generated previously in the current request, or a previous request inside the same session;   subsequently, for every non-initial request from the client the firewall ( 73 ) forwards towards the server ( 75 ) the editable parameters from the STATE, which are received in every request, in the case the request comprises editable parameters.