I am writing a static page for a tool: User pastes in base64 and it gets converted into plaintext. Not like it matters, but because the context is cryptographic, I want to prevent XSS.
I noticed document.getElementById("myTextarea").value allows you to change/set the content of a textarea without it appearing in the HTML code (even as an attribute), and unlike .innerHTML or attributes I couldn't do anything with .value.
So is .value actually safe? And is there a "simpler" HTML element that has similar behavior?
Maybe I am bad at Googling or just lazy, but I couldn't find anything on it. ("How do I google this?")
I know about validation and encoding, but then I can't feed the output straight into a reverse converter to get the initial base64.
Questions:
- Is
.valueXSS safe? - Is there a "simpler" HTML element that has similar behavior?
Edit: Removed (XSS does work in textarea innerHTML as asked and answered on other StackOverflow posts).
.innerHTMLbehaves like.textContent. I must have somehow found an old post about a library that made it possible for whatever reason.