Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

XSS payload in the background attribute of <body>

I’m reading an article in which one of the attack vector examples suggests doing the following to launch an attack:

<!-- background attribute -->
<body background="javascript:alert('XSS')">

However, when I include it in an HTML file and open it in localhost, nothing happens, does anyone know why?

Also, can someone explain the syntax javascript: and what it is called?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

However, when I include it in a html file and open it in localhost, nothing happens, does anyone know why?

The article you link to, which also mentions ActiveX and Flash, is extremely out of date.

Modern browsers block JavaScript scheme URLs in most contexts as, in those contexts, they were used almost exclusively to launch XSS attacks.

Also, can someone explain what is the syntax javascript: doing and what is it called?

JavaScript scheme URLs are designed to allow a resource to be generated via JS embedded in a URL instead of from an external location.

They have almost never been used for that.

Their most common uses are as a hackey alternative for a click event listener and as bookmarklets.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading