Do not modify innerHTML or outerHTML

이 페이지는 아직 한국어로 제공되지 않으며 번역 작업 중입니다. 번역에 관한 질문이나 의견이 있으시면 언제든지 저희에게 연락해 주십시오.


ID: typescript-browser-security/inner-outer-html

Language: TypeScript

Severity: Warning

Category: Security


Properties like innerHTML and outerHTML should not be modified directly unless such modifications are clearly reviewed. Modifying innerHTML or outerHTML using user inputs that has not been validated can lead to XSS injection.

Learn More

Non-Compliant Code Examples

function nonCompliant(argument) {
  const content = '<div>' + argument + '</div>';
function nonCompliant(myArgument) {
  document.body.outerHTML = myArgument;
if (typeof(SERVER_DOMAIN) === 'undefined') {

const RECEIVE_URL = SERVER_DOMAIN + "/challenge_scoreboard.html" + "?origin=" + get_domain();

var window_ref = null;


function store_username() {
   var username;
   var username_obj;

   username_obj = document.getElementById("username");
   username = username_obj.value

   var welcome;
   welcome = document.getElementById("welcome");
   welcome.innerHTML = "Welcome " + html_encode (username);

   var set_username;
   set_username = document.getElementById("set_username");"none";

   var game;
   game = document.getElementById("game");"inline";

   // have to do time out so the window can open
   setTimeout (function () {send_username(username);}, 1000);

   return false;
} jetbrains

Seamless integrations. Try Datadog Code Analysis