Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

247
Visualizações
Can xss attacks bypass InnerText?

all my friend's website DOM use innerText instead of innerHTML. I tried all possible ways i know but none of them work. Is it anyway that I can bypass innerText and make the tag work just like with the innerHTML tag?

Thanks

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Why not just using innerHTML ? and then use DOMPurify to sanitize your DOM. it finds any potential ways that the user can add data like javascript:alert('hacked'); and makes them as normal HTML.

DOMPurify is a DOM-only, super-fast, uber-tolerant XSS sanitizer for HTML, MathML and SVG.

look at the below example:

DOMPurify.sanitize('<img src=x onerror=alert(1)//>'); // becomes <img src="x">

you can use sanitize method then wrapped your html field or in this case image to avoid xss

another example,

const html = `<input type="text" name="text" />`;

ELEMENT.innerHTML = DOMPurify.sanitize(html, { // optional configurations // })

so if a user tries to add for example an image inside the input like

DOMpurify notices onload on image and removes it from submitting

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda