First of all, what is Cross Site Scripting (XSS)? XSS is when JavaScript code is run by a client on a website in an unauthorized manor via a textbox or other method. For example:
Notice how the text hello is rendered onto the screen. Now try using the textbox to render some HTML code. You will notice that this also renders to the screen.
Now try typing <script>alert("Hello");</script>
What happens? (reply to this thread with the answer)
While it may be a bit funny to write bold text to the page and run alerts in JavaScript, hackers can write code that can give them access to your account (if you had an account and were signed in on the given website).
Not convinced? Check out this demo where I use JavaScript to “hack” myself:
Indeed, I reset my github account (deleted every repo) to clean the account up, it was really messy, sadly the repo went away, however the source code for the module is pretty simple:
Wow. That’s scary, but also helpful if you want to make an extension so you’re always logged in to a website by syncing your session cookie across your devices.
That would trigger quite a lot of security systems as your user agent/ip may not be the same for all devices and would really confuse fingerprinting systems.
I actually transferred my Google not logged-in session cookie from an incognito tab to a normal one because I accidentally got Google dark mode in the incognito tab and wanted it in my main browser session. That’s one good use of transferring session cookies, right?
dark mode for what?
that would be an ideal use of transfering cookies because those are pereferences/non-tracking data. Flash has a similar thing for cookies and I do sometimes transfer the my flash data from computer to computer in school settings for convinience.
Google.com has dark mode in a limited beta, and I happened to get into the beta tester list in an incognito tab. I transferred the session cookie to a normal tab.
I think it’s also worth mentioning that if you’re making an HTML text-sharing website (or page, comment section, any user text-sharing at all), you should use .innerText instead of .innerHTML
User generated content should be sanitized before it is sent to the server and sent out to a user (you could make a mistake and forget to use .innerText)