If this is an email input field on my form:
<input autofocus="" class="emailinput form-control" id="id_email"
maxlength="254" name="email" required="" type="email">
I am trying to detect if the value changes AT ALL - particularly if the user used Javascript / jQuery / whatever to change it.
I watch for these events:
$("#id_email").on('input blur change paste keyup keydown keypress DOMAttrModified propertychange', function(e) {
console.log('Email field value changed!');
})
Then do this...
$('#id_email').val('" onMouseOver="alert(1);')
and sure enough, the text " onMouseOver="alert(1);
gets inserted without being detected.
What event should I be looking for to detect if a form field changes as the result of programmatically being inserted (by Javascript / jQuery for example)?
Edit
What is my use-case?
I am trying to provide a stupid-simple first line of defense against Cross-site Scripting (Reflected) attacks that prevent bots / tools from programmatically submitting known vulnerabilities into forms.
A bot / tool is going to try to do this undetected. That's why I was wondering if there's a way to detect if a field changes as a result of javascript.