Cross site scripting is a web application vulnerability that permits an attacker to inject code typically
HDMI or JavaScript into the content of an outside Web site.
When a victim views an infected page on this Web site the injected code will automatically executes
on the victim's browser.
Thus the attacker will be able to steal private information from the victim associated with the Web
site.
So here the point is that the victim trusts the web application which is in legitimate web application
but it's a vulnerable one and the attacker will inject this malicious code in order to exploit this
trust.
We have two types or mainly two types of course I scripting deflected which is known to be non persistent
and stored which is known to be persistent.
The reflected one actually occurs when a malicious script is deflected off a web application to the
victims of browser.
So the person here or the vulnerability actually takes place on the web browser and not on the application
itself.
The application is only vulnerable.
The script is activated through a link which sends a request to a Web site with a vulnerability that
enables the execution of a malicious script.
The vulnerability is typically a result of incoming requests not being sufficiently sanitized by the
website which allows for the manipulation of Web applications functions and activation of the malicious
script.
So here the issue is in the vulnerability of the Web site which allows an attacker to exploit this in
order to execute external scripts on the victims browser to distribute the malicious link.
The perpetrator typically embeds it into an email or a third party website such as comments on some
of the social media sections.
The link is embedded inside an anchor text that provokes the user to click on it.
Once the click happens the attack is executed or recall it.
It reflects off to the user.
The second type is this toward attack or stored cross site scripting.
It's known to be persistent and it is more damaging than the reflected one because it occurs when a
militia script is injected permanently into a vulnerable web application.
This injection takes place when there is a place to write when there is a place for user input such
as weakness or such as comments or such as comments and the discussion forums.
The impact of course such scripting is moderate for the reflected one but severe for the stored type
in Cali.
We have many automated tools that can help us find cross site scripting problems automatically in our
web applications.
Let's take an example here for it afflicted access as attack.
First the attacker will send an evil email to the victim after identifying that this domain is vulnerable
to cross site scripting.
So this is a legitimate domain but he attached a javascript file to it.
Using this link the victim receives this link through email and once he presses on the link the vulnerable
bank application takes data and includes it in a valid web page.
Now the victim browser thrusts the script from this domain and the attacker has full access to the victim's
accounts.
The next type of attack is the stored one where the perpetrator discovers a Web site that has a vulnerability
and will inject the script directly into the Web site or in the database through the front end.
Next the perpetrator injects.
As we said the script that is key now for each visit to the Web site.
The malicious script is activated automatically maybe on load and the attacker will have access to the
session cookies of the visitor.
Now help to protect ourselves from these types of attacks.
The most important thing is to use frameworks that automatically escape the cross site scripting by
design such as using the latest Dot Net framework the latest Ruby on Rails the latest react as etc..
It is also recommended to filter and sanitize input as much as possible.
It is also recommended to filter output or encode output in order to escape the characters that might
be used for coarse site scripting by using base64 encoding for example.
And it's advisable to enable the content security policy which is a defense in the mitigating control
against cross site scripting.