I have a webpage that blindly removes < and > as hardcoded rule. I know XSS doesn't always need < and > since it is not needed in HTML attribute and javascript contexts.
But is it possible to carry out XSS in HTML context without < and >? I saw it is possible in UTF-7(IE) where they can be replaced by other characters to make a valid HTML construct. Is it possible to do in any other way?
Or is it true that for HTML contexts just stripping < and > is sufficient since without them everything is treated as plaintext?
< > ' " & /in HTML context, but I've never understood the reason. It seems to me that just escaping<would actually be enough in practice. Maybe they are generalizing the advice for XML, but I'm still not sure why all those characters actually need to be escaped. – reed Apr 19 '20 at 16:39'or"(inside attributes). And you should always escape&. And it's simpler to say to always escape those characters, rather than depend on context. So that explains<,',", and&. As for/and>, I'm not sure, but if you have malformed HTML (say an attribute missing its closing quotation mark), they could cause harm, and it's probably easy enough to escape them anyway. – TRiG Jun 15 '23 at 09:22