Web Security: Emerging Threats and Defense

Web applications have become a widely accepted method to support the internet for the past decade. Since they have been successfully installed in the business activities and there is a requirement of advanced functionalities, the configuration is growing and becoming more complicated. The growing demand and complexity also make these web applications a preferred target for intruders on the internet. Even with the support of security specialists, they remain highly problematic for the complexity of penetration and code reviewing methods. It requires considering different testing patterns in both codes reviewing and penetration testing. As a result, the number of hacked websites is increasing day by day. Most of these vulnerabilities also occur due to incorrect input validation and lack of result validation for lousy programming practices or coding errors. Vulnerability scanners for web applications can detect a few vulnerabilities in a dynamic approach. These are quite easy to use; however, these often miss out on some of the unique critical vulnerabilities in a different and static approach. Although these are time-consuming, they can find complex vulnerabilities and improve developer knowledge in coding and best practices. Many scanners choose both dynamic and static approaches, and the developers can select them based on their requirements and conditions. This research explores and provides details of SQL injection, operating system command injection, path traversal, and cross-site scripting vulnerabilities through dynamic and static approaches. It also examines various security measures in web applications and selected five tools based on their features for scanning PHP, and JAVA code focuses on SQL injection, cross-site scripting, Path Traversal, operating system command. Moreover, this research discusses the approach of a cyber-security tester or a security developer finding out vulnerabilities through dynamic and static approaches using manual and automated web vulnerability scanners.


Introduction
A web application vulnerability enables an intruder to crack into the web application to execute unwanted things on specific victim's sites. The most advanced security vulnerabilities are found in the systems, networks, and application programs of present-day applications. Web applications are open to the public by description, including malicious attackers [1]. Moreover, input to web applications is via Hypertext Transfer Protocol (HTTP) request and response for transferring data over the web, and accurately processing the input can be highly challenging. In recent years, these attacks on web applications have been on the top of the list of hazardous attacks. The most significant and noteworthy examples are Cross-Site Scripting (XSS), which is a type of injection where malicious scripts are injected, and Structured Query Language injection (SQLi) that uses malicious SQL code for backend database manipulation [2].
The end users are using their systems more creatively in the present day than in the past decade. A maximum number of applications are executed online over the network since web applications can replace desktop applications. The information of users that is connected to the internet; can be accessed from any location [3]. Moreover, the developer is aware of the version used by the end-user and hence, conveniently providing support. However, despite having these advantages, there are a few disadvantages. When the server is offline or the end-user does not have access to the internet, the service is unavailable, and the end-user cannot access their information. Furthermore, the end-user should also trust that the web application will protect confidential information, both in terms of availability and confidentiality. It would ensure that the information would not disappear and be accessible to the people he provides authorizations [4].
The user should also consider the major disadvantages. When the server is offline or the end-user does not have accessibility to the internet, the service would be unavailable, and the end-user would not get access to information. However, the web application itself also has to be highly secured. The web application's security is within the developer's skills, and hence, he has to be knowledgeable of all the exploits and the approach of evading them. It can be a challenging job in small web applications and for helping the duty security testing tools be built and examining the web application for security flaws. This paper examines the security measures in web applications by addressing techniques that can be done by different tools, manual processes, and a few vulnerabilities that web applications might experience.
One of the most distinct goals that impact the determination to research this area; is to promote an approach that would significantly influence the fight against web application vulnerabilities, especially cases that concern applications written within PHP and JAVA. A reduced rate of exploits is observed by focusing on the web application vulnerabilities within web applications. The success of this specific objective is possible by producing an appropriate approach towards securing web applications in the source code in PHP and JAVA applications and even selecting the appropriate web application scanner to make the applications more secure.
To prevent malicious access, the web application should be secured. The web application is protected within the developer's skill set, and therefore, they require to know about all the exploits and the approach to work around them. It can be challenging for small web applications and examine the web application for security vulnerabilities [5,6]. Vulnerabilities and attack detection processes are reported based on features' selection [7]. The drawback of this approach is its subjective nature due to ranking. In the paper [8], the authors have presented a planning-based attack model. The disadvantage of this model was that the representation is extremely small. This research aims to explore and analyze four vulnerabilities from the most common and critical vulnerabilities found in a web application in both PHP and JAVA code. A comprehensive description of the vulnerabilities, exploitation, and testing is discussed in [8] using manual and automated web vulnerability scanners. Moreover, this research examines different security measures in web applications.
The main contributions of this research are summarized as follows: This research explores and analyzes vulnerabilities found in a web application in both PHP and JAVA codes. It examines the security measures in web applications by using techniques that can be performed by the tools manually and examination of some of the vulnerabilities that web applications might experience. The research also aims to promote an approach that would significantly influence the fight against web application vulnerabilities, especially cases concerning applications written in PHP and JAVA. It has proposed an appropriate approach towards securing web applications in source code in PHP and JAVA applications and choosing a suitable web application scanner to make the applications more secure.
The main part of the paper is organized as follows: i) Related work in web security, threats attacks, and countermeasures are discussed in section two.
ii) Research Methodology is illustrated in section three.
iii) A detailed discussion of the implementation and result analysis is discussed in section four.
iv) The paper is concluded in section five.

Related Work
A literature review has been conducted to explain the modern state-of-the-art automated web application security scanners using dynamic and static analysis. It has also intended to explain the primary issues of the subject and summarize the essential concepts of existing challenges and attacks, such as SQL injection attacks, OS command Injection, Cross-Site Scripting, and directory traversal [9][10][11]. The advanced development methods include specific frameworks and libraries for regulating effective and quick approaches to improve market requirements. A web application vulnerability allows an intruder to penetrate the web application for performing unwanted aspects on the specified pages of the user. In Durai et al. [12], the authors explained the differences between vulnerability assessment and exploitation and the approach of an assessment to be performed for SQL injection attacks, cross-site scripting attacks, and cross-site request forgery attacks. They even mention secured code reviews and penetration testing in the development lifecycle to identify and mitigate significant vulnerabilities in web applications.
The white-box testing method uses an examination of the programming code to detect major exploitations in the applications. The examination of the programming code can be done either in the traditional style of testing, i.e., manually, or with the help of tools. The black-box testing process, on the contrary, analyzes the execution of an application and detects the issues. This particular examination process is termed penetration testing, in which the scanner sends massive, predefined HTTP requests. Similar to white box testing, black box testing can be done either manually or with tools. In [13], the authors explain a system that automatically detects and mitigates the attacks. Web applications are inefficient in checking the correctness of the data request. For this reason, intruders can exploit their power by inserting the malicious data into the application, bypassing the website's security attributes. The inserted parameters should be examined for their effectiveness in terms of their information representation and field labeling. Patterns and values examine the legitimacy of the parameters for the occurrence of null values, duplicate values.
In [14], the authors have discussed the Injection Attack (IA) classification, which classifies SQLi and is exploited in PHP. The standard and extensive learning-based IA algorithms have appeared to teach and estimate the classification types with the help of testing and validation features of data input from the code source data. A prototype has been taught using a Convolutional NN, and it produced the most significant accuracy of 95.4%. In comparison, another prototype based on Multilayer Perceptron has achieved the highest recall of 63.7% and the most significant measure of 74.6%. The main functionalities of this specific vulnerability scanning system have been realized, and the scanning results show the probability of the technical analyses. In [15], the authors have examined a couple of open and freely available static investigation tools, with a couple of weakly designed applications for vulnerability identification. These are made of insecure applications as evidence after the testing process. Both of them produce results after running the tests.
These results are documented and examined using the Open Web Application Security Project's (OWASP) WAP and static code analysis tool RIPS to detect vulnerabilities in PHP source code. The XSS exploits are classified into two classes, called inside and outside. The inside-cross-site scripting occurs within the corresponding website, where the exploit is to be inserted. In this class, the exploit is also executed on the machine when that inserted page is being clicked. For the outside XSS, the exploit is executed through the browser. Paper [16] has addressed identification of characteristic exploitation in PHP code. It extends the traditional custom design with a component called cleans. It refers to designing of different sanitation methods. An inactive and behind-the-information investigation procedure is provided to discover technical exploits based on the unique design. The tool of POSE performs this process, and the investigation results have proved that the procedure is highly efficient for discovering techniques in web application exploits. The input given by the end-user is included in an HTTP request created by the web server or takes place somewhere in the HTML pages of the Document Object Model (DOM). DOM is a programming interface for HTML.
Cross-site scripting exploits can be broken into web-server-side exploits and client-side vulnerabilities. The web-server-side XSS exploits mostly covered "reflected XSS" and "stored XSS". The client-side exploit is applicable to DOM Cross-site scripting [17]. It distinguishes and examines advanced study outcomes on XSS discovery, breaks them into three vital sections to various tools, and these three sections include static examination, dynamic examination, and hybrid examination. They list 30 discovery methods, make overall similar analyses, and note on powers and flaws of discovered XSS exploits. Sqlmap is a free exploit discovery and pen-testing tool that finds out SQL injection attacks. This tool also automates identification and impacting SQLi exploits and allows for getting across the databases. Havij GUI is an established SQLi tool that benefits all pen testers to identify and exploit SQL injection weakness in a web application [18]. The study reported in [18] is successfully converged on popular and common vulnerabilities like SQLi, XSS, and Cross-Site Request Forgery (CSRF) and explaining such exploitations of the exploits with DVWA. Benefits of the web exploit with discovery and security refers to a reliable web access policy plan.
Machine learning (ML) exceeds difficulties that people can determine. Various ML types, such as Logistic Regression, information description, are significant for design performance. It is essential to collect and choose the convenient characteristics that are utilized to describe any information situation. Deep learning (DL) types, rather than defining the features, are likely to study them concurrently with the primary task. In [19], the authors have performed an extensive learning type capable of analyzing PHP parts as vulnerable or not to the SQL injection. This strategy is meant to suit the workflow of web applications' support written in server-side programming languages like PHP, JSP, and ASP. In [20], the authors have proposed a strategy that combines the software support lifecycle with system examination. All unprotected codes are recreated for showing the recommended encoder. It is validated with the help of a valuating censure method to obtain a conventional replacement. Evaluation of this method has remained successful for an open-source pharmaceutical application written in JSP.
In [21], the authors have performed a combined examination strategy for examining web applications related to the concerns of SQLi exploits and proposed a SQL-INJECTION tool capable of automatic SQLi exploits examination in web applications. In [22], the authors have built the first level RegExps for SQL Injection discovery from network traffic. To identify malicious SQL Injection of web traffic, it uses legitimate expressions obtained from popular SQL Injection tools. SQLi is amongst the traditional protection warnings to cloud databases that work by expanding applications that install their settings on the cloud. Session Hijacking happens when an intruder gains entrance to the session of a particular enduser. The intruder slices a legitimate session identifier applied to go inside the system and take the information. Privilege Escalation refers to the end-user getting the rights of different users. These rights can be utilized to remove data, observe confidential data, or even place undesired applications like viruses. A directory traversal is additionally recognized as path traversal. Directory traversal exploits mainly inadequate validations of browser inputs from end-users.
The algorithm Vul-Scan is applied to create a deception method for mutating examination data automatically. The algorithm chooses methods that meet the victim system and scan class, do not break the conflicted relationship, and follow the hierarchy relationship. The input is victim system data, the most evasion techniques, scan type, and evasion methods database. The authors have developed a web scanner, VulScan, which creates analysis data by utilizing a mixture of deception methods. It avoids filters and Web application firewalls (WAFs) to expose SQLi and XSS exploits [23].
The discovery of XSS vulnerability starts with the Pixy tool to investigate the origin codes for illustrating the control flow graph (CFG) and obtain the PHP source code's entire paths. A few paths of the Control Flow Graph are introduced as unseen routes, which means they will not perform. Consequently, they have pushed the unseen routes to provide reliable outcomes, and they utilized the GA generator on the unseen routes completely. The GA generator begins to initialize an arbitrary group of irregular Cross-site scripting hateful scenarios as inputs. The convenience function estimates the outcomes of the population in every generation. This paper has developed the discovery strategy of XSS exploits in PHP by implanting that elimination step to the discovery strategy as a whole to identify and eliminate Cross-site scripting. The outcomes have proved the ability of the suggested strategy to identify and eliminate Cross-site scripting exploits in PHP [24]. A logic exploit appears when programmers have produced a relevant mistake in their applications. It might be extremely easier, similar to the decreasing price in calculating it or any aspect, which has occurred completely ignored. This study explains the aspects of entirely automated and standard pen-testing techniques that result in identifying certain exploits.

Research Methodology
This research aims to explain the high-risk vulnerabilities in web applications and helping the security developers and penetration testing teams have secure code in their applications. It will also compare the web application scanner statically and dynamically for all selected vulnerabilities. It is needed to set up a workstation on Windows and Linux with all the tools to analyze the vulnerable codes of PHP and JAVA. After setting up the workstation, the vulnerable web application will be examined and explained, in which the vulnerability occurs in the code, and the approach of it can be secured through the code review process. Tools are also run and analyzed statically and dynamically in PHP and JAVA. After completing the vulnerable web application analysis and explaining how the exploits work and how to secure them, the web application scanner will scan the vulnerable web application for any kind of vulnerability and then compare the results of different tools. The benefits associated with the investigation include an indepth analysis of the selected vulnerabilities within the source codes, gaining insights into the existing vulnerabilities, learning remediation strategies for reducing exposure to the identified vulnerabilities, and providing assistance to the security developer and penetration tester selecting the right scanner tool. The research process is shown in Fig. 1. There are a variety of tools for static as well as dynamic source code scanners (Acuntix [25], NetSparker [26], BurpSuitePro [27], SonarCloud [28], Cobra [29], VulnyCode [30], ASST [31], AppSpider 7 [32], FindBug [33]). Some of them are commercial, and others are free and open source. The support of scanning PHP and JAVA applications allows different vulnerabilities that this study focuses on: SQL, XSS, Path Traversal, and OS Command. It also focuses on the popularity of the tools and accuracy in finding the vulnerability. A basic script to find vulnerabilities in a PHP source code; uses Regular Expression to find vulnerabilities. It can also find out bugs and implements a program that uses static analysis to look for bugs in Java code. Experimental Setup to scan the vulnerability in the web application is shown in Fig. 2. Vulnerability in the web application is scan with the help of static and dynamic web scanners.

Vulnerabilities and Attack Analysis
SQL injection is a web security vulnerability that allows an attacker to interfere with the queries of an application to its database. It usually enables an attacker to view data that is usually unrecoverable. This might be related to data for other users or other data that the application itself can reach. In many cases, an attacker can modify or delete this data, permanently altering the content or performance of the application. SQL injection consistently appears in the Open Web Application Security Project's (OWASP) list of top 10 security risks [34].

SQL Injection in PHP Code
The SQLi attack occurs when an SQL statement selects a specific user with a specified user ID. Fig. 3 shows the PHP SQLi Vulnerable Code 1. Fig. 4 generates a SELECT statement by adding a variable "id" to a select string. The variable is fetched from user input: When there is no validation to prevent a user from entering "malicious" input, the user might enter a "smart" input such as 'AND 1=1'. This SQL statement is correct and returns ALL rows from the Users table because AND 1=1 is always TRUE in the SQL statement. It also indicates that the SQL queries can bypass ACL by avoiding regular authorization and authentication checks, and the distinct SQL queries even may provide a way to host OS-level commands. The primary purpose of the code was to build an SQL statement for selecting a user with a provided user id. When there is no validation to prevent a user from entering "malicious" input; the user can enter some "clever" input like provided below:

SQL Injection in JAVA Code
SQL Injection attacks work because, in various applications, the most distinct method is to perform a provided computation and dynamically produce code that is run by another system or component. When we use untrusted data without proper sanitization, we often drop an open door for the intruders to exploit in generating this code. Let us take a view of how this occurs in the following example shown in Fig. 5.
The problem of this specific code is apparent. We have put the username value into the query with no validation. Exploiting this query code is trivial, and all the attackers have to send a condition that, when concatenated with the fixed part of the query, it is needed to modify the expected performance:  The SQL statement above (Fig. 6) is correct and will return ALL rows from the "Users" table since OR a=a is always TRUE in the SQL statement.

Cross-Site Scripting in PHP Code
Cross-site scripting (XSS) attacks are injections in which malicious scripts are being inserted into trusted websites. XSS happens when an attacker uses a web application to push malicious code, usually on a browser's page, to another end user. Vulnerabilities that allow attacks to work are quite well known and take place in every location. A web application accepts input from a user within the output it produces without validating or encrypting it. When there would be a variable that outputs some data directly to the browser without validation, it can lead to the execution of XSS attacks. An attacker exploits this vulnerability by intercepting the POST or GET requests and injecting the variables with harmless JavaScript codes. In the following example (Fig. 7), a sample of a vulnerable code to XSS in PHP is provided.
The vulnerable variables are $gty and $isbn. The code echoes the number of books directly in the cart and the book ISBN without sanitization of validation. It results in the execution of an XSS (Fig. 8).
An attacker will exploit this vulnerability by intercepting the POST request and injecting the variables with harmless javascript codes. In the following example (Fig. 9), a sample of a vulnerable code to XSS in JAVA is provided.
The parameter XSS is unescaped or sanitized. It will print any input it receives from the user. A malicious attacker can inject JavaScript code into the application (Fig. 10).
An attacker will exploit this vulnerability by injecting the GET request with harmless JavaScript codes. In the following example, the script passes the $file_name variable an unvalidated/unsensitized HTTP request value directly to the $file_dir variable to get the path to upload the file to it.

Directory Traversal in JAVA Code
A path traversal attack (identified as directory traversal) aims to reach files and directories that are stored outside the Webroot directory [34]. In the example (Fig. 11), a web service receives a parameter named filepath that corresponds to the name of a file previously in the server's directory. Different attackers can also control the parameter to read files in the system leading to information disclosure. The attacker would initiate the request as following to read files in the system. By manipulating variables that reference files or foldersfile path../) sequences and their changes, or by using absolute file paths, it can likely reach out arbitrary files and directories stored on the system OS, including application source code or important system files (Fig. 12)

OS Command Injection in JAVA Code
Command injection attack executes arbitrary commands on the operating system through a vulnerable program or a web application. Command injection attacks are possible when an application passes the insecure user-supplied data to a specific system shell. The OS commands provided by the attacker; are regularly executed with all vital privileges of the vulnerable application [34]. This specific application passes a cmd parameter and executes it without any kind of validation or cleanup, which is vulnerable to command injection via the CommandExec method that results in the execution of OS. The above example (Fig. 13) is a java application that is vulnerable to command injection; since the method, CommandExec is passing a cmd parameter and executing it without validation or sanitization, leading to OS command execution. The attacker would send the request as following for executing commands in the system.

Vulnerabilities Mitigations in PHP and JAVA
More than 60% of all codebases used by enterprises contain at least one specific vulnerability from open source elements, according to the "Open-Source Security and Risk Analysis" (OSSRA) report [35]. The main aspect is to check whether the application is exclusive code or open-source code; it will indeed have vulnerabilities. However, the experts overwhelmingly admit that the open-source code libraries ' "components" are highly secured than the commercial applications. The dilemma is not within the use of open-source libraries. Application vulnerabilities thrive because it's complicated to write secure code. As a result, many companies are dependent on open source projects. We will list the processes of mitigating the web applications from the vulnerabilities of XSS, SQL, Path traversal, OS command injection in PHP and JAVA, based on the OWASP Cheat Sheet Series. We will also demonstrate the process of mitigating the vulnerability in the source code below the images. The OWASP Cheat Sheet Series was created to present a dense collection of high-quality knowledge on specific application security issues [36].
To protect the code from SQLi, we can use a function called mysql_real_escape_string in PHP. It is responsible for escaping certain characters in a string for use in a SQL declaration to avoid SQL injection attacks. The developer can use the "PreparedStatement" function to protect and escape the SQL query from SQL injection attacks to avoid SQL injection attacks in JAVA code. Prepared Statements help stop SQL injection because the values that are entered into a SQL query are transmitted to the SQL server; after the actual query is sent to the server. We can use the "htmlspecialchars" function to turn special characters into HTML entities to prevent XSS attacks in PHP codes. Developers can also use a custom method to convert special characters into HTML entities.
The developer uses the "basename ()" function to return only the filename part of a given path to prevent path traversal attacks. However, to make the code more secure, we can use another function called realpath() with the basename() function. It is needed to return the canonicalized absolute pathname and avoid path traversal attacks in PHP codes. Moreover, they can also use a customized method to protect their application from path traversal attacks in codes to check if the parameter contains ".." or "/." The developer can use a function escapeshellarg() in PHP, and in Java to prevent OS Command Injection, and they should use every method that executes a system command and prevent the end-user from supply their inputs in it.

Comparison with Static and Dynamic Tools
Comparing the tools has been conducted by installing the vulnerable applications in both PHP and java language. They are also vulnerable to SQL injection and cross-site scripting and directory traversal, and os command injection. After deploying the applications in windows server with Java tomcat and Linux server with PHP interpreter scanned vulnerable applications with the dynamic tools like AppSpider, Burp Suite Pro, with a windows machine. Examining the result from these scanners after it finishes scanning, Results are in a report format with all the details, i.e., the vulnerability found, the time it takes to scan the application, etc. Based on the report, a comparison takes place between scanners. In the static approach, we run the static tools scanner locally in Linux machine and using the time command combined with the static tools in a terminal and scan the vulnerable application statically after it finishes the scanning and produces the report of the finding, we compare the result based in the information we get for these scanners in static mode. The sonar cloud scanner is a web-based static scanner. We upload the vulnerable applications to it and scan them. After scanning, the scanner produces a report of the result with all the information (time, the vulnerability found), etc. The FindBug is a plugin tool that scans the vulnerable applications in IDE software and shows a report if there is a vulnerability in the codes (statically). Recorded the time of the plugin when it finishes and if it found the vulnerability in the code.

Discussion
There are a variety of tools for static source code scanners. A few of them are commercial, and others are free and open source. The selected five tools based on their scanning PHP and JAVA code features to focus on, mainly include SQL, XSS, Path Traversal, OS Command. It is needed to focus on the tools' popularity and the accuracy in finding out the vulnerability. Cobra is a source code security audit tool that supports the detection of major security issues and vulnerabilities in the source code of several development languages. SonarCloud is cloud-based, and it supports twenty-three languages Java, JS, C#, C/C++, Objective-C, and more. It also supports Deep Code analysis to examine all source files. ASST is an open-source developed with JavaScript. It uses Regular Expression to find out vulnerabilities. FindBugs is a program that uses static analysis to look for bugs in Java code.
All dynamic tool scanners are commercial as the large companies put a lot of effort into them. In this study, we have selected four dynamic tools to scan the vulnerable application; they support scanning PHP and JAVA applications, and these are SQL, XSS, Path Traversal, OS Command". Moreover, we have shown a compression between Static and Dynamic Tools in Tab. 1. It also shows that the dynamic tools are excellent in finding vulnerabilities; however, it is slower than static tools. The top vulnerability type found by static and dynamic tools ranks accordingly by SQL Injection, Cross-Site Scripting, Path Traversal, and OS Command Injection. Regarding the above analysis of the tools, we found that the top tools for static tool scanners are FindBug,Vulny, and the top tools for dynamic tool scanners are AppSpider, NetSparker. Fig. 14 shows the comparison between static and dynamic tools against speed and vulnerability. Analysis speed of Cobra, FindBug, Sonar, ASST, and Vulny are higher than others.

Conclusions
There are a large number of vulnerabilities and security flaws in applications, which interact on the internet. Developers and penetration testers need a reference point to create or verify that a web application is secure. OWASP is the most reliable standard to refer to for guidelines in the present scenario, and the tools draw one of the best ways to make web application security. New vulnerabilities are found every day, and even the most trivial vulnerability, if properly exploited, can cause significant damage to an organization. SQL injection is the most prevalent in this study, along with path traversal and OS command injection. Moreover, XSS can also lead to serious consequences. In many organizations, application security is the most vital aspect of the application lifecycle that is usually ignored, and cybersecurity is seen as a cost rather than an investment. Experimental results indicate that SQL queries can bypass ACL by avoiding regular authorization and authentication checks, and seldom SQL queries even may provide a way to host OS-level commands. SQLi in JAVA Code works because, for various applications, the only way to perform a given computation is to dynamically produce code that is, in turn, run by another system or component. When it uses untrusted data without effective sanitization, it drops an open door for attackers to exploit in generating this code. XSS attack happens when an attacker uses a web application to push malicious code, usually on a browser's page. An attacker exploits this vulnerability by intercepting the POST or GET request and injecting the variables with harmless JavaScript codes.

STATIC AND DYNAMIC TOOLS
Analysis Speed Vulnerability Found Figure 14: Comparison of Static vs. Dynamic tools against analysis speed and vulnerability A path traversal attack aims to reach out to files and directories stored outside the Webroot directory. Attackers can control this parameter to read files in the system leading to information disclosure. Command injection attacks are possible when an application passes insecure user-supplied data to a system shell. The application passes a cmd parameter and executes it without validation or cleanup, which is vulnerable to command injection via the CommandExec method, resulting in the execution of OS. To protect the code from SQLi, we can use a function called mysql_real_escape_string in PHP, responsible for escaping certain characters in a string for use in a SQL declaration to avoid SQL injection attacks. To avoid SQL injection attacks in JAVA code, the developer can use the "PreparedStatement" function to protect and escape the SQL query from SQL injection attacks. The developer uses the "basename ()" function to return only the filename part of a given path to prevent path traversal attacks. The users should use every method that executes a system command and prevent the end-user from supplying their inputs to prevent OS Command Injection. The developer can use the function escapeshellarg( ) in PHP and Java.
The four security risks are implemented in the web application, used as an analysis set for evaluating the effectiveness of Acunetix vulnerability scanners, Netsparker vulnerability scanners, Burp Suite Pro vulnerability scanners, AppSpider vulnerability scanners, Cobra vulnerability scanners, Sonar vulnerability scanners, FindBug vulnerability scanners, ASST vulnerability scanners, and Vulny vulnerability scanners. The evaluation of the reputed web application vulnerability scanners is done by examining the results obtained while running web scanners for the vulnerable web application in PHP and JAVA and then comparing the number of vulnerabilities detected.
Several vulnerability scanners might comprise of multiple reports, and they even have several techniques to test particular types of vulnerabilities. The comparison of the tools shows that the top languages in which the tools find security vulnerabilities are JAVA and PHP. It also shows that dynamic tools excel at finding security vulnerabilities but are slower than static tools. The vulnerabilities found by both static and dynamic tools are SQLi XSS, Path Traversal, and OS Command Injection. FindBug and Vulny are the best static, and AppSpider, NetSparker are the best dynamic tools. Therefore, developers and testers should attempt to use more scanners to discover web vulnerabilities. When we exploit vulnerable applications, we can imagine from our views. While possible attackers are evermore more creative than developers, they may have talented ideas to attack the system. Therefore, the evaluation result of these vulnerabilities may not be permanent. In the future, focus on finding complex vulnerabilities such as insecure direct object references related to PHP and JAVA applications. That strategy is referred to suit the workflow of web applications written in server-side programming languages like PHP, JSP, and ASP and even develops an automatic detection and mitigation of XSS vulnerabilities, SQL injection, and other attacks based on machine learning techniques.