XSS inside the array methods?

Advertisements  I have one user Inputted place (Search box) in my code let searchText = document.getElementById(‘search’).value and that input is used to search inside the array of objects using indexOf method as the following let searchTextIndex = data.map((obj)=>obj.Artist.toLowerCase()).indexOf(searchText.toLowerCase()) I tried );alert(‘XSS’ to escape the indexOf method but that doesn’t trigger so is it possible to… Read More XSS inside the array methods?

XSS payload in the background attribute of <body>

Advertisements 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… Read More XSS payload in the background attribute of <body>

How to make a XSS vulnerable site with a keyboard logger?

Advertisements I want to create an website which is vulnerable to an XSS attack where the attacker tries to inject an keylogger who logs the keystrokes of every victim on this website. Here is the deployed website and following the code: function submitted(){ alert(“Submitted!”); } <!DOCTYPE html> <html lang=”en”> <head> <meta charset=”UTF-8″> <meta http-equiv=”X-UA-Compatible” content=”IE=edge”>… Read More How to make a XSS vulnerable site with a keyboard logger?

Is it safe to use dangerouslySetInnerHTML with hard coded html strings?

Advertisements We have an alert component that renders important information for the user. However, this component has somewhat an abstraction where you just need to pass the content as an array of string. const Component = () => { const alertContent = [‘This is the first things’, ‘Second thing’, ‘third thing’]; return ( <AlertComponent content={alertContent}… Read More Is it safe to use dangerouslySetInnerHTML with hard coded html strings?

How to sanitize user input string in nodejs, before injecting it in a template engine or say simple JS template string?

Advertisements I have webpages (basically business cards) whose titles are created based on user inputs. I am planning to use simple JS template string for this purpose, instead of some template engine. (I am using express.js/node.js for this purpose) response.send(` <html> <head> <title>${user_inputed_title_got_from_DB}</title> <meta property="og:title" content="${some_more_user_content}" /> </head> <body> <script> window.location.href="/business-card/${user_input_number}"; </script> </body> </html>`) How… Read More How to sanitize user input string in nodejs, before injecting it in a template engine or say simple JS template string?