In a tool I'm creating, there are several <input>
and <textarea>
fields that are essentially acting as glorified notepads. The only things that happen to these fields are basic editing (adding strings to the value) or copying/pasting them. Here's a snippet of one part of the tool:
HTML:
<button onclick="auth();" class="bOwn bLight">Copy</button> <button onclick="authClear();" class="bOwn bRed">Clear</button>
<input type="checkbox" id="postSCActivity" name="postSCActivity" value="Activity after Stat Change"><label for="postSCActivity">Activity after Status Change?</label><br>
<textarea id="auth" class="textbox"></textarea><p>
JS:
function auth() {
$("#auth").removeClass("textSelected");
lastClickedField = "#auth";
var prefix = "\n\n";
var content = $("#auth").val();
var suffix = " //" + $("#opcode").val();
var postSCActivity = "";
if ($("#postSCActivity").prop("checked")) {
postSCActivity = " Additional activity follows the status change(s).";
} else {
postSCActivity = " No activity follows the status change(s).";
}
if (content != "") {
$("#auth").val(prefix + content + postSCActivity + suffix);
$("#auth").select();
document.execCommand('copy');
$("#auth").addClass("textSelected");
$("#auth").val(content);
} else {
$('#blankCopy').show();
$("#blankButton").focus();
}
}
function authClear() {
$("#auth").val("");
$("#auth").removeClass("textSelected");
$("#postSCActivity").prop("checked", false);
}
For the above Javascript, the variable suffix
is entered at a login screen that only accepts letters and numbers, no symbols.
At no point does anything get submitted; this is literally only a glorified notepad that automatically adds text and copies text to the clipboard. Are there any known ways to insert javascript that would run? I can't figure out anything... I tried typing out functions, but it just copies the text. I feel it's pretty solid, but knowing my luck, I'm overlooking something. I wanted to see what I could be missing, and how I can better secure the tool, if anything else has to be done.