What is it XSS ?
XSS which stands for cross site scripting it is a web application related vulnerability and is commonly found within web based applications, i.e., websites. Web applications are used in the web browser and are hosted on web servers. This type of attack occurs when the attacker injects "HTML" (S, 2020), JavaScript or other scripts within a web application such as a website, these scripts contain malicious codes/script. This becomes a problem because this type of attack can be injected inside trusted and validated websites frequently visited website, when a user accesses these websites that have malicious code injected in them it can prompt the users to perform actions on that website which will lead to a serious issues.
An example of this could be that a code is injected which prompts the user to "create" a new post, which to the user who visits this website seems normal but the code which was injected can lead to other consequences i.e., it can be used to steal user data by prompting them to enter their personal details before being allowed to post due to "verification process" which is in fact just a front to steal data. It can also be used to steal user accounts, take control, link to harmful content etc. Or you click a submit button but "unintentionally you transfer $100" (Bright Security, 2021).
XSS is split into three types,
(1) Reflected XSS - (2) Stored XSS - (3) DOM based XSS
How it works
The main types of attacks in XSS are the three mentioned above, so how exactly do they work ?
1. In this method of XSS, a web form or a URL contains the malicious script, this means that the attacker can create a malicious script and have it "embedded into URL" (Tozzi, 2023) which is needed for the users to visit the website, but the attacker can make this URL malicious by via XSS. The script is included in the server response and is run by the user's browser, this means that when a user clicks on the link it will activate the malicious content of the script.
2. Of the two (reflected and stored) stored XSS "is the more damaging of the two" (Online: nodate) In this method of XSS, the malicious script/code is kept on the target server indefinitely meaning it is there permanently, Usually in the database because the database for a site is a storage type for a site which always needs to be active otherwise there will be no saved information or history of any information about users that access the sit, i.e., no saved passwords, usernames, emails etc. The script is then delivered and run by the user's browser when they view the infected page.
3. In this method of XSS, malicious script tampers with a web page's Document Object Model (DOM), this is the programming interface for HTML and XML, this is what allows the scripts to engage with elements within a web page such changing size of text boxes causing odd behaviour or security problems, by changing the elements of the web page. "Majority of DOM XSS vulnerabilities can be found and reliably using Burp suite's web vulnerability scanner" (Online: nodate)
Demo:
This is the lab that we are going to go through, simply click access lab to start the lab.
To do this we are going to use the search bar found within the blogpost and enter our script.
Potential Impacts
XSS Attacks can cost up to tens of thousands !
"All of the CIA policies can be dishonored" (Yang et al., no date:4)by performing XSS attacks, There are several impacts of XSS attacks which can affect companies in terms of integrity, confidentiality and availability.
The way XSS attacks affect confidentiality is via attacks that allow the attacker to steal the information of victims, one example of this can be stealing cookies. With XSS attacks it is possible to steal the cookies of a victim and then use their personal information to impersonate and steal further information as cookies can contain login details. Attackers will effectively have control of their victims accounts allowing them to login and find their confidential information.Causes and Solution
1. Reflected XSS attacks are also usually caused by issues and problems found within Stored XSS attacks, therefore the recommendations for Stored XSS can be used here as well and also have similar causes. Such as both being involved in inadequate input validation. Some causes for reflected XSS attacks are;
- User-provided data that is directly included in URLs without sufficient validation or output encoding frequently results in reflected XSS vulnerabilities. An attacker might create a malicious URL that injects executable script code, for instance, if a search query parameter is mirrored in the URL without the necessary encoding.
- When online applications communicate with websites or services operated by outside parties and sites, reflected XSS attacks can be made easier for the attackers to implement. An XSS vulnerability can arise if user-supplied data is sent to outside sources and then returned in the application's response without sufficient validation and encoding.
- Making sure that all user-supplied information is correctly verified and sanitised as this has been used and tested by professionals showing that it "prevents web applications from XSS attacks" (Patil and Patil, 2015:1) , this is important especially with information contained in URLs and form submissions. You can also use whitelisting or input filtering to only allow safe and expected characters by validating input against anticipated forms/scripts.
- When the programme responds with user-supplied data, utilise context-specific output encoding or escaping, and depending on the output context use the proper encoding routines, such as JavaScript and HTML encoding.
- When encoding web sites, user-generated material must be appropriately encoded to prevent the execution of inserted scripts, when the user-generated material is displayed on the web pages without proper encoding. Failing to do this can lead to attackers being able to inject scripts.
- The lack of input/output validation and the use of insufficient secure coding techniques are examples of inadequate security measures that might result in stored XSS vulnerabilities.
- Strict input validation should be implemented by verifying and sanitising user-provided data and it is shown that even though it may not be effective against a lot of instances it is still "useful as a first level of defence" (Bisht and Venkatakrishnan, no date:1). To guarantee that only anticipated and secure data is received, use whitelisting or input filtering.
- When presenting user-generated content on web pages, make sure to properly encrypt or escape it. Depending on the context such as, HTML and JavaScript and ensure to use the correct encoding routines.
- The use of quotes to attributes is also worth looking into because attributes that have added quotes can only be escaped via quote to which it corresponds.
3. Dom based XSS occur because attackers are able to manipulate/modify Document object model of webpages in order to execute their malicious scripts. This type can be caused by;
- Insufficient validation or sanitization of user-generated data that is used in client-side operations will make it so applications that extensively rely on JavaScript and dynamically alter the DOM insecure. This means that these applications are vulnerable.
- Incorrect or unsafe JavaScript code techniques such as using innerHTML or eval() without adequate validation might cause security holes that attackers can take advantage of. This means that having employees who are still new to JavaScript code web pages isn't a good idea as they can use outdated or less secure coding techniques for webpages.
- Regular security audits and penetration tests should be carried out in order to spot and fix vulnerabilities.
- Users should be made aware of the dangers of XSS attacks and urged to take caution when dealing with websites and avoid clicking on shady links. In other words simply training employees and customers about XSS attacks and sending out regular warning about improper links etc.
- Use security headers to further defend against XSS attacks, such as X-XSS-Protection and X-Content-Type-Options, in others words enhancing defence against Cross-Site Scripting (XSS) assaults by using certain HTTP response headers.
- The use of security frameworks and libraries, such as sanitization libraries or security-focused web frameworks, that come with built-in defences against XSS vulnerabilities. These will provide an extra layer of pre-loaded security features against latest attacks.
Comments
Post a Comment