XSS vulnerable app 001-b
Sep 25, 2019 Update: Aug 28, 2021
All HTML tags are really stripped on this page using the latest MILITARY GRADE REGEX. No HTML, no hacking!
HTML
CSS
JavaScript
<center>
<input type="text" id="input"/>
<div id="screen"></div>
</center>
document.querySelector('#input').addEventListener('keyup', function(e) {
if (e.keyCode === 13) {
let tagString = document.querySelector('#input').value;
// disable all HTML tags globally
tagString = tagString.replace(/(<([^>]+)>)/ig, '');
const range = document.createRange();
range.selectNode(document.getElementsByClassName('applet').item(0));
const documentFragment = range.createContextualFragment(tagString);
document.querySelector('#screen').appendChild(documentFragment);
}
});
#input {
font-size: 16px;
height: 26px;
width: 100%;
margin-bottom: 10px;
padding: 20px;
}
.applet-html {
padding: 20px;
}
.applet {
margin-bottom: 20px;
}
Takeaways and notes#
- Not allowing HTML tags at all, takes away a lot of the attack surafce area
- Is there a way to exploit this?