Hello and welcome to the side. Very secure coding course. My name is Sonny Wear and this is a loss Top 10 for 2013
a three cross site scripting.
So first, our definition
cross eyed scripting which you should know is
abbreviated as X s s
X s s flaws occur whenever an application takes untrusted data
and sends it to a Web browser without proper validation and escaping.
Now, these twos terms I've highlighted here validation, of course, refers back to our input validation. We spoke a lot about that in regards to injection attacks in a one
now escaping has to do with something called output in coding. We're gonna spend some time talking about that and
understanding what that means.
Cross site scripting allows Attackers to execute scripts in the victim's browser, which can hijack user sessions, deface websites or redirect the user to malicious sites.
Now, I do want to caveat that this definition tends to be biased towards reflected cross site scripting. And there are other types which we're going to talk about in just a moment
Now here is the OSS chart. We can see from the attack vectors that the exploit ability is on average,
the impact is moderate
which is good news as defensive coders, is easy
now, it says, under the security weakness that cross site scripting is the most prevalent Web application security flaw. Cross site scripting flaws occur when applications include user supply data in a page sent to the browser without properly validating or escaping that content.
Now here they name two different types stored and reflected.
I'm actually going to refer to 1/3 type, which is sometimes a part of the attack of the other two types. Let's go ahead and talk about this now, so the times of cross site scripting are reflected, otherwise known as reflective.
And that basically targets one victim at a time where the actual script is either reflected back
in the victim's browser so that they can see something. Or it's being executed in the victim's browser and they are unaware
the next type is stored
can also be called permanent can also be called persistent. You'll see it described with any of these titles
now for a stored cross site scripting vulnerability. That means an actual trusted page has been infected,
and so all of the users that browse to that page
will be poisoned by that stored. Cross it scripting attack.
Dom based cross site scripting
is something that occurs on the client side in the browser.
However, the DOM, which is a document object model, can be the target of either reflective or stored cross site scripting. And we're gonna talk about that and see that in the demos.
So first, let's talk about cross site scripting reflected one of the vehicles that can be used to carry a reflected cross site scripting. Attack is a phishing attack,
is pretty familiar with phishing attacks. Usually they come in the form of an email, and in that email will be some sort of link.
Now, part of the link may be legitimate or look very legitimate and then upended at the end could be a malicious script.
When the victim clicks that link, it will be sent to the Web server of the site. However, there's some sort of vulnerability within the Web pages, and so there's no output in coding, which neutralizes the response. And so when that http response
actually gets sent back to our victim,
now for stored cross site scripting. This is where we have a trusted website that it's some portion of it has been compromised.
And so when the victim visits the site,
if it's something, for example, like an image than upon loading upon viewing the page, there's an on load where the image or in this case the
replaced image with a malicious script would get executed.
And then we have our victim. So everyone that browses to the website would then be affected.
Now for Dom based cross site scripting, the Dom is an acronym for Document Object Model. And this is something that your browser does behind the scenes for you. It's an actual tree representation of every single HTML page in every single session
that you may have inside of your browser. I'm showing an example of one on in the screen shot.
this gets attacked. It could be it could be the target of either
the reflected or stored cross site scripting attacks. What is usually of interest is the cookie, which is what I have highlighted there. So the cookie is going toe
credential information and, of course, by right by capturing the cookie than the attacker could then follow up with subsequent types of attacks, brute force attacks, session fixation, attacks and things that we talked about in a two broken authentication. A session management.
So the Dom based cross site scripting usually goes hand in hand with one of the other main types. So now let's take a look at some sample cross site scripting, vulnerable code.
So here we have a simple
variable called first name, which has gotten out of the request object.
It's being cast to a string and then it's assigned to a local variable called first name parameter.
Now the problem with the use of the local variable first named parameter, is that
there's been no sanitation or no cleansing or no input validation of the value that was placed inside of the first name variable.
And as we're going to see in the demos, this can cause love problems. It allows an attacker to basically place any value that they like, including jobs group code,
uh, into that variables value instead.
And so because the value is immediately stored in a local variable and then used throughout the rest of the program and more than likely probably sent back out to the browser or back out to the Web page without any output encoding. This makes for a cross site scripting vulnerability.
Now, if we take a look at the way some of these cross site scripting attacks are done, we can see that there's a legitimate U R L. In this example, it's my bank dot com with a submit form,
but appended to that is usually some sort of location. Redirect that will send the request or send the cookie to the Attackers website
And, of course, that can lead to the session fixation and other times of the ties that we talked about before now for stored cross site scripting. An example of this attack would be the sample HTML code below,
where we have an image and the sources image has been replaced. Instead of having the image file named there, we instead have the location of an evil hackers website.
And, of course, they're grabbing that document Cookie, the cookie that's stored in the Dom.
Now our case study is on Sammie Kim Car.
He is famous for writing some Java script code, which he actually inserted into cascading style sheet
And over a 24 hour period, he was able to have over a 1,000,000 friends like him, and the display that that would occur on everybody's page that was affected is seemly is my hero.
So this has become a very well known
um cross site scripting, attack, vulnerability and attack that was done in the past.
Now we're gonna go ahead and move into the demo section of her module.