News for hackers. Stuff that matters.
Re:The Annoying Site: Source by maddyboo on Sunday December 23, 2018 @06:10PM (#18749032)
This is interesting

  /**
   * Sites that link to theannoyingsite.com may specify `target='_blank'` to open the
   * link in a new window. For example, Messenger.com from Facebook does this.
   * However, that means that `window.opener` will be set, which allows us to redirect
   * that window. YES, WE CAN REDIRECT THE SITE THAT LINKED TO US.
   * Learn more here: https://www.jitbit.com/alexblog/256-targetblank---the-most-underestimated-vulnerability-ever/
   */
  function attemptToTakeoverReferrerWindow () {
    if (isParentWindow && window.opener && !isParentSameOrigin()) {
      window.opener.location = `${window.location.origin}/?child=true`
    }
  }
I checked in Chromium 70 and this only seems to work on the same origin - attempting to access `window.opener` cross-origin results in

  Uncaught DOMException: Blocked a frame with origin "https://example.com" from accessing a cross-origin frame
The article linked in the code [0] and the MDN page for window.opener [1] mention the use of `rel="noopener"` to prevent `window.opener` from being set, but that it's not supported in all browsers - particularly Firefox, which needs `noreferrer`. I am sure CORS headers also play a role in protecting from this. OWASP calls this technique 'reverse tabnabbing' [2].

There's a demo [3] of the effect - you can manually inspect the first link and change the href to [4] and then click the link to test how cross origin requests work.

[0] https://www.jitbit.com/alexblog/256-targetblank---the-most-u...

[1] https://developer.mozilla.org/en-US/docs/Web/API/Window/open...

[2] https://www.owasp.org/index.php/Reverse_Tabnabbing

[3] https://rawgit.com/waltertamboer/experiment-html-js-window-o...

[4] https://gitcdn.link/cdn/waltertamboer/experiment-html-js-win...

There are no comments on this comment yet.