CodeWitness

Audit a dynamic HTML sink

The name can be controlled by a user, but the code inserts it into an HTML parser.

function showName(container, name) {
  container.innerHTML = `<p>${name}</p>`;
}

If the intended output is plain text, use a text-only DOM API rather than an HTML sink.

How should the application display an untrusted name as plain text?